From: Galen Charlton <gmc@equinoxinitiative.org> Date: Tue, 11 Jun 2019 23:08:51 +0000 (-0400) Subject: LP#1832897: improvements to the Angular admin-page component X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=4739faf12e0fd9c11278e2839de1181c8facf10a;p=contrib%2FConifer.git LP#1832897: improvements to the Angular admin-page component * 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> --- 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 bb39f8bbdd..c7479d62db 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 @@ -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> 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 11913c8991..b853a6aef5 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 @@ -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() ); }