From 42594504a9a53d6b5ec850e6bbd8c0482a01ef4e Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 11 Aug 2021 15:01:06 -0400 Subject: [PATCH] LP1888723 Avoid save warning on vol load; vol save thinko Signed-off-by: Bill Erickson Signed-off-by: Ruth Frasur Signed-off-by: Galen Charlton --- .../src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts | 12 +++++++++--- .../src/eg2/src/app/staff/cat/volcopy/volcopy.component.ts | 5 ++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts index 5b28baafa7..ab9309cf09 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts @@ -95,7 +95,7 @@ export class VolEditComponent implements OnInit { .then(_ => this.addStubCopies()) // It's possible the loaded data is not strictly allowed, // e.g. empty string call number labels - .then(_ => this.emitSaveChange()); + .then(_ => this.emitSaveChange(true)); } copyStatLabel(copy: IdlObject): string { @@ -544,9 +544,15 @@ export class VolEditComponent implements OnInit { // Called any time a change occurs that could affect the // save-ability of the form. - emitSaveChange() { + emitSaveChange(initialLoad?: boolean) { + const saveable = this.canSave(); + + // Avoid emitting a save change event when this was called + // during page load and the resulting data is saveable. + if (initialLoad && saveable) { return; } + setTimeout(() => { - this.canSaveChange.emit(this.canSave()); + this.canSaveChange.emit(saveable); }); } diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.ts index 6d2a0b6824..e288b8df6a 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.ts @@ -336,7 +336,10 @@ export class VolCopyComponent implements OnInit { save(close?: boolean): Promise { this.loading = true; - this.copyAttrs.applyPendingChanges(); + if (this.copyAttrs) { + // Won't exist on any non-attrs page. + this.copyAttrs.applyPendingChanges(); + } // Volume update API wants volumes fleshed with copies, instead // of the other way around, which is what we have here. -- 2.11.0