diff --git a/apps/red-ui/src/app/modules/search/search-screen/search-screen.component.ts b/apps/red-ui/src/app/modules/search/search-screen/search-screen.component.ts index 5c360fbef..5610feadb 100644 --- a/apps/red-ui/src/app/modules/search/search-screen/search-screen.component.ts +++ b/apps/red-ui/src/app/modules/search/search-screen/search-screen.component.ts @@ -52,27 +52,7 @@ export class SearchScreenComponent extends ListingComponent imp { label: _('search-screen.cols.pages'), width: 'auto' }, ]; - readonly searchResults$ = combineLatest([this._queryChanged, this._filtersChanged$]).pipe( - tap(() => this._loadingService.start()), - tap(([query, [dossierIds, workflowStatus, assignee, dossierTemplateIds, onlyActive]]) => - this._updateNavigation(query, dossierIds, workflowStatus, assignee, dossierTemplateIds, onlyActive), - ), - switchMap(([query, [dossierIds, workflowStatus, assignee, dossierTemplateIds, onlyActive]]) => - this._platformSearchService.search({ - query, - dossierIds, - dossierTemplateIds, - workflowStatus, - assignee, - includeDeletedDossiers: false, - includeArchivedDossiers: !onlyActive, - }), - ), - map(searchResult => this._toMatchedDocuments(searchResult)), - map(docs => this._toListItems(docs)), - tap(result => this.entitiesService.setEntities(result)), - tap(() => this._loadingService.stop()), - ); + readonly searchResults$ = new Observable(); readonly dossierTemplates$ = this._dossierTemplateService.loadAll().pipe(tap(templates => this._addTemplateFilter(templates))); @@ -90,6 +70,30 @@ export class SearchScreenComponent extends ListingComponent imp private readonly _userService: UserService, ) { super(); + if (!Object.keys(this._activatedRoute.snapshot.queryParams).length) { + this._router.navigate(['main']).then(); + } + this.searchResults$ = combineLatest([this._queryChanged$, this._filtersChanged$]).pipe( + tap(() => this._loadingService.start()), + tap(([query, [dossierIds, workflowStatus, assignee, dossierTemplateIds, onlyActive]]) => + this._updateNavigation(query, dossierIds, workflowStatus, assignee, dossierTemplateIds, onlyActive), + ), + switchMap(([query, [dossierIds, workflowStatus, assignee, dossierTemplateIds, onlyActive]]) => + this._platformSearchService.search({ + query, + dossierIds, + dossierTemplateIds, + workflowStatus, + assignee, + includeDeletedDossiers: false, + includeArchivedDossiers: !onlyActive, + }), + ), + map(searchResult => this._toMatchedDocuments(searchResult)), + map(docs => this._toListItems(docs)), + tap(result => this.entitiesService.setEntities(result)), + tap(() => this._loadingService.stop()), + ); this.searchService.skip = true; this.sortingService.setSortingOption({ column: 'searchKey', order: SortingOrders.desc }); this._initFilters(); @@ -119,7 +123,7 @@ export class SearchScreenComponent extends ListingComponent imp return this._activatedRoute.snapshot.queryParamMap.get('query'); } - private get _queryChanged(): Observable { + private get _queryChanged$(): Observable { return this.searchService.valueChanges$.pipe( startWith(this._routeQuery), tap(query => (this.searchService.searchValue = query)),