From 08ce30c4cf44d733426111fdf938b4f7dd2ddb50 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Mon, 30 Oct 2023 16:43:15 +0100 Subject: [PATCH] =?UTF-8?q?config=20:=20ajout=20=C3=A9tat=20d=C3=A9finitif?= =?UTF-8?q?=20d'une=20sortie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.html | 53 ++++++++++++++++++++++++++++++++-------------- config.schema.json | 12 +++++++++-- 2 files changed, 47 insertions(+), 18 deletions(-) diff --git a/config.html b/config.html index e3b2a36..4215003 100644 --- a/config.html +++ b/config.html @@ -15,10 +15,14 @@ {{:assign var="input_fields." label=$field.label|trim owner=$field.owner|boolval}} {{/foreach}} + {{#foreach from=$_POST.output_fields|array_transpose item="field"}} + {{:assign var="output_fields." label=$field.label|trim final=$field.final|boolval}} + {{/foreach}} + {{:save key="config" validate_schema="./config.schema.json" inputNature=$input_fields - outputNature=$_POST.output_fields + outputNature=$output_fields }} {{:redirect to="./config.html?ok=1"}} {{/form}} @@ -31,10 +35,10 @@ {{:assign var='types_entrees.Emprunt' value=0}} {{* types de sorties par défaut *}} -{{:assign var='types_sorties.' value='Vente'}} -{{:assign var='types_sorties.' value='Don'}} -{{:assign var='types_sorties.' value='Location'}} -{{:assign var='types_sorties.' value='Prêt'}} +{{:assign var='types_sorties.Vente' value=1}} +{{:assign var='types_sorties.Don' value=1}} +{{:assign var='types_sorties.Location' value=0}} +{{:assign var='types_sorties.Prêt' value=0}}
@@ -43,7 +47,7 @@ Type d'entrée - Propriétaire ?
Cocher si l'association devient propriétaire du matériel + Propriétaire ?
Cocher si l'association devient propriétaire du matériel Action @@ -94,21 +98,36 @@ Type de sortie + Définitif ?
Cocher si la sortie est définitive Action {{#foreach from=$module.config.outputNature item="output_field"}} - {{:input type="text" name="output_fields[]" default=$output_field.label}} + {{:input type="text" name="output_fields[label][]" default=$output_field.label}} + + + {{:button label="Retirer" shape="minus" onclick="this.parentNode.parentNode.remove();"}} {{else}} - {{#foreach from=$types_sorties item="value"}} + {{#foreach from=$types_sorties key="label" item="value"}} - {{:input type="text" name="output_fields[]" default=$value}} + {{:input type="text" name="output_fields[label][]" default=$label}} + + + {{:button label="Retirer" shape="minus" onclick="this.parentNode.parentNode.remove();"}} @@ -131,7 +150,7 @@ label="Enregistrer" shape="right" class="main" - onclick="return desactiverCache('#input_body');" + onclick="return desactiverCache('#input_body', '#output_body');" }}

@@ -152,12 +171,14 @@ } // Désactiver les champs caché des checkbox cochés - function desactiverCache(id_body) { - 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; + function desactiverCache(...id_body) { + for (const id of id_body) { + for (let ligne of document.querySelector(id).children) { + let idCase = ligne.querySelector("input[type=checkbox]"); + let cache = ligne.querySelector("input[type=hidden]"); // le champ caché + if (idCase.checked) { + cache.disabled = true; + } } } } diff --git a/config.schema.json b/config.schema.json index fd22ed7..0acbb84 100644 --- a/config.schema.json +++ b/config.schema.json @@ -19,9 +19,17 @@ }, "outputNature": { "description": "Nature des sorties", - "type": "array", + "type": ["array", "null"], "items": { - "type": "string" + "type": "object", + "properties": { + "label" : { + "type" : "string" + }, + "final" : { + "type" : "boolean" + } + } } } }