};
}
- 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 => {
template: `
<eg-staff-banner bannerText="{{classLabel}} Configuration" i18n-bannerText>
</eg-staff-banner>
- <eg-admin-page persistKeyPfx="{{persistKeyPfx}}" idlClass="{{idlClass}}"></eg-admin-page>
+ <eg-admin-page persistKeyPfx="{{persistKeyPfx}}" idlClass="{{idlClass}}" readonlyFields="{{readonlyFields}}"></eg-admin-page>
`
})
idlClass: string;
classLabel: string;
persistKeyPfx: string;
+ readonlyFields: string = '';
constructor(
private route: ActivatedRoute,
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.
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);
}
}
}
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
// '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;