From 6552bed7eef04764062e32480f2b5d3a00836690 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 22 Jun 2021 14:47:44 -0400 Subject: [PATCH] LP1929741 Item location select starts with; hide Unset Signed-off-by: Bill Erickson --- .../item-location-select.component.html | 1 + .../item-location-select.component.ts | 19 +++++++++++++++---- .../app/staff/acq/lineitem/copy-attrs.component.html | 6 +++--- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/share/item-location-select/item-location-select.component.html b/Open-ILS/src/eg2/src/app/share/item-location-select/item-location-select.component.html index d452fa797c..eae6d05d44 100644 --- a/Open-ILS/src/eg2/src/app/share/item-location-select/item-location-select.component.html +++ b/Open-ILS/src/eg2/src/app/share/item-location-select/item-location-select.component.html @@ -15,6 +15,7 @@ [displayTemplate]="displayTemplate" (onChange)="cboxChanged($event)" [required]="required" + [startsWith]="startsWith" (blur)="propagateTouch()" placeholder="Shelving Location..." i18n-placeholder> diff --git a/Open-ILS/src/eg2/src/app/share/item-location-select/item-location-select.component.ts b/Open-ILS/src/eg2/src/app/share/item-location-select/item-location-select.component.ts index ae304c73b6..2365f185ce 100644 --- a/Open-ILS/src/eg2/src/app/share/item-location-select/item-location-select.component.ts +++ b/Open-ILS/src/eg2/src/app/share/item-location-select/item-location-select.component.ts @@ -59,6 +59,14 @@ export class ItemLocationSelectComponent // the typeahead @Input() readOnly = false; + // See combobox + @Input() startsWith = false; + + // Show when no value is applied. + // This only applies to non-required fields, since would + // trick the combobox into thinking a valid value had been applied + @Input() showUnsetString = true; + @ViewChild('comboBox', {static: false}) comboBox: ComboboxComponent; @ViewChild('unsetString', {static: false}) unsetString: StringComponent; @@ -129,7 +137,7 @@ export class ItemLocationSelectComponent const entries: ComboboxEntry[] = []; - if (!this.required) { + if (!this.required && this.showUnsetString) { entries.push({id: null, label: this.unsetString.text}); } @@ -143,8 +151,9 @@ export class ItemLocationSelectComponent } getLocationsAsync(term: string): Observable { + // "1" is ignored, but a value is needed for pipe() below + let obs = of([1]); - let obs = of(); if (!this.filterOrgsApplied) { // Apply filter orgs the first time they are needed. obs = from(this.setFilterOrgs()); @@ -159,9 +168,11 @@ export class ItemLocationSelectComponent return of(); } + const ilike = this.startsWith ? `${term}%` : `%${term}%`; + const search: any = { deleted: 'f', - name: {'ilike': `%${term}%`} + name: {'ilike': ilike} }; if (this.startId) { @@ -177,7 +188,7 @@ export class ItemLocationSelectComponent } return new Observable(observer => { - if (!this.required) { + if (!this.required && this.showUnsetString) { observer.next({id: null, label: this.unsetString.text}); } diff --git a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/copy-attrs.component.html b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/copy-attrs.component.html index 623584b540..43f13b3245 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/copy-attrs.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/copy-attrs.component.html @@ -15,10 +15,10 @@
- + permFilter="CREATE_PICKLIST" [showUnsetString]="false">
-- 2.11.0