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=0371222ac33a9fbb8d91200cad131e9f5b74ba20;p=working%2FEvergreen.git LP1929741 Item location select starts with; hide Unset Signed-off-by: Bill Erickson Signed-off-by: Galen Charlton --- 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 7c5c035099..024e729563 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 @@ -63,6 +63,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; @@ -133,7 +141,7 @@ export class ItemLocationSelectComponent const entries: ComboboxEntry[] = []; - if (!this.required) { + if (!this.required && this.showUnsetString) { entries.push({id: null, label: this.unsetString.text}); } @@ -147,8 +155,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()); @@ -163,9 +172,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) { @@ -181,7 +192,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">