Skip to content

Commit 2b5b7db

Browse files
sandbergjammorgannoble
authored andcommitted
LP2052742 Assure ou setting resolves before checking canSave()
emitSaveChange() calls canSave(), which checks the library setting cat.require_call_number_labels. However, since the library setting check is asynchronous, there's a chance that we get to canSave() before we have the library setting value, so it uses the default (true) instead. This commit uses .then() to make sure that we only call emitSaveChange() after the library setting promise resolves and we have the actual setting value, rather than the default. Release-Note: Fixes a race condition retrieving the cat.require_call_number_labels ou setting Co-authored-by: Michele Morgan <[email protected]> Signed-off-by: Jane Sandberg <[email protected]> Signed-off-by: Shula Link <[email protected]> Signed-off-by: Steven Mayo <[email protected]> Signed-off-by: blake <[email protected]> Signed-off-by: Jason Stephenson <[email protected]> Signed-off-by: Terran McCanna <[email protected]>
1 parent ba05b0b commit 2b5b7db

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -93,28 +93,27 @@ export class VolEditComponent implements OnInit {
9393

9494
this.volcopy.genBarcodesRequested.subscribe(() => this.generateBarcodes());
9595

96-
this.volcopy.fetchRecordVolLabels(this.context.recordId)
97-
.then(labels => this.recordVolLabels = labels)
98-
.then(_ => this.volcopy.fetchBibParts(this.context.getRecordIds()))
99-
.then(_ => this.addStubCopies())
100-
// It's possible the loaded data is not strictly allowed,
101-
// e.g. empty string call number labels
102-
.then(_ => this.emitSaveChange(true));
103-
104-
// Check to see if call number label is required
105-
this.org.settings('cat.require_call_number_labels')
106-
.then(settings => {
107-
this.requireCNL =
108-
Boolean(settings['cat.require_call_number_labels']);
109-
});
110-
11196
// Check for each org if a part is required
11297
for (const orgId of this.context.getOwningLibIds()) {
11398
this.org.settings('circ.holds.ui_require_monographic_part_when_present', orgId)
11499
.then(settings => {
115100
this.requirePartsOrgMap[orgId] = Boolean(settings['circ.holds.ui_require_monographic_part_when_present']);
116101
});
117102
}
103+
104+
// Check to see if call number label is required
105+
this.org.settings('cat.require_call_number_labels')
106+
.then(settings => {
107+
this.requireCNL =
108+
Boolean(settings['cat.require_call_number_labels']);
109+
})
110+
.then(() => this.volcopy.fetchRecordVolLabels(this.context.recordId))
111+
.then(labels => this.recordVolLabels = labels)
112+
.then(_ => this.volcopy.fetchBibParts(this.context.getRecordIds()))
113+
.then(_ => this.addStubCopies())
114+
// It's possible the loaded data is not strictly allowed,
115+
// e.g. empty string call number labels
116+
.then(_ => this.emitSaveChange(true));
118117
}
119118

120119
copyStatLabel(copy: IdlObject): string {

0 commit comments

Comments
 (0)