[ADF-2128] facet container component (#3094)

* (wip) facet container

* shaping out the API

* code lint fixes

* radiobox facet example

* fields selector facet

* search limits support

* scope locations facet example

* move custom search to 'search.query' config

* use facet fields and queries from the config file

* use facet filters

* use facet buckets in query

* preserve expanded/checked states

* code cleanup and binding fixes

* fix apis after rebase

* extract query builder into separate class

* code improvements

* full chip list (merge facet fields with queries)

* placeholder for range requests

* move search infrastructure to ADF core

* cleanup code

* auto-search on init

* move search components to the content services

* selected facets chip list

* split into separate components at ADF level

* move the rest of the implementation to ADF

* facet builder fixes and tests

* translation support for category names

* docs placeholders

* update language level

* unit tests and packaging updates

* fix after rebase

* remove fdescribe

* some docs on search settings

* rename components as per review

* simplify chip list as per review

* turn query builder into service

* improve search service, integrate old search results

* fix node selector integration

* move service to the top module

* update tests

* remove fdescribe

* update tests

* test fixes

* test fixes

* test updates

* fix tests

* code and test fixes

* remove fit

* fix tests

* fix tests

* remove obsolete test

* increase bundle threshold

* update docs to reflect PR changes

* fix docs
This commit is contained in:
Denys Vuika
2018-03-29 11:34:09 +01:00
committed by Eugenio Romano
parent d6f51c22aa
commit ed48994e67
59 changed files with 2328 additions and 183 deletions

View File

@@ -17,45 +17,41 @@
import { Injectable } from '@angular/core';
import { NodePaging, QueryBody } from 'alfresco-js-api';
import { Observable } from 'rxjs/Observable';
import { AlfrescoApiService } from './alfresco-api.service';
import { AuthenticationService } from './authentication.service';
import 'rxjs/add/observable/throw';
import { Subject } from 'rxjs/Subject';
import { AlfrescoApiService } from './alfresco-api.service';
import { SearchConfigurationService } from './search-configuration.service';
@Injectable()
export class SearchService {
constructor(public authService: AuthenticationService,
private apiService: AlfrescoApiService,
dataLoaded: Subject<NodePaging> = new Subject();
constructor(private apiService: AlfrescoApiService,
private searchConfigurationService: SearchConfigurationService) {
}
getNodeQueryResults(term: string, options?: SearchOptions): Observable<NodePaging> {
return Observable.fromPromise(this.apiService.getInstance().core.queriesApi.findNodes(term, options))
.map(res => <NodePaging> res)
.catch(err => this.handleError(err));
async getNodeQueryResults(term: string, options?: SearchOptions): Promise<NodePaging> {
const data = await this.apiService.getInstance().core.queriesApi.findNodes(term, options);
this.dataLoaded.next(data);
return data;
}
search(searchTerm: string, maxResults: number, skipCount: number): Observable<NodePaging> {
const searchQuery = Object.assign(this.searchConfigurationService.generateQueryBody(searchTerm, maxResults, skipCount));
const promise = this.apiService.getInstance().search.searchApi.search(searchQuery);
async search(searchTerm: string, maxResults: number, skipCount: number): Promise<NodePaging> {
const searchQuery = this.searchConfigurationService.generateQueryBody(searchTerm, maxResults, skipCount);
const data = await this.apiService.searchApi.search(searchQuery);
return Observable
.fromPromise(promise)
.catch(err => this.handleError(err));
this.dataLoaded.next(data);
return data;
}
searchByQueryBody(queryBody: QueryBody): Observable<NodePaging> {
const promise = this.apiService.getInstance().search.searchApi.search(queryBody);
async searchByQueryBody(queryBody: QueryBody): Promise<NodePaging> {
const data = await this.apiService.searchApi.search(queryBody);
return Observable
.fromPromise(promise)
.catch(err => this.handleError(err));
}
private handleError(error: any): Observable<any> {
return Observable.throw(error || 'Server error');
this.dataLoaded.next(data);
return data;
}
}