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)
committerGalen Charlton <gmc@equinoxinitiative.org>
Wed, 7 Aug 2019 17:56:52 +0000 (17:56 +0000)
* 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>
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 a69dabd..28e25e8 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 f920d7b..503bb07 100644 (file)
@@ -77,6 +77,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;
@@ -99,12 +101,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 = [];
     }
@@ -274,8 +276,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()
         );
     }