From b7f63450ed6ae0d25ac5bd5b3828bf747abf25e3 Mon Sep 17 00:00:00 2001 From: BlasenhauerJ Date: Thu, 27 Apr 2023 13:56:46 +0200 Subject: [PATCH 1/2] add special method for mode --- src/ui/templates/settings_plugins.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/templates/settings_plugins.html b/src/ui/templates/settings_plugins.html index 479369268..7ac28227e 100644 --- a/src/ui/templates/settings_plugins.html +++ b/src/ui/templates/settings_plugins.html @@ -171,7 +171,7 @@ data-plugin-item="{{plugin['id']}}" {% if value["type"] == "check" %}
+ != 'default' %}{{global_config[setting]['value']}}{% else %}no{% endif %}" data-default-method="{% if setting in ["AUTOCONF_MODE", "SWARM_MODE", "KUBERNETES_MODE"] %}mode{% else %}{{global_config[setting]['method']}} {% endif %}" /> Date: Thu, 27 Apr 2023 14:42:57 +0200 Subject: [PATCH 2/2] remove hidden input checkbox + fix script --- src/ui/static/js/services.js | 27 +++++++++----------------- src/ui/static/js/utils/form.js | 8 -------- src/ui/templates/settings_plugins.html | 9 ++------- 3 files changed, 11 insertions(+), 33 deletions(-) diff --git a/src/ui/static/js/services.js b/src/ui/static/js/services.js index 3cf637152..51ba3c265 100644 --- a/src/ui/static/js/services.js +++ b/src/ui/static/js/services.js @@ -144,18 +144,18 @@ class ServiceModal { //for all other settings values const defaultMethod = inp.getAttribute("data-default-method"); - const defaultVal = inp.getAttribute("data-default-value") || ""; + const defaultVal = inp.getAttribute("data-default-value"); //SET VALUE if (inp.getAttribute("type") === "checkbox") { inp.checked = defaultVal === "yes" ? true : false; inp.setAttribute("value", defaultVal); - inp.value = defaultVal; inp.setAttribute("data-method", defaultMethod); } if (inp.getAttribute("type") !== "checkbox") { inp.setAttribute("value", defaultVal); + inp.value = defaultVal; inp.setAttribute("data-method", defaultMethod); } @@ -302,14 +302,6 @@ class ServiceModal { inp.checked = value === "yes" ? true : false; inp.setAttribute("value", value); inp.setAttribute("data-method", method); - - if (inp.hasAttribute("disabled")) { - const hidden_inp = inp - .closest("div[data-checkbox-handler]") - .querySelector("input[type='hidden']"); - hidden_inp.setAttribute("value", value); - hidden_inp.setAttribute("data-method", method); - } } //for select if (inp.tagName === "SELECT") { @@ -691,16 +683,15 @@ class Multiple { //for settings input if (inp.getAttribute("type") === "checkbox") { inp.checked = value === "yes" ? true : false; - if (inp.hasAttribute("disabled")) { - const hidden_inp = inp - .closest("div[data-checkbox-handler]") - .querySelector("input[type='hidden']"); - hidden_inp.setAttribute("value", value); - } + inp.setAttribute("value", value); + inp.setAttribute("data-method", method); } - inp.value = value; - inp.setAttribute("data-method", method); + if (inp.getAttribute("type") !== "checkbox") { + inp.setAttribute("value", value); + inp.value = value; + inp.setAttribute("data-method", method); + } }); } catch (err) {} //update select diff --git a/src/ui/static/js/utils/form.js b/src/ui/static/js/utils/form.js index f6ff726d7..60727f77c 100644 --- a/src/ui/static/js/utils/form.js +++ b/src/ui/static/js/utils/form.js @@ -24,14 +24,6 @@ class Checkbox { checkboxEl.checked ? checkboxEl.setAttribute("value", "yes") : checkboxEl.setAttribute("value", "no"); - - //set custom input hidden value - const newValue = checkboxEl.getAttribute("value"); - const inpServ = checkboxEl - .closest("[data-checkbox-handler]") - .querySelector('input[type="hidden"]'); - inpServ.setAttribute("value", newValue); - inpServ.value = newValue; } } catch (err) {} }); diff --git a/src/ui/templates/settings_plugins.html b/src/ui/templates/settings_plugins.html index 7ac28227e..3434f68ae 100644 --- a/src/ui/templates/settings_plugins.html +++ b/src/ui/templates/settings_plugins.html @@ -171,7 +171,7 @@ data-plugin-item="{{plugin['id']}}" {% if value["type"] == "check" %}
- + -