From 149e78a11fc3ac25d2b5d681ec8ac8c602b84569 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 13 May 2020 10:22:02 -0400 Subject: [PATCH] LP1847800 fm-editor defaultNewRecord backport Backport the defaultNewRecord option for the fm-editor and auto admin pages to support new record creation based on grid filters. This feature was originally part of LP1840287 which was not backported to 3.4 Signed-off-by: Bill Erickson --- .../eg2/src/app/share/fm-editor/fm-editor.component.ts | 15 +++++++++++++-- .../app/staff/share/admin-page/admin-page.component.html | 2 +- 2 files changed, 14 insertions(+), 3 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 2d9271830e..bed3d861b4 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 @@ -100,6 +100,9 @@ export class FmRecordEditorComponent // behaviour for each field (by field name). @Input() fieldOptions: {[fieldName: string]: FmFieldOptions} = {}; + // This is used to set default values when making a new record + @Input() defaultNewRecord: IdlObject; + // list of fields that should not be displayed @Input() hiddenFieldsList: string[] = []; @Input() hiddenFields: string; // comma-separated string version @@ -356,8 +359,16 @@ export class FmRecordEditorComponent // // Create a new record from the stub record provided by the // caller or a new from-scratch record - // Set this._record (not this.record) to avoid loop in initRecord() - this._record = this.record || this.idl.create(this.idlClass); + if (!this.record) { + // NOTE: Set this._record (not this.record) to avoid + // loop in initRecord() + if (this.defaultNewRecord) { + // Clone to avoid polluting the stub record + this._record = this.idl.clone(this.defaultNewRecord); + } else { + this._record = this.idl.create(this.idlClass); + } + } this._recordId = null; // avoid future confusion return this.getFieldList(); 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 7841c43799..5234f491af 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 @@ -71,7 +71,7 @@ -- 2.11.0