LP#1775466 Admin grid persist key options
authorBill Erickson <berickxx@gmail.com>
Mon, 6 Aug 2018 14:33:40 +0000 (10:33 -0400)
committerBill Erickson <berickxx@gmail.com>
Mon, 6 Aug 2018 14:33:40 +0000 (10:33 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/admin/basic-admin-page.component.ts
Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.ts

index aa24cc7..ccbc847 100644 (file)
@@ -10,13 +10,15 @@ import {IdlService} from '@eg/core/idl.service';
     template: `
       <eg-staff-banner bannerText="{{classLabel}} Configuration" i18n-bannerText>
       </eg-staff-banner>
-      <eg-admin-page idlClass="{{idlClass}}"></eg-admin-page>
+      <eg-admin-page persistKeyPfx="{{persistKeyPfx}}" idlClass="{{idlClass}}"></eg-admin-page>
     `
 })
 
 export class BasicAdminPageComponent implements OnInit {
+
     idlClass: string;
     classLabel: string;
+    persistKeyPfx: string;
 
     constructor(
         private route: ActivatedRoute,
@@ -33,6 +35,10 @@ export class BasicAdminPageComponent implements OnInit {
         }
         const table = schema + '.' + this.route.snapshot.paramMap.get('table');
 
+        // Set the prefix to "server", "local", "workstation", 
+        // extracted from the URL path.
+        this.persistKeyPfx = this.route.snapshot.parent.url[0].path;
+
         Object.keys(this.idl.classes).forEach(class_ => {
             const classDef = this.idl.classes[class_];
             if (classDef.table === table) {
index 003a2da..29d0545 100644 (file)
@@ -51,12 +51,20 @@ export class AdminPageComponent implements OnInit {
     // Ditto includeOrgAncestors, but descendants.
     @Input() includeOrgDescendants: boolean;
 
+    // Optional grid persist key.  This is the part of the key 
+    // following eg.grid.
+    @Input() persistKey: string;
+
+    // Optional path component to add to the generated grid persist key, 
+    // formatted as (for example): 
+    // 'eg.grid.admin.${persistKeyPfx}.config.billing_type'
+    @Input() persistKeyPfx: string;
+
     @ViewChild('grid') grid: GridComponent;
     @ViewChild('editDialog') editDialog: FmRecordEditorComponent;
     @ViewChild('successString') successString: StringComponent;
     @ViewChild('createString') createString: StringComponent;
 
-    persistKey: string;
     idlClassDef: any;
     pkeyField: string;
     createNew: () => void;
@@ -101,7 +109,13 @@ export class AdminPageComponent implements OnInit {
     ngOnInit() {
         this.idlClassDef = this.idl.classes[this.idlClass];
         this.pkeyField = this.idlClassDef.pkey || 'id';
-        this.persistKey = 'admin.' + this.idlClassDef.table;
+
+        if (!this.persistKey) {
+            this.persistKey = 
+                'admin.' + 
+                (this.persistKeyPfx ? this.persistKeyPfx + '.' : '') + 
+                this.idlClassDef.table;
+        }
 
         // Limit the view org selector to orgs where the user has 
         // permacrud-encoded view permissions.