From: Bill Erickson Date: Tue, 22 Jun 2021 18:47:44 +0000 (-0400) Subject: LP1929741 Item location select starts with; hide Unset X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=2e40b80ae64f7a0b5f17a30d52e60ec83dbd9e48;p=working%2FEvergreen.git LP1929741 Item location select starts with; hide Unset Signed-off-by: Bill Erickson Signed-off-by: Galen Charlton Signed-off-by: Jane Sandberg --- 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 cd99267e44..33edf714f8 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 @@ -77,6 +77,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; @@ -147,7 +155,7 @@ export class ItemLocationSelectComponent const entries: ComboboxEntry[] = []; - if (!this.required) { + if (!this.required && this.showUnsetString) { entries.push({id: null, label: this.unsetString.text}); } @@ -161,8 +169,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()); @@ -177,9 +186,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) { @@ -195,7 +206,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">