item and patron stat cat admin pages collab/phasefx/stat-cat-admin-wip-alternative
authorJason Etheridge <jason@EquinoxOLI.org>
Wed, 14 Dec 2022 05:58:29 +0000 (00:58 -0500)
committerJason Etheridge <jason@EquinoxOLI.org>
Wed, 14 Dec 2022 13:47:49 +0000 (08:47 -0500)
Leverages the BasicAdminPage component, with some tweaks.

Changes to the BasicAdminPage and AdminPage components all default to off, so should not affect existing interfaces:

* add an option to hide the Clear Filters action from subordinate admin pages (when you follow config fields)
* add an option to propagate recordLabel to the fmEditor component, and also use said label within the admin page
* add an option to propagate orgDefaultAllowed to the fmEditor component

For the stat cat and entry admin pages specifically, we leverage these to:

* hide Clear Filters so that we don't let the user get into a situation where they try to create a new stat cat entry but have a blank and unsettable stat cat field (because we mark that field as read-only in the fmEditor)
* default the Owner field for new stat cats and entries to the workstation library
* use Item and Patron instead of Asset and Actor in various labels (at least until we're ready to make that change wholesale in the IDL)

Signed-off-by: Jason Etheridge <jason@EquinoxOLI.org>
Open-ILS/src/eg2/src/app/staff/admin/basic-admin-page.component.spec.ts
Open-ILS/src/eg2/src/app/staff/admin/basic-admin-page.component.ts
Open-ILS/src/eg2/src/app/staff/admin/local/admin-local-splash.component.html
Open-ILS/src/eg2/src/app/staff/admin/local/routing.module.ts
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 7a5cb9d..e2b4794 100644 (file)
@@ -30,10 +30,13 @@ class MockAdminPageComponent {
     @Input() configLinkBasePath: string;
     @Input() defaultNewRecord: IdlObject;
     @Input() disableOrgFilter: boolean;
+    @Input() hideClearFilters: boolean;
     @Input() fieldOrder: string;
     @Input() idlClass: string;
     @Input() persistKeyPfx: string;
     @Input() readonlyFields: string;
+    @Input() recordLabel: string;
+    @Input() orgDefaultAllowed: string;
 }
 
 describe('Component: BasicAdminPage', () => {
index 1f63253..f2d7fa2 100644 (file)
@@ -11,14 +11,17 @@ import {tap, switchMap} from 'rxjs/operators';
 @Component({
     template: `
       <ng-container *ngIf="idlClass">
-      <eg-title i18n-prefix prefix="{{classLabel}} Administration">
+      <eg-title i18n-prefix prefix="{{recordLabel || classLabel}} Administration">
       </eg-title>
-      <eg-staff-banner bannerText="{{classLabel}} Configuration" i18n-bannerText>
+      <eg-staff-banner bannerText="{{recordLabel || classLabel}} Configuration" i18n-bannerText>
       </eg-staff-banner>
       <eg-admin-page persistKeyPfx="{{persistKeyPfx}}" idlClass="{{idlClass}}"
         configLinkBasePath="{{configLinkBasePath}}"
         fieldOrder="{{fieldOrder}}"
         readonlyFields="{{readonlyFields}}"
+        recordLabel="{{recordLabel}}"
+        orgDefaultAllowed="{{orgDefaultAllowed}}"
+        [hideClearFilters]="hideClearFilters"
         [defaultNewRecord]="defaultNewRecordIdl"
         [disableOrgFilter]="disableOrgFilter"></eg-admin-page>
       </ng-container>
@@ -32,6 +35,9 @@ export class BasicAdminPageComponent implements OnInit {
     persistKeyPfx: string;
     fieldOrder = '';
     readonlyFields = '';
+    recordLabel = '';
+    orgDefaultAllowed = '';
+    hideClearFilters: boolean;
     defaultNewRecordIdl: IdlObject;
     configLinkBasePath = '/staff/admin';
 
@@ -75,6 +81,9 @@ export class BasicAdminPageComponent implements OnInit {
                     this.disableOrgFilter = data['disableOrgFilter'];
                     this.fieldOrder = data['fieldOrder'];
                     this.readonlyFields = data['readonlyFields'];
+                    this.recordLabel = data['recordLabel'];
+                    this.orgDefaultAllowed = data['orgDefaultAllowed'];
+                    this.hideClearFilters = data['hideClearFilters'];
                     this.defaultNewRecord = data['defaultNewRecord'];
                 }
 
index 92d22f0..b5eb873 100644 (file)
       routerLink="/staff/admin/local/config/standing_penalty"></eg-link-table-link>
     <eg-link-table-link i18n-label label="Statistical Categories Editor" 
       url="/eg/staff/admin/local/asset/stat_cat_editor"></eg-link-table-link>
+    <eg-link-table-link i18n-label label="Item Statistical Categories Editor" 
+      routerLink="/staff/admin/local/asset/stat_cat"></eg-link-table-link>
+    <eg-link-table-link i18n-label label="Patron Statistical Categories Editor" 
+      routerLink="/staff/admin/local/actor/stat_cat"></eg-link-table-link>
     <eg-link-table-link i18n-label label="Statistical Popularity Badges" 
       routerLink="/staff/admin/local/rating/badge"></eg-link-table-link>
     <eg-link-table-link i18n-label label="Surveys" 
index 267f008..0f53843 100644 (file)
@@ -98,6 +98,48 @@ const routes: Routes = [{
     loadChildren: () =>
       import('./negative-balances/negative-balances.module').then(m => m.NegativeBalancesModule)
 }, {
+    path: 'asset/stat_cat',
+    component: BasicAdminPageComponent,
+    data: [{
+        schema: 'asset',
+        table: 'stat_cat',
+        readonlyFields: 'id',
+        orgDefaultAllowed: 'owner',
+        recordLabel: $localize `Item Statistical Category`,
+        fieldOrder: 'name,owner,required,opac_visible,checkout_archive,sip_field,sip_format'}]
+}, {
+    path: 'asset/stat_cat_entry',
+    component: BasicAdminPageComponent,
+    data: [{
+        schema: 'asset',
+        table: 'stat_cat_entry',
+        readonlyFields: 'id,stat_cat',
+        orgDefaultAllowed: 'owner',
+        recordLabel: $localize `Item Statistical Category Entry`,
+        hideClearFilters: true,
+        fieldOrder: 'stat_cat,value,owner'}]
+}, {
+    path: 'actor/stat_cat',
+    component: BasicAdminPageComponent,
+    data: [{
+        schema: 'actor',
+        table: 'stat_cat',
+        readonlyFields: 'id',
+        orgDefaultAllowed: 'owner',
+        recordLabel: $localize `Patron Statistical Category`,
+        fieldOrder: 'name,owner,required,opac_visible,usr_summary,allow_freetext,checkout_archive,sip_field,sip_format'}]
+}, {
+    path: 'actor/stat_cat_entry',
+    component: BasicAdminPageComponent,
+    data: [{
+        schema: 'actor',
+        table: 'stat_cat_entry',
+        readonlyFields: 'id,stat_cat',
+        orgDefaultAllowed: 'owner',
+        recordLabel: $localize `Patron Statistical Category Entry`,
+        hideClearFilters: true,
+        fieldOrder: 'stat_cat,value,owner'}]
+}, {
     path: ':schema/:table',
     component: BasicAdminPageComponent
 }
index 817a018..7457638 100644 (file)
@@ -1,19 +1,19 @@
-<ng-template #successStrTmpl i18n>{{idlClassDef.label}} Update Succeeded</ng-template>
+<ng-template #successStrTmpl i18n>{{recordLabel || idlClassDef.label}} Update Succeeded</ng-template>
 <eg-string #successString [template]="successStrTmpl"></eg-string>
 
-<ng-template #updateFailedStrTmpl i18n>Update of {{idlClassDef.label}} failed</ng-template>
+<ng-template #updateFailedStrTmpl i18n>Update of {{recordLabel || 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>
+<ng-template #deleteFailedStrTmpl i18n>Delete of {{recordLabel || 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>
+<ng-template #deleteSuccessStrTmpl i18n>{{recordLabel || idlClassDef.label}} Successfully Deleted</ng-template>
 <eg-string #deleteSuccessString [template]="deleteSuccessStrTmpl"></eg-string>
 
-<ng-template #createStrTmpl i18n>{{idlClassDef.label}} Successfully Created</ng-template>
+<ng-template #createStrTmpl i18n>{{recordLabel || idlClassDef.label}} Successfully Created</ng-template>
 <eg-string #createString [template]="createStrTmpl"></eg-string>
 
-<ng-template #createErrStrTmpl i18n>Failed to create new {{idlClassDef.label}}</ng-template>
+<ng-template #createErrStrTmpl i18n>Failed to create new {{recordLabel || idlClassDef.label}}</ng-template>
 <eg-string #createErrString [template]="createErrStrTmpl"></eg-string>
 
 <ng-container *ngIf="orgField || gridFilters">
@@ -32,7 +32,7 @@
       <div class="flex-1"></div><!-- push right -->
       <ng-container *ngIf="gridFilters">
         <span i18n>Filters Applied: {{gridFilters | json}}</span>
-        <a class="pl-2 font-italic" 
+        <a *ngIf="!hideClearFilters" class="pl-2 font-italic" 
           [attr.href]="clearGridFiltersUrl()" i18n>Clear Filters</a>
       </ng-container>
     </div>
@@ -57,7 +57,7 @@
     (onRowActivate)="showEditDialog($event)"
     [filterable]="true" [stickyHeader]="true">
   <eg-grid-toolbar-button [disabled]="!canCreate" 
-    label="New {{idlClassDef.label}}" i18n-label (onClick)="createNew()">
+    label="New {{recordLabel || idlClassDef.label}}" i18n-label (onClick)="createNew()">
   </eg-grid-toolbar-button>
   <eg-grid-toolbar-button [disabled]="translatableFields.length === 0"
     label="Apply Translations" i18n-label (onClick)="translate()">
 </eg-grid>
 
 <eg-fm-record-editor #editDialog idlClass="{{idlClass}}" 
+    [recordLabel]="recordLabel"
     [fieldOptions]="fieldOptions"
     [fieldOrder]="fieldOrder"
     [defaultNewRecord]="defaultNewRecord"
     [preloadLinkedValues]="true"
+    [orgDefaultAllowed]="orgDefaultAllowed"
     [readonlyFields]="readonlyFields">
 </eg-fm-record-editor>
 
index 7098c70..aac070f 100644 (file)
@@ -79,6 +79,15 @@ export class AdminPageComponent implements OnInit {
     // Optional comma-separated list of read-only fields
     @Input() readonlyFields: string;
 
+    // Optional record label to use instead of the IDL label
+    @Input() recordLabel: string;
+
+    // optional flag to hide the Clear Filters action for gridFilters
+    @Input() hideClearFilters: boolean;
+
+    // optional list of org fields which are allowed a default if unset
+    @Input() orgDefaultAllowed: string;
+
     // Optional template containing help/about text which will
     // be added to the page, above the grid.
     @Input() helpTemplate: TemplateRef<any>;