Allow to filter null values optionally in debounced input

The search depends on an initial null value input to function
pull/8546/head
Oliver Günther 4 years ago
parent f98f98e833
commit f2d0184475
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 4
      frontend/src/app/helpers/rxjs/debounced-input-switchmap.ts
  2. 3
      frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.component.ts

@ -37,17 +37,19 @@ export class DebouncedRequestSwitchmap<T, R = HalResource> {
/**
* @param handler switch map handler function to output a response observable
* @param debounceTime {number} Time to debounce in ms.
* @param preFilterNull {boolean} Whether to exclude null and undefined searches
* @param emptyValue {R} The empty fall back value before first response or on errors
*/
constructor(readonly requestHandler:RequestSwitchmapHandler<T, R[]>,
readonly errorHandler:RequestErrorHandler,
readonly preFilterNull:boolean = false,
readonly debounceMs = 250) {
/** Output switchmap observable */
this.output$ = concat(
of([]),
this.input$.pipe(
filter(val => val !== undefined && val !== null),
filter(val => !preFilterNull || (val !== undefined && val !== null)),
distinctUntilChanged(),
debounceTime(debounceMs),
tap((val:T) => {

@ -51,7 +51,8 @@ export class AddListModalComponent extends OpModalComponent implements OnInit {
/** Keep a switchmap for search term and loading state */
public requests = new DebouncedRequestSwitchmap<string, ValueOption>(
(searchTerm:string) => this.actionService.loadAvailable(this.board, this.active, searchTerm),
errorNotificationHandler(this.halNotification)
errorNotificationHandler(this.halNotification),
true
);
public showClose:boolean;

Loading…
Cancel
Save