LP#1807458 Angular admin grid Edit Selected option
authorBill Erickson <berickxx@gmail.com>
Mon, 10 Dec 2018 18:09:36 +0000 (13:09 -0500)
committerDan Wells <dbw2@calvin.edu>
Fri, 22 Mar 2019 19:42:01 +0000 (15:42 -0400)
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 <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
Signed-off-by: Dan Wells <dbw2@calvin.edu>

Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.html
Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.ts

index 0fc5c44..8cf5070 100644 (file)
@@ -49,6 +49,8 @@
   <eg-grid-toolbar-button [disabled]="translatableFields.length == 0" 
     label="Apply Translations" i18n-label [action]="translate">
   </eg-grid-toolbar-button>
+  <eg-grid-toolbar-action label="Edit Selected" i18n-label [action]="editSelected">
+  </eg-grid-toolbar-action>
   <eg-grid-toolbar-action label="Delete Selected" i18n-label [action]="deleteSelected">
   </eg-grid-toolbar-action>
 </eg-grid>
index 80fd2fd..03ba326 100644 (file)
@@ -75,6 +75,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;
@@ -153,20 +154,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(
@@ -309,6 +311,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 => {}
+        );
+    }
+
 }