From b16abc157ee584f4be80a537ee24ec9e5ff25496 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 17 Feb 2021 19:34:54 +0300 Subject: * App: rename hidden to hidden_tag * search: use client dialog * add some form field helpers --- js/App.js | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) (limited to 'js/App.js') diff --git a/js/App.js b/js/App.js index bb861829d..9d8f6c275 100644 --- a/js/App.js +++ b/js/App.js @@ -18,14 +18,44 @@ const App = { is_prefs: false, LABEL_BASE_INDEX: -1024, FormFields: { - hidden: function(name, value, id = "") { - return `` + attributes_to_string: function(attributes) { + return Object.keys(attributes).map((k) => + `${App.escapeHtml(k)}="${App.escapeHtml(attributes[k])}"`) + .join(" "); }, - select_hash: function(name, value, values, attributes) { + hidden_tag: function(name, value, attributes = {}, id = "") { + return `` + }, + // allow html inside because of icons + button_tag: function(value, type, attributes = {}) { + return `` + + }, + icon: function(icon, attributes = {}) { + return `${icon}`; + }, + submit_tag: function(value, attributes = {}) { + return this.button_tag(value, "submit", {...{class: "alt-primary"}, ...attributes}); + }, + cancel_dialog_tag: function(value, attributes = {}) { + return this.button_tag(value, "", {...{onclick: "App.dialogOf(this).hide()"}, ...attributes}); + }, + select_tag: function(name, value, values = [], attributes = {}, id = "") { + return ` + + ` + }, + select_hash: function(name, value, values = {}, attributes = {}, id = "") { return ` - ${Object.keys(values).map((vk) => - `` + `` ).join("")} ` -- cgit v1.2.3-54-g00ecf