[ADF-3292] fix reset to defaults (#3566)

* fix reset to defaults

* code fixes

* restore providers

* fix category filtering
This commit is contained in:
Denys Vuika
2018-07-06 10:03:32 +01:00
committed by Eugenio Romano
parent 75e27ccb36
commit 6508b145d0

View File

@@ -55,26 +55,18 @@ export class SearchQueryBuilderService {
// TODO: to be supported in future iterations // TODO: to be supported in future iterations
ranges: { [id: string]: SearchRange } = {}; ranges: { [id: string]: SearchRange } = {};
constructor(appConfig: AppConfigService, private alfrescoApiService: AlfrescoApiService) { constructor(private appConfig: AppConfigService, private alfrescoApiService: AlfrescoApiService) {
this.config = appConfig.get<SearchConfiguration>('search');
this.resetToDefaults(); this.resetToDefaults();
} }
resetToDefaults() { resetToDefaults() {
if (this.config) { const template = this.appConfig.get<SearchConfiguration>('search');
this.categories = if (template) {
(this.config.categories || []) this.config = JSON.parse(JSON.stringify(template));
.filter(category => category.enabled) this.categories = (this.config.categories || []).filter(category => category.enabled);
.map(category => { return { ...category }; }); this.filterQueries = this.config.filterQueries || [];
this.filterQueries =
(this.config.filterQueries || [])
.map(query => { return {...query}; });
if (this.config.sorting) { if (this.config.sorting) {
this.sorting = this.sorting = this.config.sorting.defaults || [];
(this.config.sorting.defaults || [])
.map(sorting => { return { ...sorting }; });
} }
} }
} }