LP1916949: combobox asyncSupportsEmptyTermClick works again user/mccanna/lp1916949_async_comboboxes_show_values_on_click_signoff
authorJane Sandberg <sandbej@linnbenton.edu>
Fri, 26 Feb 2021 01:04:13 +0000 (17:04 -0800)
committerTerran McCanna <tmccanna@georgialibraries.org>
Wed, 17 Mar 2021 17:45:01 +0000 (13:45 -0400)
This fixes two lines that were getting in the way of the desired
behavior of opening an async combobox (particularly those automagical
pcrud ones with an idlClass input) on user click when
asyncSupportsEmptyTermClick="true".

Basically, the addAsyncEntries method would accept _CLICK_ as a search
term.  However, it would then return '' instead of _CLICK_ as an
Observable value, so the filter method had no idea it was a click event.
Additionally, even if _CLICK_ had gotten through to the filter method,
it wasn't allowed to display those freshly-fetched pcrud values, since
asyncDataSources with searchterm _CLICK_ were needlessly excluded.

Also removes some imports that are no longer needed, just to keep things
tidy.

To test:
1) Apply this patch.
2) Go to Booking > Create Reservation
3) Click inside the Resource Type box.
4) Note that the available resource types display!

To make sure that asyncSupportsEmptyTermClick="false" still also
works as expected:
5) Go to Acquisitions > General Search.
6) Perform an empty search.
7) In the search results grid, some filter comboboxes have
   asyncSupportsEmptyTermClick, while others do not.  For example, the
   Status column has it, so if you click in the Status filter, a list of
   possible statuses will show up.  However, the Selecting User column
   (you have to enable this column) does not have it, so if you click in
   that filter, it doesn't automatically display a useless list of 100
   users.

Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Open-ILS/src/eg2/src/app/share/combobox/combobox.component.ts

index d21ad5f..1418505 100644 (file)
@@ -9,9 +9,8 @@ import {Component, OnInit, Input, Output, ViewChild,
     TemplateRef, EventEmitter, ElementRef, forwardRef} from '@angular/core';
 import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';
 import {Observable, of, Subject} from 'rxjs';
-import {map, tap, reduce, mergeMap, mapTo, debounceTime, distinctUntilChanged, merge, filter} from 'rxjs/operators';
+import {map, mergeMap, mapTo, debounceTime, distinctUntilChanged, merge, filter} from 'rxjs/operators';
 import {NgbTypeahead, NgbTypeaheadSelectItemEvent} from '@ng-bootstrap/ng-bootstrap';
-import {StoreService} from '@eg/core/store.service';
 import {IdlService, IdlObject} from '@eg/core/idl.service';
 import {PcrudService} from '@eg/core/pcrud.service';
 import {OrgService} from '@eg/core/org.service';
@@ -181,7 +180,6 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit, AfterVie
 
     constructor(
       private elm: ElementRef,
-      private store: StoreService,
       private idl: IdlService,
       private pcrud: PcrudService,
       private org: OrgService,
@@ -457,7 +455,7 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit, AfterVie
                 (entry: ComboboxEntry) => this.addAsyncEntry(entry),
                 err => {},
                 ()  => {
-                    observer.next(searchTerm);
+                    observer.next(term);
                     observer.complete();
                 }
             );
@@ -487,8 +485,8 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit, AfterVie
                 // click action occurred.
                 if (term === '') { return []; }
 
-                // In sync-data mode, a click displays the full list.
-                if (term === '_CLICK_' && !this.asyncDataSource) {
+                // A click displays the full list.
+                if (term === '_CLICK_') {
                     return this.entrylist;
                 }