LP#1945385: use eg-admin-page for circ limit sets admin UI
authorJeff Davis <jdavis@sitka.bclibraries.ca>
Thu, 19 May 2022 23:32:38 +0000 (16:32 -0700)
committerJason Stephenson <jason@sigio.com>
Tue, 28 Jun 2022 20:33:39 +0000 (16:33 -0400)
Signed-off-by: Jeff Davis <jdavis@sitka.bclibraries.ca>
Signed-off-by: Jennifer Pringle <jennifer.pringle@bc.libraries.coop>
Signed-off-by: Jason Stephenson <jason@sigio.com>
Open-ILS/src/eg2/src/app/staff/admin/local/circ_limit_set/circ_limit_set.component.html
Open-ILS/src/eg2/src/app/staff/admin/local/circ_limit_set/circ_limit_set.component.ts
Open-ILS/src/eg2/src/app/staff/admin/local/circ_limit_set/circ_limit_set.module.ts
Open-ILS/src/eg2/src/app/staff/admin/local/circ_limit_set/circ_limit_set_edit.component.ts

index 58340e7..44fc39b 100644 (file)
@@ -1,26 +1,14 @@
 <eg-staff-banner bannerText="Circulation Limit Set Administration" i18n-bannerText>
   </eg-staff-banner>
 
-<eg-string #createFailedString i18n-text text="Created Circulation Limit 
-  Set"></eg-string>
-<eg-string #createSuccessString i18n-text text="Failed to Create Circulation 
-  Limit Set"></eg-string>
-<eg-string #deleteFailedString i18n-text text="Delete of Circulation Limit Set 
-  failed or was not allowed"></eg-string>
-<eg-string #deleteSuccessString i18n-text text="Delete of Circulation Limit Set
-  succeeded"></eg-string>
-<eg-string #updateSuccessString i18n-text text="Circulation Limit Set Update 
-  Succeeded"></eg-string>
-<eg-string #updateFailedString i18n-text text="Circulation Limit Set 
-  Update Failed"></eg-string>
+<eg-admin-page idlClass="ccls" [templateFields]="[{name: 'Linked Entities', template: cclsLinkedEntitiesTmpl}]"></eg-admin-page>
 
-<eg-grid #grid idlClass="ccls" [dataSource]="gridDataSource" hideFields="id">
-  <eg-grid-toolbar-button label="New Circulation Limit Set" i18n-label 
-    (onClick)="createNew()"></eg-grid-toolbar-button>
-  <eg-grid-toolbar-action label="Edit Selected" i18n-label 
-    (onClick)="editSelected($event)"></eg-grid-toolbar-action>
-  <eg-grid-toolbar-action label="Delete Selected" i18n-label 
-    (onClick)="deleteSelected($event)"></eg-grid-toolbar-action>
-</eg-grid>
+<ng-template #cclsLinkedEntitiesTmpl let-row="row">
+  <div>
+    <a routerLink="/staff/admin/local/config/circ_limit_set/{{row.id()}}">
+      Manage
+    </a>
+  </div>
+</ng-template>
 
 <eg-fm-record-editor #editDialog hiddenFields="id" idlClass="ccls"></eg-fm-record-editor>
index f38a9df..ce28023 100644 (file)
@@ -1,123 +1,7 @@
-import {Pager} from '@eg/share/util/pager';
-import {Component, OnInit, Input, ViewChild} from '@angular/core';
-import {GridComponent} from '@eg/share/grid/grid.component';
-import {GridDataSource} from '@eg/share/grid/grid';
-import {Router} from '@angular/router';
-import {IdlObject} from '@eg/core/idl.service';
-import {PcrudService} from '@eg/core/pcrud.service';
-import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component';
-import {StringComponent} from '@eg/share/string/string.component';
-import {ToastService} from '@eg/share/toast/toast.service';
+import {Component} from '@angular/core';
 
 @Component({
     templateUrl: './circ_limit_set.component.html'
 })
 
