diff --git a/_nav.html b/_nav.html index 44eafb7..23df109 100644 --- a/_nav.html +++ b/_nav.html @@ -5,5 +5,6 @@
  • Catégories
  • Entrées
  • Sorties
  • +
  • Configuration
  • diff --git a/config.html b/config.html new file mode 100644 index 0000000..6f9c811 --- /dev/null +++ b/config.html @@ -0,0 +1,137 @@ +{{#restrict section="config" level="admin" block=true}}{{/restrict}} +{{:admin_header title="Configuration" current="module_equipment"}} + +{{* barre de navigation *}} +{{:include file="/%s/_nav.html"|args:$module.name current="config"}} + +{{if $_GET.ok}} +

    Configuration enregistrée.

    +{{/if}} + +{{* 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=$labels item="label"}} + {{if $label|in:$owner_keys}} + {{* label présent *}} + {{:assign var="input_fields." label=$label|trim owner=1|boolval}} + {{else}} + {{* label absent *}} + {{:assign var="input_fields." label=$label|trim owner=0|boolval}} + {{/if}} +{{/foreach}} + + {{:save key="config" + validate_schema="./config.schema.json" + inputNature=$input_fields + outputNature=$_POST.output_fields + }} + {{:redirect to="./config.html?ok=1"}} +{{/form}} + +{{* types d'entrées *}} +{{: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 *}} +{{: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'}} + +
    +
    + Entrées + + + + + + + + + + {{#foreach from=$module.config.inputNature item="input_field"}} + + + + + + {{else}} + {{#foreach from=$types_entrees key="label" item="value"}} + + + + + + {{/foreach}} + {{/foreach}} + +
    Type d'entréePropriétaire ?
    Cocher si l'association devient propriétaire du matériel
    Action
    {{:input type="text" name="input_fields[label][]" default=$input_field.label}} + {{:button label="Retirer" shape="minus" onclick="this.parentNode.parentNode.remove();"}} +
    {{:input type="text" name="input_fields[label][]" default=$label}} + {{:button label="Retirer" shape="minus" onclick="this.parentNode.parentNode.remove();"}} +
    +

    + {{:button shape="plus" + label="Ajouter un champ" + onclick="var a = document.querySelector('.input_fields tbody').lastElementChild; + var b = a.cloneNode(true); + b.querySelector('input[type="text"]').value = null; + b.querySelector('input[type="checkbox"]').checked = false; + a.parentNode.append(b);"}} +

    +
    + +
    + Sorties + + + + + + + + + {{#foreach from=$module.config.outputNature item="output_field"}} + + + + + {{else}} + {{#foreach from=$types_sorties item="value"}} + + + + + {{/foreach}} + {{/foreach}} + +
    Type de sortieAction
    {{:input type="text" name="output_fields[]" default=$output_field.label}} + {{:button label="Retirer" shape="minus" onclick="this.parentNode.parentNode.remove();"}} +
    {{:input type="text" name="output_fields[]" default=$value}} + {{:button label="Retirer" shape="minus" onclick="this.parentNode.parentNode.remove();"}} +
    +

    + {{:button shape="plus" + label="Ajouter un champ" + onclick="var a = document.querySelector('.output_fields tbody').lastElementChild; + var b = a.cloneNode(true); + b.querySelector('input[type="text"]').value = null; + a.parentNode.append(b);"}} +

    +
    + +

    + {{:button type="submit" name="save" label="Enregistrer" shape="right" class="main"}} +

    +
    + + +{{:admin_footer}} diff --git a/config.schema.json b/config.schema.json new file mode 100644 index 0000000..fd22ed7 --- /dev/null +++ b/config.schema.json @@ -0,0 +1,28 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "inputNature": { + "description": "Nature des entrées", + "type": "array", + "items": { + "type": "object", + "properties": { + "label" : { + "type" : "string" + }, + "owner" : { + "type" : "boolean" + } + } + } + }, + "outputNature": { + "description": "Nature des sorties", + "type": "array", + "items": { + "type": "string" + } + } + } +}