Vérification de la possibilité de supprimer un type de mouvement dans

la config
This commit is contained in:
Jean-Christophe Engel 2023-11-25 11:57:09 +01:00
parent e2d90b3da5
commit f47e4b0892

View File

@ -48,20 +48,43 @@
</thead> </thead>
<tbody id="input_body"> <tbody id="input_body">
{{#foreach from=$module.config.inputNature item="input_field"}} {{#foreach from=$module.config.inputNature item="input_field"}}
{{* Vérifier si la suppression de ce type d'entrée est possible *}}
{{:assign suppr=true}}
{{#load type="movement" where="$$.inputNature = :libelle" :libelle=$input_field.label}}
{{:assign suppr=false}}
{{/load}}
<tr> <tr>
<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>{{:input type="select" name="input_fields[type][]" options=$types_entrees default=$input_field.type required=true default_empty="— Choisir un type —"}}</td> <td>{{:input type="select" name="input_fields[type][]" options=$types_entrees default=$input_field.type required=true default_empty="— Choisir un type —"}}</td>
<td class="action"> <td class="action">
{{:button label="Retirer" shape="minus" onclick="this.parentNode.parentNode.remove();"}} {{if $suppr}}
{{:button label="Supprimer" shape="minus" onclick="this.parentNode.parentNode.remove();"}}
{{else}}
{{:button label="Supprimer" shape="minus" disabled=true}}
{{/if}}
</td> </td>
</tr> </tr>
{{else}} {{else}}
{{* pas de config enregistrée : utiliser les valeurs par défaut *}}
{{#foreach from=$entrees_defaut key="label" item="value"}} {{#foreach from=$entrees_defaut key="label" item="value"}}
{{* Vérifier si la suppression de ce type d'entrée est possible *}}
{{:assign suppr=true}}
{{#load type="movement" where="$$.inputNature = :libelle" :libelle=$label}}
{{:assign suppr=false}}
{{/load}}
<tr> <tr>
<td>{{:input type="text" name="input_fields[label][]" default=$label}}</td> <td>{{:input type="text" name="input_fields[label][]" default=$label}}</td>
<td>{{:input type="select" name="input_fields[type][]" options=$types_entrees required=true default=$value default_empty="— Choisir un type —"}}</td> <td>{{:input type="select" name="input_fields[type][]" options=$types_entrees required=true default=$value default_empty="— Choisir un type —"}}</td>
<td class="action"> <td class="action">
{{:button label="Retirer" shape="minus" onclick="this.parentNode.parentNode.remove();"}} {{if $suppr}}
{{:button label="Supprimer" shape="minus" onclick="this.parentNode.parentNode.remove();"}}
{{else}}
{{:button label="Supprimer" shape="minus" disabled=true}}
{{/if}}
</td> </td>
</tr> </tr>
{{/foreach}} {{/foreach}}
@ -95,20 +118,43 @@
</thead> </thead>
<tbody id="output_body"> <tbody id="output_body">
{{#foreach from=$module.config.outputNature item="output_field"}} {{#foreach from=$module.config.outputNature item="output_field"}}
{{* Vérifier si la suppression de ce type de sortie est possible *}}
{{:assign suppr=true}}
{{#load type="movement" where="$$.outputNature = :libelle" :libelle=$output_field.label}}
{{:assign suppr=false}}
{{/load}}
<tr> <tr>
<td>{{:input type="text" name="output_fields[label][]" default=$output_field.label}}</td> <td>{{:input type="text" name="output_fields[label][]" default=$output_field.label}}</td>
<td>{{:input type="select" name="output_fields[type][]" options=$types_sorties default=$output_field.type required=true default_empty="— Choisir un type —"}}</td> <td>{{:input type="select" name="output_fields[type][]" options=$types_sorties default=$output_field.type required=true default_empty="— Choisir un type —"}}</td>
<td class="action"> <td class="action">
{{:button label="Retirer" shape="minus" onclick="this.parentNode.parentNode.remove();"}} {{if $suppr}}
{{:button label="Supprimer" shape="minus" onclick="this.parentNode.parentNode.remove();"}}
{{else}}
{{:button label="Supprimer" shape="minus" disabled=true}}
{{/if}}
</td> </td>
</tr> </tr>
{{else}} {{else}}
{{* pas de config enregistrée : utiliser les valeurs par défaut *}}
{{#foreach from=$sorties_defaut key="label" item="value"}} {{#foreach from=$sorties_defaut key="label" item="value"}}
{{* Vérifier si la suppression de ce type de sortie est possible *}}
{{:assign suppr=true}}
{{#load type="movement" where="$$.inputNature = :libelle" :libelle=$label}}
{{:assign suppr=false}}
{{/load}}
<tr> <tr>
<td>{{:input type="text" name="output_fields[label][]" default=$label}}</td> <td>{{:input type="text" name="output_fields[label][]" default=$label}}</td>
<td>{{:input type="select" name="output_fields[type][]" options=$types_sorties required=true default=$value default_empty="— Choisir un type —"}}</td> <td>{{:input type="select" name="output_fields[type][]" options=$types_sorties required=true default=$value default_empty="— Choisir un type —"}}</td>
<td class="action"> <td class="action">
{{:button label="Retirer" shape="minus" onclick="this.parentNode.parentNode.remove();"}} {{if $suppr}}
{{:button label="Supprimer" shape="minus" onclick="this.parentNode.parentNode.remove();"}}
{{else}}
{{:button label="Supprimer" shape="minus" disabled=true}}
{{/if}}
</td> </td>
</tr> </tr>
{{/foreach}} {{/foreach}}