From 8bc86d80895c833ee1817bd82e1f6b96c879bf5d Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Wed, 12 Jun 2019 17:47:12 +0200 Subject: [PATCH] =?UTF-8?q?PAB=20:=20clonage=20d'=C3=A9l=C3=A9ments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dialog-edit-pab.component.html | 2 +- .../dialog-edit-pab.component.ts | 4 +- .../pab-table/pab-table.component.ts | 55 ++++++++++++++++++- 3 files changed, 57 insertions(+), 4 deletions(-) diff --git a/src/app/components/dialog-edit-pab/dialog-edit-pab.component.html b/src/app/components/dialog-edit-pab/dialog-edit-pab.component.html index e96cc7807..8674eb361 100644 --- a/src/app/components/dialog-edit-pab/dialog-edit-pab.component.html +++ b/src/app/components/dialog-edit-pab/dialog-edit-pab.component.html @@ -67,7 +67,7 @@ <button mat-raised-button type="submit" color="warn" (click)="applyValues()" [disabled]="buttonDisabled(valueToSetRef, deltaRef)"> - {{ uitextSave }} + {{ uitextValidate }} </button> </div> diff --git a/src/app/components/dialog-edit-pab/dialog-edit-pab.component.ts b/src/app/components/dialog-edit-pab/dialog-edit-pab.component.ts index 0be09d40f..ba3986a12 100644 --- a/src/app/components/dialog-edit-pab/dialog-edit-pab.component.ts +++ b/src/app/components/dialog-edit-pab/dialog-edit-pab.component.ts @@ -183,8 +183,8 @@ export class DialogEditPabComponent { return this.intlService.localizeText("ERROR_PARAM_MUST_BE_A_NUMBER"); } - public get uitextSave() { - return this.intlService.localizeText("INFO_OPTION_SAVE"); + public get uitextValidate() { + return this.intlService.localizeText("INFO_OPTION_VALIDATE"); } public get uitextCancel() { diff --git a/src/app/components/pab-table/pab-table.component.ts b/src/app/components/pab-table/pab-table.component.ts index 48d108657..104699b8a 100644 --- a/src/app/components/pab-table/pab-table.component.ts +++ b/src/app/components/pab-table/pab-table.component.ts @@ -780,10 +780,63 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit { console.log("Add !!!"); /* const newChild = undefined; this.selectedItem.parent.addChild(newChild, this.selectedItem.findPositionInParent()); */ + /* for (let i = 0; i < this.childrenToAdd; i++) { + this.selectedItem.parent.addChild() + } */ + /* let msg: string; + if (this.childrenToAdd === 1) { + msg = this.i18nService.localizeText("INFO_FSC_FS_ADDED"); + } else { + msg = sprintf(this.i18nService.localizeText("INFO_FSC_FS_ADDED_N_TIMES"), this.childrenToAdd); + } + this.notifService.notify(msg); */ + this.childrenToAdd = 1; // reinit to avoid confusion } public onCopyClick() { - console.log("Copy !!!"); + for (let i = 0; i < this.childrenToAdd; i++) { + const newChild = Session.getInstance().createNub( + this.selectedItem.properties.clone(), + this.selectedItem.parent + ); + // copy parameter values + for (const p of this.selectedItem.prms) { + newChild.getParameter(p.symbol).singleValue = p.singleValue; + } + // copy children + if (this.selectedItem instanceof ParallelStructure) { + for (const c of this.selectedItem.getChildren()) { + const newGrandChild = Session.getInstance().createNub( + c.properties.clone(), + newChild + ); + // copy children parameters values + for (const p of c.prms) { + newGrandChild.getParameter(p.symbol).singleValue = p.singleValue; + } + // add to parent + newChild.addChild( + newGrandChild, + c.findPositionInParent() + ); + } + } + // add to parent + this.selectedItem.parent.addChild( + newChild, + this.selectedItem.findPositionInParent() + ); + } + this.refresh(); + /* const pos = (this._fieldSet.parent as FieldsetContainer).getFieldsetPosition(this._fieldSet) + 1; + let msg: string; + if (this.childrenToAdd === 1) { + msg = sprintf(this.i18nService.localizeText("INFO_FSC_FS_COPIED"), pos); + } else { + msg = sprintf(this.i18nService.localizeText("INFO_FSC_FS_COPIED_N_TIMES"), pos, this.childrenToAdd); + } + this.notifService.notify(msg); */ + this.childrenToAdd = 1; // reinit to avoid confusion } public onMoveUpClick() { -- GitLab