diff --git a/src/app/formulaire/elements/fieldset.ts b/src/app/formulaire/elements/fieldset.ts index cf23d79c99dd52911b9d7e1e31ce7de338b45ead..e5a9ca15af20c8281d7652b8c609727f324f4653 100644 --- a/src/app/formulaire/elements/fieldset.ts +++ b/src/app/formulaire/elements/fieldset.ts @@ -400,9 +400,6 @@ export class FieldSet extends FormulaireElement implements Observer { } } else { if (this.parentForm instanceof FormulaireFixedVar) { - // backup parameters - const oldParams = this.backupParameters(); - // for all select fields known by the form, apply received value // to associated property const selectIds = this.parentForm.selectids; @@ -421,11 +418,13 @@ export class FieldSet extends FormulaireElement implements Observer { } } } - - // restore parameters - this.restoreParameters(oldParams, FormulaireNode.NeverEmptyFields); } } + + if (ServiceFactory.applicationSetupService.enableEmptyFieldsOnFormInit) { + const f = this.parentForm; + f.emptyFields(); + } break; // switch (data.action) } } diff --git a/src/app/formulaire/elements/formulaire-node.ts b/src/app/formulaire/elements/formulaire-node.ts index 4ce0648832d4762ffbc4e65f9aab9ef013e2197b..0ab8a88dfd64f0fd0ec52037fea428d3d701506c 100644 --- a/src/app/formulaire/elements/formulaire-node.ts +++ b/src/app/formulaire/elements/formulaire-node.ts @@ -156,7 +156,7 @@ export abstract class FormulaireNode implements IObservable { if (p instanceof NgParameter) { if ( [ParamValueMode.SINGLE, ParamValueMode.CALCUL].includes(p.valueMode) - && !except.includes(p.id) + && !except.includes(p.id) && !p.isValueModified ) { if (p.valueMode === ParamValueMode.CALCUL) { calcP = p; diff --git a/src/app/services/formulaire.service.ts b/src/app/services/formulaire.service.ts index 5d3910bbfc888c573f59c31074b96fc5279095a9..1bfdbe14fe9daced78b2821402b48ab549c00223 100644 --- a/src/app/services/formulaire.service.ts +++ b/src/app/services/formulaire.service.ts @@ -50,6 +50,7 @@ import { FormulairePAR } from "../formulaire/definition/form-par"; import { FormulaireVerificateur } from "../formulaire/definition/form-verificateur"; import { FormulaireEspece } from "../formulaire/definition/form-espece"; import { FormulairePrebarrage } from "../formulaire/definition/form-prebarrage"; +import { ServiceFactory } from "./service-factory"; @Injectable() export class FormulaireService extends Observable { @@ -628,6 +629,10 @@ export class FormulaireService extends Observable { */ public async loadSession(f: File, formInfos: any[] = []): Promise<{ hasErrors: boolean, loaded: string[] }> { try { + // disable "empty fields" flag temporarly + const emptyFields = ServiceFactory.applicationSetupService.enableEmptyFieldsOnFormInit; + ServiceFactory.applicationSetupService.enableEmptyFieldsOnFormInit = false; + const s = await this.readSingleFile(f); const uids: string[] = []; formInfos.forEach((fi) => { @@ -646,6 +651,10 @@ export class FormulaireService extends Observable { } await this.createFormulaire(nn.nub.calcType, nn.nub, title); // await guarantees loading order } + + // restore "empty fields" flag + ServiceFactory.applicationSetupService.enableEmptyFieldsOnFormInit = emptyFields; + // apply settings if (res.settings) { // model based settings