Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Allow to filter null values optionally in debounced input

Oliver Güntherf2d018447575
diff --git a/frontend/src/app/helpers/rxjs/debounced-input-switchmap.ts b/frontend/src/app/helpers/rxjs/debounced-input-switchmap.ts
index 1fee6345fce..5a9dfb50781 100644
--- a/frontend/src/app/helpers/rxjs/debounced-input-switchmap.ts
+++ b/frontend/src/app/helpers/rxjs/debounced-input-switchmap.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) => {
diff --git a/frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.component.ts b/frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.component.ts
index c2d036cf6c7..6abbb5f0cb5 100644
--- a/frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.component.ts
+++ b/frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.component.ts
@@ -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;