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 empty search values for autocompleter in certain modes

Klaus Zandersea63ed50edcb
diff --git a/frontend/src/app/shared/components/autocompleter/op-autocompleter/services/op-autocompleter.service.ts b/frontend/src/app/shared/components/autocompleter/op-autocompleter/services/op-autocompleter.service.ts
index 3f78a0c9b10..268e5168773 100644
--- a/frontend/src/app/shared/components/autocompleter/op-autocompleter/services/op-autocompleter.service.ts
+++ b/frontend/src/app/shared/components/autocompleter/op-autocompleter/services/op-autocompleter.service.ts
@@ -87,29 +87,29 @@ export class OpAutocompleterService extends UntilDestroyedMixin {
// If you need to fetch our default date sources like work_packages or users,
// you should use the default method (loadAvailable), otherwise you should implement a function for
// your desired resource
- public loadData(matching:string|null, resource:TOpAutocompleterResource, filters?:IAPIFilter[], searchKey?:string) {
+ public loadData(matching:string|null, resource:TOpAutocompleterResource, filters?:IAPIFilter[], searchKey?:string, allowEmpty:boolean = false) {
// Exit early if the query string is empty as there is no typeahead
- if (matching === null || matching.length === 0) {
+ if (!allowEmpty && (matching === null || matching.length === 0)) {
return of([]);
}
switch (resource) {
// in this case we can add more functions for fetching usual resources
default: {
- return this.loadAvailable(matching, resource, filters, searchKey);
+ return this.loadAvailable(matching || '', resource, filters, searchKey);
}
}
}
// A method for returning data based on a custom URL (i.e. in time logging we have a special endpoint for retrieving
// work packages)
- public loadFromUrl(url:string, matching:string|null, resource:TOpAutocompleterResource, filters?:IAPIFilter[], searchKey?:string) {
+ public loadFromUrl(url:string, matching:string|null, resource:TOpAutocompleterResource, filters?:IAPIFilter[], searchKey?:string, allowEmpty:boolean = false) {
// Exit early if the query string is empty as there is no typeahead
- if (matching === null || matching.length === 0) {
+ if (!allowEmpty && (matching === null || matching.length === 0)) {
return of([]);
}
- const finalFilters:ApiV3FilterBuilder = this.createFilters(filters ?? [], matching, searchKey);
+ const finalFilters:ApiV3FilterBuilder = this.createFilters(filters ?? [], matching || '', searchKey);
const params = this.createParams(resource);
const stringifiedBuiltOutUrl = addFiltersToPath(url, finalFilters, params).toString();
diff --git a/frontend/src/app/shared/components/autocompleter/time-entries-work-package-autocompleter/time-entries-work-package-autocompleter.component.ts b/frontend/src/app/shared/components/autocompleter/time-entries-work-package-autocompleter/time-entries-work-package-autocompleter.component.ts
index 90cae05b5d3..2acd1270451 100644
--- a/frontend/src/app/shared/components/autocompleter/time-entries-work-package-autocompleter/time-entries-work-package-autocompleter.component.ts
+++ b/frontend/src/app/shared/components/autocompleter/time-entries-work-package-autocompleter/time-entries-work-package-autocompleter.component.ts
@@ -141,6 +141,7 @@ export class TimeEntriesWorkPackageAutocompleterComponent extends OpAutocomplete
this.resource,
this.modeSpecificFilters,
this.searchKey,
+ (this.mode === 'recent'), // allow empty typeahead for recent page, as this will list most recent WPs
)
.pipe(map((workPackages) => this.sortValues(workPackages)));
}