Ajout gestion configuration
This commit is contained in:
parent
c190d72f3c
commit
50230bc673
@ -5,5 +5,6 @@
|
|||||||
<li {{if $current == 'categories'}} class="current"{{/if}}><a href="{{$base_path}}/categories/index.html">Catégories</a></li>
|
<li {{if $current == 'categories'}} class="current"{{/if}}><a href="{{$base_path}}/categories/index.html">Catégories</a></li>
|
||||||
<li {{if $current == 'entrees'}} class="current"{{/if}}><a href="{{$base_path}}/mouvements/entrees/index.html">Entrées</a></li>
|
<li {{if $current == 'entrees'}} class="current"{{/if}}><a href="{{$base_path}}/mouvements/entrees/index.html">Entrées</a></li>
|
||||||
<li {{if $current == 'sorties'}} class="current"{{/if}}><a href="{{$base_path}}/mouvements/sorties/index.html">Sorties</a></li>
|
<li {{if $current == 'sorties'}} class="current"{{/if}}><a href="{{$base_path}}/mouvements/sorties/index.html">Sorties</a></li>
|
||||||
|
<li {{if $current == 'config'}} class="current"{{/if}}><a href="{{$base_path}}/config.html">Configuration</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
137
config.html
Normal file
137
config.html
Normal file
@ -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}}
|
||||||
|
<p class="block confirm">Configuration enregistrée.</p>
|
||||||
|
{{/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'}}
|
||||||
|
|
||||||
|
<form method="post" action="">
|
||||||
|
<fieldset>
|
||||||
|
<legend>Entrées</legend>
|
||||||
|
<table class="list input_fields">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Type d'entrée</th>
|
||||||
|
<th>Propriétaire ? <br/> <span class="help" style="font-weight:normal">Cocher si l'association devient propriétaire du matériel</span></th>
|
||||||
|
<th>Action</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{{#foreach from=$module.config.inputNature item="input_field"}}
|
||||||
|
<tr>
|
||||||
|
<td>{{:input type="text" name="input_fields[label][]" default=$input_field.label}}</td>
|
||||||
|
<td><label>{{:input type="checkbox" name="input_fields[owner][%s]"|args:$input_field.label value=1 default=$input_field.owner}}oui</label></td>
|
||||||
|
<td class="action">
|
||||||
|
{{:button label="Retirer" shape="minus" onclick="this.parentNode.parentNode.remove();"}}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{{else}}
|
||||||
|
{{#foreach from=$types_entrees key="label" item="value"}}
|
||||||
|
<tr>
|
||||||
|
<td>{{:input type="text" name="input_fields[label][]" default=$label}}</td>
|
||||||
|
<td><label>{{:input type="checkbox" name="input_fields[owner][]" value=1 default=$value}}oui</label></td>
|
||||||
|
<td class="action">
|
||||||
|
{{:button label="Retirer" shape="minus" onclick="this.parentNode.parentNode.remove();"}}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{{/foreach}}
|
||||||
|
{{/foreach}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<p class="actions">
|
||||||
|
{{: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);"}}
|
||||||
|
</p>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<legend>Sorties</legend>
|
||||||
|
<table class="list output_fields">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Type de sortie</th>
|
||||||
|
<th>Action</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{{#foreach from=$module.config.outputNature item="output_field"}}
|
||||||
|
<tr>
|
||||||
|
<td>{{:input type="text" name="output_fields[]" default=$output_field.label}}</td>
|
||||||
|
<td class="action">
|
||||||
|
{{:button label="Retirer" shape="minus" onclick="this.parentNode.parentNode.remove();"}}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{{else}}
|
||||||
|
{{#foreach from=$types_sorties item="value"}}
|
||||||
|
<tr>
|
||||||
|
<td>{{:input type="text" name="output_fields[]" default=$value}}</td>
|
||||||
|
<td class="action">
|
||||||
|
{{:button label="Retirer" shape="minus" onclick="this.parentNode.parentNode.remove();"}}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{{/foreach}}
|
||||||
|
{{/foreach}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<p class="actions">
|
||||||
|
{{: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);"}}
|
||||||
|
</p>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<p class="submit">
|
||||||
|
{{:button type="submit" name="save" label="Enregistrer" shape="right" class="main"}}
|
||||||
|
</p>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
{{:admin_footer}}
|
28
config.schema.json
Normal file
28
config.schema.json
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user