diff --git a/apps/red-ui/src/app/modules/dossier/screens/search-screen/search-screen.component.html b/apps/red-ui/src/app/modules/dossier/screens/search-screen/search-screen.component.html index c7bee84cf..9bf89fde2 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/search-screen/search-screen.component.html +++ b/apps/red-ui/src/app/modules/dossier/screens/search-screen/search-screen.component.html @@ -50,7 +50,7 @@ > {{ term }}. {{ 'search-screen.must-contain' | translate }}:  {{ term }} diff --git a/apps/red-ui/src/app/modules/dossier/screens/search-screen/search-screen.component.ts b/apps/red-ui/src/app/modules/dossier/screens/search-screen/search-screen.component.ts index ca841e50a..6ed63f012 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/search-screen/search-screen.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/search-screen/search-screen.component.ts @@ -30,6 +30,11 @@ interface ListItem { readonly numberOfPages: number; } +interface SearchInput { + query: string; + dossierIds?: string[]; +} + @Component({ templateUrl: './search-screen.component.html', styleUrls: ['./search-screen.component.scss'], @@ -40,7 +45,7 @@ export class SearchScreenComponent extends BaseListingComponent implem readonly searchPositions = searchPositions; readonly itemSize = 85; - readonly search$ = new BehaviorSubject(null); + readonly search$ = new BehaviorSubject(null); readonly searchResults$: Observable = this.search$.asObservable().pipe( switchMap(query => this._search(query)), map(searchResult => this._toMatchedDocuments(searchResult)), @@ -64,7 +69,6 @@ export class SearchScreenComponent extends BaseListingComponent implem ]; protected readonly _primaryKey = 'fileName'; protected readonly _tableHeaderLabel = _('search-screen.table-header'); - private _dossierId: string; constructor( protected readonly _injector: Injector, @@ -100,9 +104,10 @@ export class SearchScreenComponent extends BaseListingComponent implem .valueChanges.pipe(debounceTime(300)) .subscribe(value => this.updateNavigation(value)); - this.addSubscription = this.filterService.filterGroups$ - .pipe(skip(1)) - .subscribe(() => this.updateNavigation(this.search$.getValue())); + this.addSubscription = this.filterService.filterGroups$.pipe(skip(1)).subscribe(filters => { + const dossierIds = filters[0].values.filter(v => v.checked).map(v => v.key); + this.search$.next({ query: this.searchService.searchValue, dossierIds: dossierIds }); + }); } setInitialConfig() { @@ -115,21 +120,22 @@ export class SearchScreenComponent extends BaseListingComponent implem this._router.navigate([], { queryParams }).then(); } - private _search(query: string): Observable { + private _search(searchInput: SearchInput): Observable { return this._searchControllerService.search({ - dossierId: this._dossierId, - queryString: query ?? '', - from: 0, + dossierIds: searchInput.dossierIds, + queryString: searchInput.query ?? '', + page: 1, returnSections: false, - size: 100 + pageSize: 300 }); } private _updateValues({ query, dossierId }: { readonly query: string; readonly dossierId: string }) { - if (dossierId) this.filterService.toggleFilter('dossiers', dossierId); - this._dossierId = dossierId; + if (dossierId) { + this.filterService.toggleFilter('dossiers', dossierId); + } this.searchService.searchValue = query; - this.search$.next(query); + this.search$.next({ query, dossierIds: dossierId ? [dossierId] : [] }); } private _getFileWrapper(dossierId: string, fileId: string): FileStatusWrapper { diff --git a/apps/red-ui/src/app/services/user.service.ts b/apps/red-ui/src/app/services/user.service.ts index 95cc5886d..fe54e6647 100644 --- a/apps/red-ui/src/app/services/user.service.ts +++ b/apps/red-ui/src/app/services/user.service.ts @@ -123,9 +123,13 @@ export class UserService { } async loadAllUsers() { - this._allUsers = (await this._userControllerService.getAllUsers().toPromise()).map( - user => new UserWrapper(user, user.roles, user.userId) - ); + let allUsers = []; + if (this._currentUser.isUserAdmin) { + allUsers = await this._userControllerService.getAllUsers().toPromise(); + } else { + allUsers = await this._userControllerService.getUsers().toPromise(); + } + this._allUsers = allUsers.map(user => new UserWrapper(user, user.roles, user.userId)); this._allRedUsers = this._allUsers.filter(u => UserService._hasAnyRedRole(u)); this.usersReloaded$.next(); return this._allUsers; diff --git a/libs/red-ui-http/src/lib/model/searchRequest.ts b/libs/red-ui-http/src/lib/model/searchRequest.ts index 9391dd6ad..d1152c782 100644 --- a/libs/red-ui-http/src/lib/model/searchRequest.ts +++ b/libs/red-ui-http/src/lib/model/searchRequest.ts @@ -11,10 +11,11 @@ */ export interface SearchRequest { - dossierId?: string; + dossierIds?: string[]; + dossierTemplateIds?: string[]; fileId?: string; - from?: number; + page?: number; + pageSize?: number; queryString?: string; returnSections?: boolean; - size?: number; }