-export class CircLimitSetComponent implements OnInit {
-
-    recId: number;
-    gridDataSource: GridDataSource;
-    initDone = false;
-    cspSource: GridDataSource = new GridDataSource();
-
-    @ViewChild('editDialog', {static: true}) editDialog: FmRecordEditorComponent;
-    @ViewChild('grid', {static: true}) grid: GridComponent;
-    @ViewChild('updateSuccessString', {static: true}) updateSuccessString: StringComponent;
-    @ViewChild('updateFailedString', {static: true}) updateFailedString: StringComponent;
-    @ViewChild('deleteFailedString', {static: true}) deleteFailedString: StringComponent;
-    @ViewChild('deleteSuccessString', {static: true}) deleteSuccessString: StringComponent;
-    @ViewChild('createSuccessString', {static: true}) createSuccessString: StringComponent;
-    @ViewChild('createErrString', {static: true}) createErrString: StringComponent;
-
-    @Input() dialogSize: 'sm' | 'lg' = 'lg';
-
-    constructor(
-        private pcrud: PcrudService,
-        private toast: ToastService,
-        private router: Router
-    ) {
-        this.gridDataSource = new GridDataSource();
-    }
-
-    ngOnInit() {
-        this.gridDataSource.getRows = (pager: Pager, sort: any[]) => {
-            const orderBy: any = {};
-            const searchOps = {
-                offset: pager.offset,
-                limit: pager.limit,
-                order_by: orderBy
-            };
-            return this.pcrud.retrieveAll('ccls', searchOps, {fleshSelectors: true});
-        };
-
-        this.grid.onRowActivate.subscribe(
-            (set: IdlObject) => {
-                const idToEdit = set.id();
-                this.navigateToEditPage(idToEdit);
-            }
-        );
-    }
-
-    deleteSelected = (idlThings: IdlObject[]) => {
-        idlThings.forEach(idlThing => idlThing.isdeleted(true));
-        this.pcrud.autoApply(idlThings).subscribe(
-            val => {
-                this.deleteSuccessString.current()
-                    .then(str => this.toast.success(str));
-            },
-            err => {
-                this.deleteFailedString.current()
-                    .then(str => this.toast.danger(str));
-            },
-            ()  => this.grid.reload()
-        );
-    }
-
-    editSelected(sets: IdlObject[]) {
-        const idToEdit = sets[0].id();
-        this.navigateToEditPage(idToEdit);
-    }
-
-    navigateToEditPage(id: any) {
-        this.router.navigate(['/staff/admin/local/config/circ_limit_set/' + id]);
-    }
-
-    createNew() {
-        this.editDialog.mode = 'create';
-        this.editDialog.recordId = null;
-        this.editDialog.record = null;
-        this.editDialog.open({size: this.dialogSize}).subscribe(
-            ok => {
-                this.createSuccessString.current()
-                    .then(str => this.toast.success(str));
-                this.grid.reload();
-            },
-            rejection => {
-                if (!rejection.dismissed) {
-                    this.createErrString.current()
-                        .then(str => this.toast.danger(str));
-                }
-            }
-        );
-    }
-
-    showEditDialog(standingPenalty: IdlObject): Promise<any> {
-        this.editDialog.mode = 'update';
-        this.editDialog.recordId = standingPenalty['id']();
-        return new Promise((resolve, reject) => {
-            this.editDialog.open({size: this.dialogSize}).subscribe(
-                result => {
-                    this.updateSuccessString.current()
-                        .then(str => this.toast.success(str));
-                    this.grid.reload();
-                    resolve(result);
-                },
-                error => {
-                    this.updateFailedString.current()
-                        .then(str => this.toast.danger(str));
-                    reject(error);
-                }
-            );
-        });
-    }
-}
+export class CircLimitSetComponent { }
index e7cf75a..8149691 100644 (file)
@@ -4,6 +4,7 @@ import {CircLimitSetComponent} from './circ_limit_set.component';
 import {CircLimitSetEditComponent} from './circ_limit_set_edit.component';
 import {CircLimitSetRoutingModule} from './circ_limit_set_routing.module';
 import {ItemLocationSelectModule} from '@eg/share/item-location-select/item-location-select.module';
+import {AdminPageModule} from '@eg/staff/share/admin-page/admin-page.module';
 
 @NgModule({
   declarations: [
@@ -12,6 +13,7 @@ import {ItemLocationSelectModule} from '@eg/share/item-location-select/item-loca
   ],
   imports: [
     AdminCommonModule,
+    AdminPageModule,
     CircLimitSetRoutingModule,
     ItemLocationSelectModule,
   ],
index a8dd48e..be81a1c 100644 (file)
@@ -25,7 +25,7 @@ export class CircLimitSetEditComponent  implements OnInit {
     selectedLimitGroup: any;
     locId = 0;
 
-    circTab: 'limitSet' | 'linked' = 'limitSet';
+    circTab: 'limitSet' | 'linked' = 'linked';
 
     @ViewChild('addingSuccess', {static: true}) addingSuccess: StringComponent;
     @ViewChild('removingSuccess', {static: true}) removingSuccess: StringComponent;