// the typeahead
@Input() readOnly = false;
+ // See combobox
+ @Input() startsWith = false;
+
+ // Show <Unset> when no value is applied.
+ // This only applies to non-required fields, since <Unset> 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;
const entries: ComboboxEntry[] = [];
- if (!this.required) {
+ if (!this.required && this.showUnsetString) {
entries.push({id: null, label: this.unsetString.text});
}
}
getLocationsAsync(term: string): Observable<ComboboxEntry> {
+ // "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());
return of();
}
+ const ilike = this.startsWith ? `${term}%` : `%${term}%`;
+
const search: any = {
deleted: 'f',
- name: {'ilike': `%${term}%`}
+ name: {'ilike': ilike}
};
if (this.startId) {
}
return new Observable<ComboboxEntry>(observer => {
- if (!this.required) {
+ if (!this.required && this.showUnsetString) {
observer.next({id: null, label: this.unsetString.text});
}
</eg-org-select>
</div>
<div class="flex-1 p-1">
- <eg-item-location-select [readOnly]="fieldIsDisabled('location')"
- #locationSelector [ngModel]="copy.location()"
+ <eg-item-location-select [readOnly]="fieldIsDisabled('location')"
+ #locationSelector [ngModel]="copy.location()" [startsWith]="true"
(valueChange)="valueChange('location', $event)"
- permFilter="CREATE_PICKLIST">
+ permFilter="CREATE_PICKLIST" [showUnsetString]="false">
</eg-item-location-select>
</div>
<div class="flex-1 p-1">