From ca3e1035faf93d0afc7dc0e8f357817710db0917 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Fri, 2 Nov 2018 23:14:51 +0000 Subject: [PATCH] fix search result pagination in demo shell (#3942) --- demo-shell/src/app.config.json | 11 +++++++++++ .../app/components/search/search-result.component.ts | 11 ++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/demo-shell/src/app.config.json b/demo-shell/src/app.config.json index 4ffe3360e0..2ddf953412 100644 --- a/demo-shell/src/app.config.json +++ b/demo-shell/src/app.config.json @@ -68,6 +68,17 @@ } ], "search": { + "app:fields": [ + "cm:name", + "cm:title", + "cm:description", + "ia:whatEvent", + "ia:descriptionEvent", + "lnk:title", + "lnk:description", + "TEXT", + "TAG" + ], "include": ["path", "allowableOperations"], "sorting": { "options": [ diff --git a/demo-shell/src/app/components/search/search-result.component.ts b/demo-shell/src/app/components/search/search-result.component.ts index ecd8de04b1..d8aeebc668 100644 --- a/demo-shell/src/app/components/search/search-result.component.ts +++ b/demo-shell/src/app/components/search/search-result.component.ts @@ -19,7 +19,7 @@ import { Component, OnInit, Optional, OnDestroy } from '@angular/core'; import { Router, ActivatedRoute, Params } from '@angular/router'; import { NodePaging, Pagination } from 'alfresco-js-api'; import { SearchQueryBuilderService } from '@alfresco/adf-content-services'; -import { UserPreferencesService, SearchService } from '@alfresco/adf-core'; +import { UserPreferencesService, SearchService, AppConfigService } from '@alfresco/adf-core'; import { Subscription } from 'rxjs'; @Component({ @@ -41,6 +41,7 @@ export class SearchResultComponent implements OnInit, OnDestroy { private subscriptions: Subscription[] = []; constructor(public router: Router, + private config: AppConfigService, private preferences: UserPreferencesService, private queryBuilder: SearchQueryBuilderService, @Optional() private route: ActivatedRoute) { @@ -61,6 +62,8 @@ export class SearchResultComponent implements OnInit, OnDestroy { }), this.queryBuilder.executed.subscribe(data => { + this.queryBuilder.paging.skipCount = 0; + this.onSearchResultLoaded(data); this.isLoading = false; }) @@ -87,10 +90,8 @@ export class SearchResultComponent implements OnInit, OnDestroy { return null; } - const suffix = userInput.lastIndexOf('*') >= 0 ? '' : '*'; - const query = `cm:name:${userInput}${suffix} OR cm:title:${userInput}${suffix} OR cm:description:${userInput}${suffix} - OR ia:whatEvent:${userInput}${suffix} OR ia:descriptionEvent:${userInput}${suffix} OR lnk:title:${userInput}${suffix} - OR lnk:description:${userInput}${suffix} OR TEXT:${userInput}${suffix} OR TAG:${userInput}${suffix}`; + const fields = this.config.get('search.app:fields', ['cm:name']); + const query = fields.map(field => `${field}:"${userInput}*"`).join(' OR '); return query; }