LP#1888723: tweak eg-item-location-select
authorGalen Charlton <gmc@equinoxOLI.org>
Sun, 15 Aug 2021 23:37:39 +0000 (19:37 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Sun, 15 Aug 2021 23:57:23 +0000 (19:57 -0400)
The contextOrgId Input() can now be changed dynamically; doing
so will refresh the list list of shelving locations available
in the drop-down.

Apply this to the distribution formula editor.

Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/eg2/src/app/share/item-location-select/item-location-select.component.ts
Open-ILS/src/eg2/src/app/staff/admin/acq/distribution_formula/distribution-formula-edit-dialog.component.html

index 97ffc53..4317500 100644 (file)
@@ -37,7 +37,11 @@ export class ItemLocationSelectComponent
     @Input() permFilter: string;
 
     // Limit copy locations to those owned at or above this org unit.
-    @Input() contextOrgId: number;
+    private _contextOrgId: number;
+    @Input() set contextOrgId(value: number) {
+        this._contextOrgId = value;
+        this.ngOnInit();
+    }
 
     @Input() orgUnitLabelField = 'shortname';
 
@@ -159,7 +163,7 @@ export class ItemLocationSelectComponent
     }
 
     setFilterOrgs(): Promise<number[]> {
-        const org = this.contextOrgId || this.auth.user().ws_ou();
+        const org = this._contextOrgId || this.auth.user().ws_ou();
         const contextOrgIds = this.org.ancestors(org, true);
 
         if (!this.permFilter) {
index 5c537df..c89c3fa 100644 (file)
@@ -62,7 +62,7 @@
         </div>
         <div class="col-sm-2">
           <eg-item-location-select
-            permFilter="ADMIN_ACQ_DISTRIB_FORMULA"
+            permFilter="ADMIN_ACQ_DISTRIB_FORMULA" [contextOrgId]="entry.owning_lib()"
             [ngModel]="entry.location()" name="location-{{idx}}"
             (ngModelChange)="entry.location($event)"
             (valueChange)="myForm.form.markAsDirty()">