diff --git a/docs/extending/application-features.md b/docs/extending/application-features.md index 0abb8619d..3fdf47e9a 100644 --- a/docs/extending/application-features.md +++ b/docs/extending/application-features.md @@ -15,6 +15,7 @@ The ACA supports the following set of extension points: - Viewer - Sidebar (aka Info Drawer) - Content metadata presets (for `Properties` tab) +- Search All the customizations are stored in the `features` section of the configuration file: @@ -699,3 +700,202 @@ Here is the initial setting from `app.extension.json`: **Tip:** In order to allow the content-metadata presets to be extended, the settings from `app.config.json` must be copied to the `app.extensions.json` file and its ids must be added to all the items. Having ids allows external plugins to extend the current setting. + +## Search + +The search configurations are needed by the [Search Filter Component](https://www.alfresco.com/abn/adf/docs/content-services/components/search-filter.component/) to render the filters. +This is can be configured either in `app.config.json` or `app.extensions.json`. + +Configuring search from `app.extensions.json` will overwrite/update the application search. +Settings them from custom plugins allows user to disable, update or extend. + +```json + { + "search": { + "id": "app.search-extension", + "order": 100, + "name": "APP.BROWSE.SEARCH.DEFAULT_SEARCH", + "default": true, + "filterWithContains": true, + "aca:fields": ["cm:name", "cm:title", "cm:description", "TEXT", "TAG"], + "include": ["path", "allowableOperations", "properties"], + "sorting": { + "options": [ + { + "key": "score", + "label": "SEARCH.SORT.RELEVANCE", + "type": "SCORE", + "field": "score", + "ascending": false + }, + { + "key": "name", + "label": "SEARCH.SORT.FILENAME", + "type": "FIELD", + "field": "cm:name", + "ascending": true + }, + { + "key": "title", + "label": "SEARCH.SORT.TITLE", + "type": "FIELD", + "field": "cm:title", + "ascending": true + }, + { + "key": "modified", + "label": "SEARCH.SORT.MODIFIED_DATE", + "type": "FIELD", + "field": "cm:modified", + "ascending": true + }, + { + "key": "modifier", + "label": "SEARCH.SORT.MODIFIER", + "type": "FIELD", + "field": "cm:modifier", + "ascending": true + }, + { + "key": "created", + "label": "SEARCH.SORT.CREATE_DATE", + "type": "FIELD", + "field": "cm:created", + "ascending": true + }, + { + "key": "content.sizeInBytes", + "label": "SEARCH.SORT.SIZE", + "type": "FIELD", + "field": "content.size", + "ascending": true + }, + { + "key": "content.mimetype", + "label": "SEARCH.SORT.TYPE", + "type": "FIELD", + "field": "content.mimetype", + "ascending": true + } + ], + "defaults": [ + { + "key": "score", + "type": "SCORE", + "field": "score", + "ascending": false + } + ] + }, + "aca:triggeredOnChange": false, + "resetButton": true, + "filterQueries": [ + { "query": "+TYPE:'cm:folder' OR +TYPE:'cm:content'" }, + { + "query": "-TYPE:'cm:thumbnail' AND -TYPE:'cm:failedThumbnail' AND -TYPE:'cm:rating'" + }, + { "query": "-cm:creator:System AND -QNAME:comment" }, + { + "query": "-TYPE:'st:site' AND -ASPECT:'st:siteContainer' AND -ASPECT:'sys:hidden'" + }, + { + "query": "-TYPE:'dl:dataList' AND -TYPE:'dl:todoList' AND -TYPE:'dl:issue'" + }, + { "query": "-TYPE:'fm:topic' AND -TYPE:'fm:post'" }, + { "query": "-TYPE:'lnk:link'" }, + { "query": "-PNAME:'0/wiki'" } + ], + "facetFields": { + "expanded": true, + "fields": [ + { + "mincount": 1, + "field": "content.mimetype", + "label": "SEARCH.FACET_FIELDS.FILE_TYPE", + "settings": { + "allowUpdateOnChange": false, + "hideDefaultAction": true + } + } + ] + }, + "facetQueries": { + "label": "SEARCH.CATEGORIES.MODIFIED_DATE", + "expanded": true, + "queries": [ + { + "label": "SEARCH.FACET_QUERIES.TODAY", + "query": "cm:modified:[TODAY to TODAY]" + }, + { + "label": "SEARCH.FACET_QUERIES.THIS_WEEK", + "query": "cm:modified:[NOW/DAY-7DAYS TO NOW/DAY+1DAY]" + }, + { + "label": "SEARCH.FACET_QUERIES.THIS_MONTH", + "query": "cm:modified:[NOW/DAY-1MONTH TO NOW/DAY+1DAY]" + }, + { + "label": "SEARCH.FACET_QUERIES.LAST_6_MONTHS", + "query": "cm:modified:[NOW/DAY-6MONTHS TO NOW/DAY+1DAY]" + }, + { + "label": "SEARCH.FACET_QUERIES.THIS_YEAR", + "query": "cm:modified:[NOW/DAY-1YEAR TO NOW/DAY+1DAY]" + } + ], + "settings": { + "allowUpdateOnChange": false, + "hideDefaultAction": true + } + }, + "categories": [ + { + "id": "size", + "name": "SEARCH.CATEGORIES.SIZE", + "enabled": true, + "component": { + "selector": "check-list", + "settings": { + "allowUpdateOnChange": false, + "hideDefaultAction": true, + "options": [ + { + "name": "SEARCH.CATEGORIES.SIZE_OPTIONS.SMALL", + "value": "content.size:[0 TO 1048576>" + }, + { + "name": "SEARCH.CATEGORIES.SIZE_OPTIONS.MEDIUM", + "value": "content.size:[1048576 TO 52428800]" + }, + { + "name": "SEARCH.CATEGORIES.SIZE_OPTIONS.LARGE", + "value": "content.size:<52428800 TO 524288000]" + }, + { + "name": "SEARCH.CATEGORIES.SIZE_OPTIONS.HUGE", + "value": "content.size:<524288000 TO MAX]" + } + ] + } + } + }, + { + "id": "createdDateRange", + "name": "SEARCH.CATEGORIES.CREATED_DATE", + "enabled": true, + "component": { + "selector": "date-range", + "settings": { + "allowUpdateOnChange": false, + "hideDefaultAction": true, + "field": "cm:created", + "dateFormat": "DD-MMM-YY", + "maxDate": "today" + } + } + } + ] + } + } +``` diff --git a/projects/aca-shared/src/lib/services/app.extension.service.spec.ts b/projects/aca-shared/src/lib/services/app.extension.service.spec.ts index db4f4e618..5c0f6329c 100644 --- a/projects/aca-shared/src/lib/services/app.extension.service.spec.ts +++ b/projects/aca-shared/src/lib/services/app.extension.service.spec.ts @@ -873,4 +873,59 @@ describe('AppExtensionService', () => { expect(actions.children[1].id).toBe('header.action.1'); }); }); + + describe('search', () => { + beforeEach(() => { + applyConfig({ + $id: 'test', + $name: 'test', + $version: '1.0.0', + $license: 'MIT', + $vendor: 'Good company', + $runtime: '1.5.0', + features: { + search: [ + { + id: 'app.search', + order: 100, + name: 'default', + default: true, + filterWithContains: true, + 'aca:fields': ['cm:name', 'cm:title', 'cm:description', 'TEXT', 'TAG'], + include: ['path', 'allowableOperations', 'properties'], + categories: [ + { + id: 'size', + name: 'SEARCH.CATEGORIES.SIZE', + enabled: true + } + ] + }, + { + id: 'app.search-1', + order: 200, + name: 'default', + default: false + }, + { + id: 'app.search-2', + order: 200, + name: 'default', + disabled: true + } + ] + } + }); + }); + + it('should load the search extension', () => { + expect(service.search.length).toBe(2); + expect(service.search[0].id).toBe('app.search'); + expect(service.search[1].id).toBe('app.search-1'); + }); + + it('should not load the disabled search extension', () => { + expect(service.search.find(({ id }) => id === 'app.search-2')).toBe(undefined, 'disabled configuration shown in the result'); + }); + }); }); diff --git a/projects/aca-shared/src/lib/services/app.extension.service.ts b/projects/aca-shared/src/lib/services/app.extension.service.ts index 2c99ed415..edbfdc0b6 100644 --- a/projects/aca-shared/src/lib/services/app.extension.service.ts +++ b/projects/aca-shared/src/lib/services/app.extension.service.ts @@ -47,7 +47,8 @@ import { ExtensionRef, RuleContext, DocumentListPresetRef, - IconRef + IconRef, + mergeArrays } from '@alfresco/adf-extensions'; import { AppConfigService, AuthenticationService, LogService } from '@alfresco/adf-core'; import { BehaviorSubject, Observable } from 'rxjs'; @@ -73,6 +74,7 @@ export class AppExtensionService implements RuleContext { sidebarTabs: Array = []; sidebarActions: Array = []; contentMetadata: any; + search: any; viewerRules: ViewerRules = {}; settingGroups: Array = []; @@ -150,6 +152,7 @@ export class AppExtensionService implements RuleContext { this.navbar = this.loadNavBar(config); this.sidebarTabs = this.loader.getElements(config, 'features.sidebar.tabs'); this.contentMetadata = this.loadContentMetadata(config); + this.search = this.loadSearchForms(config); this.documentListPresets = { files: this.getDocumentListPreset(config, 'files'), @@ -286,6 +289,25 @@ export class AppExtensionService implements RuleContext { return { presets }; } + loadSearchForms(config: ExtensionConfig): any { + const elements = this.loader.getElements(config, 'features.search'); + if (!elements.length) { + return null; + } + + let search = []; + search = mergeArrays(search, elements) + .filter((entry) => !entry.disabled) + .sort(sortByOrder); + + try { + this.appConfig.config['search'] = search; + } catch (error) { + this.logger.error(error, '- could not change search from app.config -'); + } + return search; + } + filterDisabled(object: Array<{ disabled: boolean }> | { disabled: boolean }) { if (Array.isArray(object)) { return object.filter((item) => !item.disabled).map((item) => this.filterDisabled(item)); diff --git a/src/app.config.json b/src/app.config.json index f67a46c52..9079f750c 100644 --- a/src/app.config.json +++ b/src/app.config.json @@ -189,217 +189,6 @@ "multi-value-pipe-separator": ", ", "multi-value-chips": true }, - "search": [{ - "filterWithContains": true, - "aca:fields": ["cm:name", "cm:title", "cm:description", "TEXT", "TAG"], - "include": ["path", "allowableOperations", "properties"], - "sorting": { - "options": [ - { - "key": "score", - "label": "SEARCH.SORT.RELEVANCE", - "type": "SCORE", - "field": "score", - "ascending": false - }, - { - "key": "name", - "label": "SEARCH.SORT.FILENAME", - "type": "FIELD", - "field": "cm:name", - "ascending": true - }, - { - "key": "title", - "label": "SEARCH.SORT.TITLE", - "type": "FIELD", - "field": "cm:title", - "ascending": true - }, - { - "key": "modified", - "label": "SEARCH.SORT.MODIFIED_DATE", - "type": "FIELD", - "field": "cm:modified", - "ascending": true - }, - { - "key": "modifier", - "label": "SEARCH.SORT.MODIFIER", - "type": "FIELD", - "field": "cm:modifier", - "ascending": true - }, - { - "key": "created", - "label": "SEARCH.SORT.CREATE_DATE", - "type": "FIELD", - "field": "cm:created", - "ascending": true - }, - { - "key": "content.sizeInBytes", - "label": "SEARCH.SORT.SIZE", - "type": "FIELD", - "field": "content.size", - "ascending": true - }, - { - "key": "content.mimetype", - "label": "SEARCH.SORT.TYPE", - "type": "FIELD", - "field": "content.mimetype", - "ascending": true - } - ], - "defaults": [ - { - "key": "score", - "type": "SCORE", - "field": "score", - "ascending": false - } - ] - }, - "aca:triggeredOnChange": false, - "resetButton": true, - "filterQueries": [ - { "query": "+TYPE:'cm:folder' OR +TYPE:'cm:content'" }, - { - "query": "-TYPE:'cm:thumbnail' AND -TYPE:'cm:failedThumbnail' AND -TYPE:'cm:rating'" - }, - { "query": "-cm:creator:System AND -QNAME:comment" }, - { - "query": "-TYPE:'st:site' AND -ASPECT:'st:siteContainer' AND -ASPECT:'sys:hidden'" - }, - { - "query": "-TYPE:'dl:dataList' AND -TYPE:'dl:todoList' AND -TYPE:'dl:issue'" - }, - { "query": "-TYPE:'fm:topic' AND -TYPE:'fm:post'" }, - { "query": "-TYPE:'lnk:link'" }, - { "query": "-PNAME:'0/wiki'" } - ], - "facetFields": { - "expanded": true, - "fields": [ - { - "mincount": 1, - "field": "content.mimetype", - "label": "SEARCH.FACET_FIELDS.FILE_TYPE", - "settings": { - "allowUpdateOnChange": false, - "hideDefaultAction": true - } - }, - { - "mincount": 1, - "field": "creator", - "label": "SEARCH.FACET_FIELDS.CREATOR", - "settings": { - "allowUpdateOnChange": false, - "hideDefaultAction": true - } - }, - { - "mincount": 1, - "field": "modifier", - "label": "SEARCH.FACET_FIELDS.MODIFIER", - "settings": { - "allowUpdateOnChange": false, - "hideDefaultAction": true - } - }, - { - "mincount": 1, - "field": "SITE", - "label": "SEARCH.FACET_FIELDS.LOCATION", - "settings": { - "allowUpdateOnChange": false, - "hideDefaultAction": true - } - } - ] - }, - "facetQueries": { - "label": "SEARCH.CATEGORIES.MODIFIED_DATE", - "expanded": true, - "queries": [ - { - "label": "SEARCH.FACET_QUERIES.TODAY", - "query": "cm:modified:[TODAY to TODAY]" - }, - { - "label": "SEARCH.FACET_QUERIES.THIS_WEEK", - "query": "cm:modified:[NOW/DAY-7DAYS TO NOW/DAY+1DAY]" - }, - { - "label": "SEARCH.FACET_QUERIES.THIS_MONTH", - "query": "cm:modified:[NOW/DAY-1MONTH TO NOW/DAY+1DAY]" - }, - { - "label": "SEARCH.FACET_QUERIES.LAST_6_MONTHS", - "query": "cm:modified:[NOW/DAY-6MONTHS TO NOW/DAY+1DAY]" - }, - { - "label": "SEARCH.FACET_QUERIES.THIS_YEAR", - "query": "cm:modified:[NOW/DAY-1YEAR TO NOW/DAY+1DAY]" - } - ], - "settings": { - "allowUpdateOnChange": false, - "hideDefaultAction": true - } - }, - "categories": [ - { - "id": "size", - "name": "SEARCH.CATEGORIES.SIZE", - "enabled": true, - "component": { - "selector": "check-list", - "settings": { - "allowUpdateOnChange": false, - "hideDefaultAction": true, - "options": [ - { - "name": "SEARCH.CATEGORIES.SIZE_OPTIONS.SMALL", - "value": "content.size:[0 TO 1048576>" - }, - { - "name": "SEARCH.CATEGORIES.SIZE_OPTIONS.MEDIUM", - "value": "content.size:[1048576 TO 52428800]" - }, - { - "name": "SEARCH.CATEGORIES.SIZE_OPTIONS.LARGE", - "value": "content.size:<52428800 TO 524288000]" - }, - { - "name": "SEARCH.CATEGORIES.SIZE_OPTIONS.HUGE", - "value": "content.size:<524288000 TO MAX]" - } - ] - } - } - }, - { - "id": "createdDateRange", - "name": "SEARCH.CATEGORIES.CREATED_DATE", - "enabled": true, - "component": { - "selector": "date-range", - "settings": { - "allowUpdateOnChange": false, - "hideDefaultAction": true, - "field": "cm:created", - "dateFormat": "DD-MMM-YY", - "maxDate": "today" - } - } - } - ], - "name": "APP.BROWSE.SEARCH.DEFAULT_SEARCH", - "default": true - }], "search-headers": { "filterWithContains": true, "app:fields": [ diff --git a/src/assets/app.extensions.json b/src/assets/app.extensions.json index c81933ab0..9cce3e2a2 100644 --- a/src/assets/app.extensions.json +++ b/src/assets/app.extensions.json @@ -1178,6 +1178,221 @@ } ] }, + "search": [ + { + "id": "app.search.default", + "order": 100, + "filterWithContains": true, + "aca:fields": ["cm:name", "cm:title", "cm:description", "TEXT", "TAG"], + "include": ["path", "allowableOperations", "properties"], + "sorting": { + "options": [ + { + "key": "score", + "label": "SEARCH.SORT.RELEVANCE", + "type": "SCORE", + "field": "score", + "ascending": false + }, + { + "key": "name", + "label": "SEARCH.SORT.FILENAME", + "type": "FIELD", + "field": "cm:name", + "ascending": true + }, + { + "key": "title", + "label": "SEARCH.SORT.TITLE", + "type": "FIELD", + "field": "cm:title", + "ascending": true + }, + { + "key": "modified", + "label": "SEARCH.SORT.MODIFIED_DATE", + "type": "FIELD", + "field": "cm:modified", + "ascending": true + }, + { + "key": "modifier", + "label": "SEARCH.SORT.MODIFIER", + "type": "FIELD", + "field": "cm:modifier", + "ascending": true + }, + { + "key": "created", + "label": "SEARCH.SORT.CREATE_DATE", + "type": "FIELD", + "field": "cm:created", + "ascending": true + }, + { + "key": "content.sizeInBytes", + "label": "SEARCH.SORT.SIZE", + "type": "FIELD", + "field": "content.size", + "ascending": true + }, + { + "key": "content.mimetype", + "label": "SEARCH.SORT.TYPE", + "type": "FIELD", + "field": "content.mimetype", + "ascending": true + } + ], + "defaults": [ + { + "key": "score", + "type": "SCORE", + "field": "score", + "ascending": false + } + ] + }, + "aca:triggeredOnChange": false, + "resetButton": true, + "filterQueries": [ + { "query": "+TYPE:'cm:folder' OR +TYPE:'cm:content'" }, + { + "query": "-TYPE:'cm:thumbnail' AND -TYPE:'cm:failedThumbnail' AND -TYPE:'cm:rating'" + }, + { "query": "-cm:creator:System AND -QNAME:comment" }, + { + "query": "-TYPE:'st:site' AND -ASPECT:'st:siteContainer' AND -ASPECT:'sys:hidden'" + }, + { + "query": "-TYPE:'dl:dataList' AND -TYPE:'dl:todoList' AND -TYPE:'dl:issue'" + }, + { "query": "-TYPE:'fm:topic' AND -TYPE:'fm:post'" }, + { "query": "-TYPE:'lnk:link'" }, + { "query": "-PNAME:'0/wiki'" } + ], + "facetFields": { + "expanded": true, + "fields": [ + { + "mincount": 1, + "field": "content.mimetype", + "label": "SEARCH.FACET_FIELDS.FILE_TYPE", + "settings": { + "allowUpdateOnChange": false, + "hideDefaultAction": true + } + }, + { + "mincount": 1, + "field": "creator", + "label": "SEARCH.FACET_FIELDS.CREATOR", + "settings": { + "allowUpdateOnChange": false, + "hideDefaultAction": true + } + }, + { + "mincount": 1, + "field": "modifier", + "label": "SEARCH.FACET_FIELDS.MODIFIER", + "settings": { + "allowUpdateOnChange": false, + "hideDefaultAction": true + } + }, + { + "mincount": 1, + "field": "SITE", + "label": "SEARCH.FACET_FIELDS.LOCATION", + "settings": { + "allowUpdateOnChange": false, + "hideDefaultAction": true + } + } + ] + }, + "facetQueries": { + "label": "SEARCH.CATEGORIES.MODIFIED_DATE", + "expanded": true, + "queries": [ + { + "label": "SEARCH.FACET_QUERIES.TODAY", + "query": "cm:modified:[TODAY to TODAY]" + }, + { + "label": "SEARCH.FACET_QUERIES.THIS_WEEK", + "query": "cm:modified:[NOW/DAY-7DAYS TO NOW/DAY+1DAY]" + }, + { + "label": "SEARCH.FACET_QUERIES.THIS_MONTH", + "query": "cm:modified:[NOW/DAY-1MONTH TO NOW/DAY+1DAY]" + }, + { + "label": "SEARCH.FACET_QUERIES.LAST_6_MONTHS", + "query": "cm:modified:[NOW/DAY-6MONTHS TO NOW/DAY+1DAY]" + }, + { + "label": "SEARCH.FACET_QUERIES.THIS_YEAR", + "query": "cm:modified:[NOW/DAY-1YEAR TO NOW/DAY+1DAY]" + } + ], + "settings": { + "allowUpdateOnChange": false, + "hideDefaultAction": true + } + }, + "categories": [ + { + "id": "size", + "name": "SEARCH.CATEGORIES.SIZE", + "enabled": true, + "component": { + "selector": "check-list", + "settings": { + "allowUpdateOnChange": false, + "hideDefaultAction": true, + "options": [ + { + "name": "SEARCH.CATEGORIES.SIZE_OPTIONS.SMALL", + "value": "content.size:[0 TO 1048576>" + }, + { + "name": "SEARCH.CATEGORIES.SIZE_OPTIONS.MEDIUM", + "value": "content.size:[1048576 TO 52428800]" + }, + { + "name": "SEARCH.CATEGORIES.SIZE_OPTIONS.LARGE", + "value": "content.size:<52428800 TO 524288000]" + }, + { + "name": "SEARCH.CATEGORIES.SIZE_OPTIONS.HUGE", + "value": "content.size:<524288000 TO MAX]" + } + ] + } + } + }, + { + "id": "createdDateRange", + "name": "SEARCH.CATEGORIES.CREATED_DATE", + "enabled": true, + "component": { + "selector": "date-range", + "settings": { + "allowUpdateOnChange": false, + "hideDefaultAction": true, + "field": "cm:created", + "dateFormat": "DD-MMM-YY", + "maxDate": "today" + } + } + } + ], + "name": "APP.BROWSE.SEARCH.DEFAULT_SEARCH", + "default": true + } + ], "content-metadata-presets": [ { "id": "app.content.metadata.custom",