From 47ded1c9cc60052f6f09510dd6ded8007491c502 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 10 Dec 2018 13:09:36 -0500 Subject: [PATCH] LP#1807458 Angular admin grid Edit Selected option Adds a new "Edit Selected" action to the "Actions for Selected Items" menu in the general purpose admin grid. This only visibly affects the ACQ admin grids at time of writing, but applies to all auto-generated admin grids. Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg --- .../share/admin-page/admin-page.component.html | 2 ++ .../staff/share/admin-page/admin-page.component.ts | 39 +++++++++++++++------- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.html b/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.html index 194f06b515..ee9a175976 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.html +++ b/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.html @@ -49,6 +49,8 @@ + + diff --git a/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.ts b/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.ts index be4452b1b3..6e865f1702 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.ts @@ -72,6 +72,7 @@ export class AdminPageComponent implements OnInit { pkeyField: string; createNew: () => void; deleteSelected: (rows: IdlObject[]) => void; + editSelected: (rows: IdlObject[]) => void; // True if any columns on the object support translations translateRowIdx: number; @@ -150,20 +151,21 @@ export class AdminPageComponent implements OnInit { // TODO: pass the row activate handler via the grid markup this.grid.onRowActivate.subscribe( - (idlThing: IdlObject) => { - this.editDialog.mode = 'update'; - this.editDialog.recId = idlThing[this.pkeyField](); - this.editDialog.open({size: this.dialogSize}).then( - ok => { - this.successString.current() - .then(str => this.toast.success(str)); - this.grid.reload(); - }, - err => {} - ); - } + (idlThing: IdlObject) => this.showEditDialog(idlThing) ); + this.editSelected = (idlThings: IdlObject[]) => { + + // Edit each IDL thing one at a time + const editOneThing = (thing: IdlObject) => { + if (!thing) return; + + this.showEditDialog(thing).then( + () => editOneThing(idlThings.shift())); + } + + editOneThing(idlThings.shift()); }; + this.createNew = () => { this.editDialog.mode = 'create'; this.editDialog.open({size: this.dialogSize}).then( @@ -306,6 +308,19 @@ export class AdminPageComponent implements OnInit { return this.contextOrg && this.contextOrg.children().length === 0; } + showEditDialog(idlThing: IdlObject) { + this.editDialog.mode = 'update'; + this.editDialog.recId = idlThing[this.pkeyField](); + return this.editDialog.open({size: this.dialogSize}).then( + ok => { + this.successString.current() + .then(str => this.toast.success(str)); + this.grid.reload(); + }, + err => {} + ); + } + } -- 2.11.0