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