.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 {
// 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);
});
}
save(close?: boolean): Promise<any> {
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.