From: Bill Erickson Date: Mon, 12 Aug 2019 21:46:40 +0000 (-0400) Subject: LPXXX fm-editor API consolidation WIP X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Fberick%2Flpxxx-org-unit-admin;p=working%2FEvergreen.git LPXXX fm-editor API consolidation WIP Signed-off-by: Bill Erickson --- 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 739a2c48d1..aa54bd1b77 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 @@ -160,10 +160,14 @@ export class FmRecordEditorComponent } } else { this._recordId = null; - this.record = null; + this._record = null; } } + get recordId(): any { + return this._recordId; + } + // IDL record we are editing _record: IdlObject; @@ -174,7 +178,7 @@ export class FmRecordEditorComponent this.handleRecordChange(); } } else { - this.recordId = null; + this._recordId = null; this._record = null; } } @@ -270,9 +274,12 @@ export class FmRecordEditorComponent let promise; if (this.record && this.recordId === null) { promise = Promise.resolve(this.record); - } else { + } else if (this.recordId) { promise = this.pcrud.retrieve(this.idlClass, this.recordId).toPromise(); + } else { + // Not enough data yet to fetch anything + return Promise.resolve(); } return promise.then(rec => { @@ -282,7 +289,8 @@ export class FmRecordEditorComponent record found with id ${this.recordId}`); } - this.record = rec; + // Set this._record (not this.record) to avoid loop in initRecord() + this._record = rec; this.convertDatatypesToJs(); return this.getFieldList(); }); @@ -292,8 +300,9 @@ export class FmRecordEditorComponent // // Create a new record from the stub record provided by the // caller or a new from-scratch record - this.record = this.record || this.idl.create(this.idlClass); - this.recordId = null; // avoid future confusion + // Set this._record (not this.record) to avoid loop in initRecord() + this._record = this.record || this.idl.create(this.idlClass); + this._recordId = null; // avoid future confusion return this.getFieldList(); }