diff --git a/config.html b/config.html index 7052d47..b5d5411 100644 --- a/config.html +++ b/config.html @@ -34,15 +34,15 @@ - {{#foreach from=$config.input_nature}} + {{#foreach from=$config.input_nature key=key}} {{$label}} {{$type}} {{if ! $locked_inputs|has:$label}} - {{:linkbutton label="Supprimer" shape="delete" href="config/supprimer_type_mouvement.html?dir=input&mvt=%s"|args:$label target="_dialog"}} + {{:linkbutton label="Supprimer" shape="delete" href="config/supprimer_type_mouvement.html?dir=input&op_key=%s"|args:$key target="_dialog"}} {{/if}} - {{:linkbutton label="Modifier" shape="edit" href="config/modifier_type_mouvement.html?dir=input&mvt=%s"|args:$label target="_dialog"}} + {{:linkbutton label="Modifier" shape="edit" href="config/modifier_type_mouvement.html?dir=input&op_key=%s"|args:$key target="_dialog"}} {{/foreach}} @@ -59,15 +59,15 @@ - {{#foreach from=$config.output_nature}} + {{#foreach from=$config.output_nature key=key}} {{$label}} {{$type}} {{if ! $locked_outputs|has:$label}} - {{:linkbutton label="Supprimer" shape="delete" href="config/supprimer_type_mouvement.html?dir=output&mvt=%s"|args:$label target="_dialog"}} + {{:linkbutton label="Supprimer" shape="delete" href="config/supprimer_type_mouvement.html?dir=output&op_key=%s"|args:$key target="_dialog"}} {{/if}} - {{:linkbutton label="Modifier" shape="edit" href="config/modifier_type_mouvement.html?dir=output&mvt=%s"|args:$label target="_dialog"}} + {{:linkbutton label="Modifier" shape="edit" href="config/modifier_type_mouvement.html?dir=output&op_key=%s"|args:$key target="_dialog"}} {{/foreach}} diff --git a/config/modifier_type_mouvement.html b/config/modifier_type_mouvement.html index 40749ee..b83032d 100644 --- a/config/modifier_type_mouvement.html +++ b/config/modifier_type_mouvement.html @@ -3,7 +3,7 @@ {{* paramètres : - dir : input ou output - - mvt : libellé du type de mouvement à modifier + - op_key : clé du type de mouvement dont on veut modifier le libellé *}} {{* barre de navigation *}} @@ -14,32 +14,38 @@ {{* lecture config (défaut ou enregistrée) *}} {{:include file="../_get_config.html" keep="config"}} -{{*:debug config.input_nature=$config.input_nature config.input_nature=$config.input_nature*}} -{{*:debug mvt=$_GET.mvt*}} {{#form on="save"}} - {{#foreach from=$config.input_nature key="label" item="type"}} - {{:debug key=$label item=$type}} - {{if $_GET.dir == 'input' - && $label|trim|tolower == $_GET.mvt|trim|tolower}} - {{:assign var="input_nature.label" value=$_POST.name|trim|tolower|ucfirst}} - {{else} + {{:assign input_nature=null}} + {{#foreach from=$config.input_nature key=key}} + {{:assign var="input_nature.key" value=$key}} + {{if $_GET.dir == 'input'}} + {{if $key == $_GET.op_key}} + {{:assign var="input_nature.label" value=$_POST.name|trim|tolower|ucfirst}} + {{else}} + {{:assign var="input_nature.label" value=$label}} + {{/if}} + {{else}} {{:assign var="input_nature.label" value=$label}} {{/if}} {{:assign var="input_nature.type" value=$type}} {{:assign var="input_natures." from=input_nature}} {{/foreach}} - {{#foreach from=$config.output_nature key="label" item="type"}} - {{if $_GET.dir == 'output' && $label|trim|tolower == $_GET.mvt|trim|tolower}} - {{:assign var="output_nature.label" value=$_POST.name|trim|tolower|ucfirst}} + {{#foreach from=$config.output_nature key=key}} + {{:assign var="output_nature.key" value=$key}} + {{if $_GET.dir == 'output'}} + {{if $key == $_GET.op_key}} + {{:assign var="output_nature.label" value=$_POST.name|trim|tolower|ucfirst}} + {{else}} + {{:assign var="output_nature.label" value=$label}} + {{/if}} {{else}} {{:assign var="output_nature.label" value=$label}} {{/if}} {{:assign var="output_nature.type" value=$type}} {{:assign var="output_natures." from=output_nature}} {{/foreach}} -{{:debug input_natures=$input_natures output_natures=$output_natures}} -{{* + {{:save key="config" validate_schema="../config.schema.json" @@ -47,17 +53,16 @@ output_nature=$output_natures }} {{:redirect to="./config.html?ok=1"}} -*}} {{/form}} {{:admin_header title="Gestion des matériels" current="module_equipment"}} {{:form_errors}} - +{{:assign var="default_label" from="config.%s_nature.%s.label"|args:$_GET.dir:$_GET.op_key}}
Modifier le libellé
- {{:input type="text" name="name" label="Libellé" default=$_GET.mvt required=true maxlength="100"}} + {{:input type="text" name="name" label="Libellé" default=$default_label required=true maxlength="100"}}

{{:button type="submit" name="save" label="Enregistrer" shape="right" class="main"}} diff --git a/config/supprimer_type_mouvement.html b/config/supprimer_type_mouvement.html index 0f55947..ce46f28 100644 --- a/config/supprimer_type_mouvement.html +++ b/config/supprimer_type_mouvement.html @@ -3,7 +3,7 @@ {{* paramètres : - dir : input ou output - - mvt : libellé du type de mouvement à supprimer + - op_key : clé du type de mouvement à supprimer *}} {{* barre de navigation *}} @@ -16,24 +16,20 @@ {{#form on="delete"}} {{#foreach from=$config.input_nature key=key}} - {{if $_GET.dir == 'input' && $label|trim|tolower != $_GET.mvt|trim|tolower || - $_GET.dir == 'output' - }} - {{:assign var="input_nature.key" value=$key}} - {{:assign var="input_nature.label" value=$label}} - {{:assign var="input_nature.type" value=$type}} - {{:assign var="input_natures." from=input_nature}} + {{if $_GET.dir == 'input' && $key != $_GET.op_key || $_GET.dir == 'output'}} + {{:assign var="input_nature.key" value=$key}} + {{:assign var="input_nature.label" value=$label}} + {{:assign var="input_nature.type" value=$type}} + {{:assign var="input_natures." from=input_nature}} {{/if}} {{/foreach}} {{#foreach from=$config.output_nature key=key}} - {{if $_GET.dir == 'output' && $label|trim|tolower != $_GET.mvt|trim|tolower || - $_GET.dir == 'input' - }} - {{:assign var="output_nature.key" value=$key}} - {{:assign var="output_nature.label" value=$label}} - {{:assign var="output_nature.type" value=$type}} - {{:assign var="output_natures." from=output_nature}} + {{if $_GET.dir == 'output' && $key != $_GET.op_key || $_GET.dir == 'input'}} + {{:assign var="output_nature.key" value=$key}} + {{:assign var="output_nature.label" value=$label}} + {{:assign var="output_nature.type" value=$type}} + {{:assign var="output_natures." from=output_nature}} {{/if}} {{/foreach}}