Skip to content
Snippets Groups Projects
Commit 7a6483ca authored by François Grand's avatar François Grand
Browse files

feat: restore parameter value mode in case of cancel in variable values modification dialog

refs #508
parent f61e3d35
No related branches found
No related tags found
2 merge requests!133Release version 4.15.0,!121Resolve "Remettre le paramètre dans son état initial quand le dialogue "Varier" est annulé"
......@@ -121,7 +121,7 @@
<div mat-dialog-actions [attr.align]="'end'">
<div>
<button id="btn-cancel" mat-raised-button color="primary" [mat-dialog-close]="true" cdkFocusInitial>
<button id="btn-cancel" mat-raised-button color="primary" (click)="onCancel()" cdkFocusInitial>
{{ uitextCancel }}
</button>
<button mat-raised-button color="warn" (click)="onValidate()" [disabled]=" !isFormValid">
......
......@@ -282,6 +282,12 @@ export class DialogEditParamValuesComponent implements OnInit {
return ret;
}
public onCancel() {
this.dialogRef.close({
cancelled: true
});
}
public onValidate() {
switch (this.param.valueMode) {
case ParamValueMode.LISTE:
......@@ -294,7 +300,9 @@ export class DialogEditParamValuesComponent implements OnInit {
this.data.param.setStepValue(this, this.param.stepValue);
break;
}
this.dialogRef.close();
this.dialogRef.close({
cancelled: false
});
}
/**
......
......@@ -119,6 +119,12 @@ export class ParamFieldLineComponent implements OnChanges {
private _formService: FormulaireService;
/**
* valeur du mode de paramètre avant clic sur un des radios, utilisé pour restaurer le mode en cas de cancel
* du dialogue de modification des valeurs en mode variable
*/
private oldValueMode: ParamValueMode;
/*
* gestion des événements clic sur les radios :
* envoi d'un message au composant parent
......@@ -236,7 +242,7 @@ export class ParamFieldLineComponent implements OnChanges {
}
public onRadioClick(option: string) {
const oldValue = this.param.valueMode;
this.oldValueMode = this.param.valueMode;
switch (option) {
case "fix":
this.param.valueMode = ParamValueMode.SINGLE;
......@@ -245,7 +251,7 @@ export class ParamFieldLineComponent implements OnChanges {
case "var":
// prevent setting LISTE mode back to MINMAX if someone clicks "variable" again
// after setting variable mode to LISTE
if (oldValue !== ParamValueMode.MINMAX && oldValue !== ParamValueMode.LISTE) {
if (this.oldValueMode !== ParamValueMode.MINMAX && this.oldValueMode !== ParamValueMode.LISTE) {
this.param.valueMode = ParamValueMode.MINMAX; // min/max par défaut
}
if (this._paramValuesComponent) {
......@@ -273,7 +279,7 @@ export class ParamFieldLineComponent implements OnChanges {
}
this.radio.emit({
"param": this.param,
"oldValueMode": oldValue
"oldValueMode": this.oldValueMode
});
// MAJ validité
this.emitValidity();
......@@ -306,6 +312,10 @@ export class ParamFieldLineComponent implements OnChanges {
case "model":
this.inputChange.emit(event);
break;
case "cancelvar": // cancel button clicked in DialogEditParamValuesComponent
this.param.valueMode = this.oldValueMode;
break;
}
}
......
......@@ -55,7 +55,7 @@ export class ParamValuesComponent implements AfterViewInit, Observer {
public openDialog() {
// modification des valeurs variables
this.editValuesDialog.open(
const dlgRef = this.editValuesDialog.open(
DialogEditParamValuesComponent,
{
disableClose: true,
......@@ -66,6 +66,12 @@ export class ParamValuesComponent implements AfterViewInit, Observer {
panelClass: "dialogMinWidth320px"
}
);
dlgRef.afterClosed().toPromise().then(result => {
if (result.cancelled)
this.change.emit({
action: "cancelvar"
});
});
}
public ngAfterViewInit() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment