LP#1832897: improvements to the Angular admin-page component
authorGalen Charlton <gmc@equinoxinitiative.org>
Tue, 11 Jun 2019 23:08:51 +0000 (19:08 -0400)
committerJane Sandberg <sandbej@linnbenton.edu>
Wed, 4 Sep 2019 02:31:13 +0000 (19:31 -0700)
* Make some of its services public so that it can be more easily
  subclassed.
* Show toast on success or failure of record deletion actions.

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <sandbej@linnbenton.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 bb39f8b..c7479d6 100644 (file)
@@ -4,6 +4,11 @@
 <ng-template #updateFailedStrTmpl i18n>Update of {{idlClassDef.label}} failed</ng-template>
 <eg-string #updateFailedString [template]="updateFailedStrTmpl"></eg-string>
 
+<ng-template #deleteFailedStrTmpl i18n>Delete of {{idlClassDef.label}} failed or was not allowed</ng-template>
+<eg-string #deleteFailedString [template]="deleteFailedStrTmpl"></eg-string>
+
+<ng-template #deleteSuccessStrTmpl i18n>{{idlClassDef.label}} Successfully Deleted</ng-template>
+<eg-string #deleteSuccessString [template]="deleteSuccessStrTmpl"></eg-string>
 
 <ng-template #createStrTmpl i18n>{{idlClassDef.label}} Succeessfully Created</ng-template>
 <eg-string #createString [template]="createStrTmpl"></eg-string>
index 11913c8..b853a6a 100644 (file)
@@ -81,6 +81,8 @@ export class AdminPageComponent implements OnInit {
     @ViewChild('createString') createString: StringComponent;
     @ViewChild('createErrString') createErrString: StringComponent;
     @ViewChild('updateFailedString') updateFailedString: StringComponent;
+    @ViewChild('deleteFailedString') deleteFailedString: StringComponent;
+    @ViewChild('deleteSuccessString') deleteSuccessString: StringComponent;
     @ViewChild('translator') translator: TranslateComponent;
 
     idlClassDef: any;
@@ -103,12 +105,12 @@ export class AdminPageComponent implements OnInit {
 
     constructor(
         private route: ActivatedRoute,
-        private idl: IdlService,
+        public idl: IdlService,
         private org: OrgService,
-        private auth: AuthService,
-        private pcrud: PcrudService,
+        public auth: AuthService,
+        public pcrud: PcrudService,
         private perm: PermService,
-        private toast: ToastService
+        public toast: ToastService
     ) {
         this.translatableFields = [];
     }
@@ -278,8 +280,15 @@ export class AdminPageComponent implements OnInit {
     deleteSelected(idlThings: IdlObject[]) {
         idlThings.forEach(idlThing => idlThing.isdeleted(true));
         this.pcrud.autoApply(idlThings).subscribe(
-            val => console.debug('deleted: ' + val),
-            err => {},
+            val => {
+                console.debug('deleted: ' + val);
+                this.deleteSuccessString.current()
+                    .then(str => this.toast.success(str));
+            },
+            err => {
+                this.deleteFailedString.current()
+                    .then(str => this.toast.danger(str));
+            },
             ()  => this.grid.reload()
         );
     }