Simplification configuration

This commit is contained in:
Jean-Christophe Engel 2023-10-25 14:36:34 +02:00
parent a28d725d65
commit 8e43543dd1

View File

@ -11,12 +11,9 @@
{{* Traiter l'envoi du formulaire *}}
{{#form on="save"}}
{{:assign var="labels" value=$_POST.input_fields.label}}
{{:assign var="owner_keys" value=$_POST.input_fields.owner|keys}}
{{#foreach from=$_POST.input_fields|array_transpose item="field"}}
{{:assign var="input_fields." label=$field.label|trim owner=$field.owner|boolval}}
{{/foreach}}
{{#foreach from=$_POST.input_fields|array_transpose item="field"}}
{{:assign var="input_fields." label=$field.label|trim owner=$field.owner|boolval}}
{{/foreach}}
{{:save key="config"
validate_schema="./config.schema.json"
@ -26,14 +23,14 @@
{{:redirect to="./config.html?ok=1"}}
{{/form}}
{{* types d'entrées *}}
{{* types d'entrées par défaut *}}
{{:assign var='types_entrees.Achat' value=1}}
{{:assign var='types_entrees.Don' value=1}}
{{:assign var='types_entrees.Récupération' value=1}}
{{:assign var='types_entrees.Location' value=0}}
{{:assign var='types_entrees.Emprunt' value=0}}
{{* types de sorties *}}
{{* types de sorties par défaut *}}
{{:assign var='types_sorties.' value='Vente'}}
{{:assign var='types_sorties.' value='Don'}}
{{:assign var='types_sorties.' value='Location'}}
@ -56,9 +53,9 @@
<td>{{:input type="text" name="input_fields[label][]" default=$input_field.label}}</td>
<td>
<label>
{{:input type="hidden" name="input_fields[owner][]" value=0}}
{{:input type="checkbox" name="input_fields[owner][]" value=1 default=$input_field.owner}}
Proprio ?
{{:input type="hidden" name="input_fields[owner][]" value=0}}
</label>
</td>
<td class="action">
@ -71,9 +68,9 @@
<td>{{:input type="text" name="input_fields[label][]" default=$label}}</td>
<td>
<label>
{{:input type="hidden" name="input_fields[owner][]" value=0}}
{{:input type="checkbox" name="input_fields[owner][]" value=1 default=$value}}
Proprio ?
{{:input type="hidden" name="input_fields[owner][]" value=0}}
</label>
</td>
<td class="action">
@ -156,11 +153,9 @@
// Désactiver les champs caché des checkbox cochés
function desactiverCache(id_body) {
var table = document.querySelector(id_body);
let lignes = table.children;
for (let i = 0; i < lignes.length; ++i) {
let idCase = lignes[i].querySelector("input[type=checkbox]");
let cache = lignes[i].querySelector("input[type=hidden]"); // le champ caché
for (let ligne of document.querySelector(id_body).children) {
let idCase = ligne.querySelector("input[type=checkbox]");
let cache = ligne.querySelector("input[type=hidden]"); // le champ caché
if (idCase.checked) {
cache.disabled = true;
}