From 2e60910340c3d7c55685e6421f4749f86092e19c Mon Sep 17 00:00:00 2001 From: Jane Sandberg Date: Sat, 29 Dec 2018 16:40:10 -0800 Subject: [PATCH] LP1809288: Make some brt fields read-only Signed-off-by: Jane Sandberg Signed-off-by: Bill Erickson --- .../src/app/share/fm-editor/fm-editor.component.ts | 13 ++++++++++++- .../app/staff/admin/basic-admin-page.component.ts | 21 +++++++++++++++++---- .../src/app/staff/admin/booking/routing.module.ts | 4 ++++ .../share/admin-page/admin-page.component.html | 2 +- .../staff/share/admin-page/admin-page.component.ts | 3 +++ 5 files changed, 37 insertions(+), 6 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts b/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts index 3ad4892cb7..7b90a02437 100644 --- a/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts +++ b/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts @@ -256,7 +256,18 @@ export class FmRecordEditorComponent }; } - if (field.datatype === 'link') { + if (field.datatype === 'link' && field.readOnly) { // no need to fetch all possible values for read-only fields + let id_to_fetch = this.record[field.name](); + if (id_to_fetch) { + promises.push( + this.pcrud.retrieve(field.class, this.record[field.name]()) + .toPromise().then(list => { + field.linkedValues = + this.flattenLinkedValues(field.class, Array(list)); + }) + ); + } + } else if (field.datatype === 'link') { promises.push( this.pcrud.retrieveAll(field.class, {}, {atomic : true}) .toPromise().then(list => { diff --git a/Open-ILS/src/eg2/src/app/staff/admin/basic-admin-page.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/basic-admin-page.component.ts index 0d6be84dbd..0427646abc 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/basic-admin-page.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/basic-admin-page.component.ts @@ -10,7 +10,7 @@ import {IdlService} from '@eg/core/idl.service'; template: ` - + ` }) @@ -19,6 +19,7 @@ export class BasicAdminPageComponent implements OnInit { idlClass: string; classLabel: string; persistKeyPfx: string; + readonlyFields: string = ''; constructor( private route: ActivatedRoute, @@ -33,7 +34,13 @@ export class BasicAdminPageComponent implements OnInit { const data = this.route.snapshot.data[0]; if (data) { schema = data.schema; } } - const table = schema + '.' + this.route.snapshot.paramMap.get('table'); + let table = this.route.snapshot.paramMap.get('table'); + if (!table) { + const data = this.route.snapshot.data[0]; + if (data) { table = data.table; } + } + const full_table = schema + '.' + table; + // Set the prefix to "server", "local", "workstation", // extracted from the URL path. @@ -44,16 +51,22 @@ export class BasicAdminPageComponent implements OnInit { this.persistKeyPfx = ''; } + // Pass the readonlyFields param if available + if (this.route.snapshot.data[0].readonlyFields) { + this.readonlyFields = this.route.snapshot.data[0].readonlyFields; + } + + Object.keys(this.idl.classes).forEach(class_ => { const classDef = this.idl.classes[class_]; - if (classDef.table === table) { + if (classDef.table === full_table) { this.idlClass = class_; this.classLabel = classDef.label; } }); if (!this.idlClass) { - throw new Error('Unable to find IDL class for table ' + table); + throw new Error('Unable to find IDL class for table ' + full_table); } } } diff --git a/Open-ILS/src/eg2/src/app/staff/admin/booking/routing.module.ts b/Open-ILS/src/eg2/src/app/staff/admin/booking/routing.module.ts index 1cbf480ee4..cb5ef9e589 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/booking/routing.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/booking/routing.module.ts @@ -7,6 +7,10 @@ const routes: Routes = [{ path: 'splash', component: AdminBookingSplashComponent }, { + path: 'resource_type', + component: BasicAdminPageComponent, + data: [{schema: 'booking', table: 'resource_type', readonlyFields: 'catalog_item,record'}] +}, { path: ':table', component: BasicAdminPageComponent, // All booking admin pages cover data in the booking.* schema. No need to 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 194f06b515..0fc5c44b51 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 @@ -53,7 +53,7 @@ - + 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 be4452b1b3..80fd2fdf6c 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 @@ -62,6 +62,9 @@ export class AdminPageComponent implements OnInit { // 'eg.grid.admin.${persistKeyPfx}.config.billing_type' @Input() persistKeyPfx: string; + // Optional comma-separated list of read-only fields + @Input() readonlyFields: string; + @ViewChild('grid') grid: GridComponent; @ViewChild('editDialog') editDialog: FmRecordEditorComponent; @ViewChild('successString') successString: StringComponent; -- 2.11.0