diff --git a/client/src/app/site/modules/global-headbar/components/global-search/global-search.component.ts b/client/src/app/site/modules/global-headbar/components/global-search/global-search.component.ts
index 1e9275edf1..3c63c7e6d0 100644
--- a/client/src/app/site/modules/global-headbar/components/global-search/global-search.component.ts
+++ b/client/src/app/site/modules/global-headbar/components/global-search/global-search.component.ts
@@ -63,12 +63,10 @@ export class GlobalSearchComponent implements OnDestroy {
this.updateCurrentlyAvailableFilters();
this.filterChangeSubscription = this.currentFilters.valueChanges
.pipe(startWith(this.currentFilters.value), pairwise())
- .subscribe(([last, next]) => {
- if (last.meetingFilter !== next.meetingFilter) {
+ .subscribe(() => {
+ if (this.searchTerm) {
this.searchChange();
}
-
- this.updateFilteredResults();
});
}
@@ -76,12 +74,8 @@ export class GlobalSearchComponent implements OnDestroy {
this.filterChangeSubscription.unsubscribe();
}
- public getPermissionByFilter(filter: string): Permission {
- if (filter === `topic`) {
- return Permission.agendaItemCanSee;
- }
-
- return (filter + `.can_see`) as Permission;
+ public hasFilterPermission(filter: string): boolean {
+ return !this.activeMeeting.meetingId || this.operator.hasPerms(this.getPermissionByFilter(filter));
}
public async searchChange(): Promise {
@@ -96,8 +90,13 @@ export class GlobalSearchComponent implements OnDestroy {
this.cd.markForCheck();
try {
+ const filters =
+ this.currentFilters.get(`meetingFilter`).getRawValue() === `meetings`
+ ? [`meeting`]
+ : this.selectedFilters();
const search = await this.globalSearchService.searchChange(
this.searchTerm,
+ filters,
this.currentlyAvailableFilters,
searchMeeting
);
@@ -179,6 +178,24 @@ export class GlobalSearchComponent implements OnDestroy {
return resultText;
}
+ private getPermissionByFilter(filter: string): Permission {
+ if (filter === `topic`) {
+ return Permission.agendaItemCanSee;
+ }
+
+ return (filter + `.can_see`) as Permission;
+ }
+
+ private selectedFilters(): string[] {
+ const filters = [];
+ for (const filter of this.currentlyAvailableFilters) {
+ if (this.currentFilters.get(filter) && this.currentFilters.get(filter).getRawValue()) {
+ filters.push(filter);
+ }
+ }
+ return filters;
+ }
+
private updateFilteredResults(): void {
this.filteredResults = [];
let allUnchecked = true;
diff --git a/client/src/app/site/services/global-search/global-search.service.ts b/client/src/app/site/services/global-search/global-search.service.ts
index 5d924d2f5c..3f52d4cc44 100644
--- a/client/src/app/site/services/global-search/global-search.service.ts
+++ b/client/src/app/site/services/global-search/global-search.service.ts
@@ -14,6 +14,7 @@ export class GlobalSearchService {
public async searchChange(
searchTerm: string,
+ reqCollections: string[] = [],
collections: string[] = [],
meeting?: Id
): Promise<{ resultList: GlobalSearchEntry[]; models: GlobalSearchResponse }> {
@@ -21,10 +22,13 @@ export class GlobalSearchService {
return { resultList: [], models: {} };
}
- const params: { q: string; m?: string } = { q: searchTerm };
+ const params: { q: string; c?: string; m?: string } = { q: searchTerm };
if (meeting) {
params.m = meeting.toString();
}
+ if (reqCollections && reqCollections.length) {
+ params.c = reqCollections.join(`,`);
+ }
const rawResults: GlobalSearchResponse = await this.http.get(`/system/search`, null, params);
@@ -101,6 +105,12 @@ export class GlobalSearchService {
const content = results[fqid].content;
const collection = collectionFromFqid(fqid);
const id = content.sequential_number || idFromFqid(fqid);
+ let meeting = null;
+ if (content.meeting_id) {
+ meeting = results[`meeting/${content.meeting_id}`]?.content;
+ } else if (content.owner_id && content.owner_id.startsWith(`meeting`)) {
+ meeting = results[content.owner_id]?.content;
+ }
return {
title: this.getTitle(collection, content),
@@ -109,7 +119,7 @@ export class GlobalSearchService {
fqid,
collection,
url: this.getUrl(collection, id, content),
- meeting: results[`meeting/${content.meeting_id}`]?.content,
+ meeting,
committee: results[`committee/${content.committee_id}`]?.content,
score: results[fqid].score || 0
};