[AAE-3199] - Add support for searchable content model properties (new search filters panel in the attach file widget) (#6134)

* Create new panel component and search refactoring

* Replace

* First refactoring - Fix global search and service injection issues

* More refactoring

* Fix service injection - create one new instance for content-node-selector component

* Avoid having more services extending BaseQueryBuilderService

* more refactoring, remove injecting the SearchQueryBuilderService from the content node selector service

* Fix build errors to launch unit tests

* Fix existing unit tests

* Fix wrong import and constructor injection comments

* Fix wrong import

* Fix comments

* Fix api compatibility

* Revert demo shell causing e2e fail

Co-authored-by: adomi <ardit.domi@alfresco.com>
This commit is contained in:
Maurizio Vitale
2020-10-01 09:11:23 +01:00
committed by GitHub
parent f0af0c4113
commit 7c83f2eb18
20 changed files with 515 additions and 234 deletions

View File

@@ -15,7 +15,17 @@
* limitations under the License.
*/
import { Component, EventEmitter, Input, OnInit, Output, ViewChild, ViewEncapsulation, OnDestroy } from '@angular/core';
import {
Component,
EventEmitter,
Input,
OnInit,
Output,
ViewChild,
ViewEncapsulation,
OnDestroy,
Inject
} from '@angular/core';
import {
HighlightDirective,
UserPreferencesService,
@@ -37,6 +47,8 @@ import { debounceTime, takeUntil, scan } from 'rxjs/operators';
import { CustomResourcesService } from '../document-list/services/custom-resources.service';
import { NodeEntryEvent, ShareDataRow } from '../document-list';
import { Subject } from 'rxjs';
import { SEARCH_QUERY_SERVICE_TOKEN } from '../search/search-query-service.token';
import { SearchQueryBuilderService } from '../search/search-query-builder.service';
export type ValidationFunction = (entry: Node) => boolean;
@@ -47,7 +59,11 @@ export const defaultValidation = () => true;
styleUrls: ['./content-node-selector-panel.component.scss'],
templateUrl: './content-node-selector-panel.component.html',
encapsulation: ViewEncapsulation.None,
host: { 'class': 'adf-content-node-selector-panel' }
host: { 'class': 'adf-content-node-selector-panel' },
providers: [{
provide: SEARCH_QUERY_SERVICE_TOKEN,
useClass: SearchQueryBuilderService
}]
})
export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
@@ -230,6 +246,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
constructor(private contentNodeSelectorService: ContentNodeSelectorService,
private customResourcesService: CustomResourcesService,
@Inject(SEARCH_QUERY_SERVICE_TOKEN) public queryBuilderService: SearchQueryBuilderService,
private userPreferencesService: UserPreferencesService,
private nodesApiService: NodesApiService,
private uploadService: UploadService,
@@ -253,6 +270,12 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
)
.subscribe(searchValue => this.search(searchValue));
this.queryBuilderService.executed
.pipe(takeUntil(this.onDestroy$))
.subscribe( (results: NodePaging) => {
this.showSearchResults(results);
});
this.userPreferencesService
.select(UserPreferenceValues.PaginationSize)
.pipe(takeUntil(this.onDestroy$))
@@ -421,15 +444,15 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
if (this.customResourcesService.hasCorrespondingNodeIds(this.siteId)) {
this.customResourcesService.getCorrespondingNodeIds(this.siteId)
.subscribe((nodeIds) => {
this.contentNodeSelectorService.search(this.searchTerm, this.siteId, this.pagination.skipCount, this.pagination.maxItems, nodeIds, this.showFiles)
.subscribe(this.showSearchResults.bind(this));
},
const query = this.contentNodeSelectorService.createQuery(this.searchTerm, this.siteId, this.pagination.skipCount, this.pagination.maxItems, nodeIds, this.showFiles);
this.queryBuilderService.execute(query);
},
() => {
this.showSearchResults({ list: { entries: [] } });
});
} else {
this.contentNodeSelectorService.search(this.searchTerm, this.siteId, this.pagination.skipCount, this.pagination.maxItems, [], this.showFiles)
.subscribe(this.showSearchResults.bind(this));
const query = this.contentNodeSelectorService.createQuery(this.searchTerm, this.siteId, this.pagination.skipCount, this.pagination.maxItems, [], this.showFiles);
this.queryBuilderService.execute(query);
}
}