remove hidden input checkbox + fix script

This commit is contained in:
BlasenhauerJ 2023-04-27 14:42:57 +02:00
parent b7f63450ed
commit 01d8c65c96
3 changed files with 11 additions and 33 deletions

View File

@ -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

View File

@ -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) {}
});

View File

@ -171,7 +171,7 @@ data-plugin-item="{{plugin['id']}}"
{% if value["type"] == "check" %}
<div data-checkbox-handler="{{value['id']}}" class="relative mb-7 md:mb-0 z-10">
<input id="{{setting}}" name="{{setting}}"
data-default-method="{% if setting in ["AUTOCONF_MODE", "SWARM_MODE", "KUBERNETES_MODE"] %}mode{% else %}{{global_config[setting]['method']}} {% endif %}"
data-default-method="{% if setting in ["AUTOCONF_MODE", "SWARM_MODE", "KUBERNETES_MODE"] %}mode{% else %}{{global_config[setting]['method']}}{% endif %}"
data-default-value="{{global_config[setting]['value']}}" {% if
setting in ["AUTOCONF_MODE", "SWARM_MODE", "KUBERNETES_MODE"] or global_config[setting]['method'] != 'ui' and global_config[setting]['method']
!= 'default' %} disabled {% endif %}
@ -196,11 +196,7 @@ data-plugin-item="{{plugin['id']}}"
value="{% if
setting in ["AUTOCONF_MODE", "SWARM_MODE", "KUBERNETES_MODE"] or global_config[setting]['method'] != 'ui' and global_config[setting]['method']
!= 'default' %}{{global_config[setting]['value']}}{% else %}no{% endif %}" />
<input type="hidden" name="{{setting}}" value="{% if
setting in ["AUTOCONF_MODE", "SWARM_MODE", "KUBERNETES_MODE"] or global_config[setting]['method'] != 'ui' and global_config[setting]['method']
!= 'default' %}{{global_config[setting]['value']}}{% else %}no{% endif %}" data-default-value="{% if
setting in ["AUTOCONF_MODE", "SWARM_MODE", "KUBERNETES_MODE"] or global_config[setting]['method'] != 'ui' and global_config[setting]['method']
!= '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 %}" />
<svg
data-checkbox-handler="{{value['id']}}"
class="pointer-events-none absolute fill-white dark:fill-gray-300 left-0 top-0 translate-x-1 translate-y-2 h-3 w-3"
@ -403,7 +399,6 @@ data-plugin-item="{{plugin['id']}}"
dark:disabled:border-gray-800 disabled:text-gray-700
dark:disabled:text-gray-300" type="checkbox" data-pattern="{{value['regex']|safe}}"
value="{{value['default']}}" />
<input type="hidden" name="{{setting}}_SCHEMA" value="no" data-default-value="no" data-default-method="default" />
<svg
data-checkbox-handler="{{value['id']}}"
class="pointer-events-none absolute fill-white dark:fill-gray-300 left-0 top-0 translate-x-1 translate-y-2 h-3 w-3"