From 48771af5ae7d6292eef763f9a5677acc93ecacc9 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 15 Sep 2021 10:21:25 -0400 Subject: [PATCH] LP1846552 Shelving location Order handle new locations Ensure that copy locations added since the last time location order entries were saved are displayed. Show when a location is "unsaved" in the UI. Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- .../copy-loc-order/copy-loc-order.component.html | 3 ++- .../copy-loc-order/copy-loc-order.component.ts | 22 ++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/copy-loc-order/copy-loc-order.component.html b/Open-ILS/src/eg2/src/app/staff/admin/local/copy-loc-order/copy-loc-order.component.html index c37cf0a8f8..6c42172b08 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/copy-loc-order/copy-loc-order.component.html +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/copy-loc-order/copy-loc-order.component.html @@ -27,7 +27,7 @@ class="mr-2 btn btn-sm btn-outline-dark .mat-icon-shrunk-in-button"> vertical_align_bottom - + Selected: {{selected().location().name()}} ({{orgSn(selected().location().owning_lib())}}) @@ -52,6 +52,7 @@ [ngClass]="{'border border-primary rounded': selectedEntry == entry.id()}"> {{entry.location().name()}} ({{orgSn(entry.location().owning_lib())}}) + (unsaved) diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/copy-loc-order/copy-loc-order.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/copy-loc-order/copy-loc-order.component.ts index 56e9b1a341..fb9eb4e2aa 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/copy-loc-order/copy-loc-order.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/copy-loc-order/copy-loc-order.component.ts @@ -70,21 +70,27 @@ export class CopyLocOrderComponent implements OnInit { .then(_ => { - if (this.entries.length > 0) { return; } - - // If we have no position entries, create some now so they - // can become the basis of our new list. + // Ensure we have an entry for every in-range copy location. const locs = Object.values(this.locations) .sort((o1, o2) => o1.name() < o2.name() ? -1 : 1); - let pos = 1; + let pos = this.entries.length; + locs.forEach(loc => { - const entry = this.idl.create('acplo'); + pos++; + + let entry = this.entries.filter(e => e.location().id() === loc.id())[0]; + if (entry) { return; } + + // Either we have no entries or we encountered a new copy + // location added since the last time entries were saved. + + entry = this.idl.create('acplo'); entry.isnew(true); - entry.id(-pos); // avoid using '0' as an ID + entry.id(-pos); // local temp ID entry.location(loc); - entry.position(pos++); + entry.position(pos); entry.org(this.contextOrg); this.entries.push(entry); }); -- 2.11.0