diff --git a/docs/tutorials/search-form.md b/docs/tutorials/search-form.md index 3ce2c845e..53073821b 100644 --- a/docs/tutorials/search-form.md +++ b/docs/tutorials/search-form.md @@ -10,6 +10,7 @@ In this tutorial, we are going to implement the following features: - [Add a new search form](#add-a-new-search-form) - [Replace a search form](#replace-a-search-form) - [Replace default search](#replace-default-search) +- [Adding rule to search form](#adding-rule-to-search-form) ### Extension Properties @@ -80,3 +81,23 @@ To replace the default search with your configuration set to true the default fi } } ``` +### Adding rule to search form + +It support the visible rule to show the configuration + +```json +{ + "features": { + "search": [ + { + "id": "app.search.custom_search", + "order": 200, + "name": "APP.SEARCH.MY_CUSTOM_SEARCH", + "rules": { + "visible": "" + } + } + ] + } +} +``` diff --git a/extension.schema.json b/extension.schema.json index 250b4e311..c34b8a4a4 100644 --- a/extension.schema.json +++ b/extension.schema.json @@ -684,7 +684,7 @@ "description": "Element rules", "type": "object", "properties": { - "disabled": { + "visible": { "description": "Rule to evaluate the visibility state", "type": "string" } diff --git a/package-lock.json b/package-lock.json index c7da670f6..1ae681b06 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "alfresco-content-app", - "version": "2.6.0", + "version": "2.6.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 2d90bc2db..065e88efd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "alfresco-content-app", - "version": "2.6.0", + "version": "2.6.1", "commit": "", "license": "LGPL-3.0", "scripts": { diff --git a/projects/aca-about/package.json b/projects/aca-about/package.json index fbfb9f14c..0cfa88c26 100644 --- a/projects/aca-about/package.json +++ b/projects/aca-about/package.json @@ -1,6 +1,6 @@ { "name": "@alfresco/aca-about", - "version": "2.6.0", + "version": "2.6.1", "peerDependencies": { "@angular/common": "^10.0.14", "@angular/core": "^10.0.14" diff --git a/projects/aca-settings/package.json b/projects/aca-settings/package.json index b108f0ef7..e3ca05196 100644 --- a/projects/aca-settings/package.json +++ b/projects/aca-settings/package.json @@ -1,6 +1,6 @@ { "name": "@alfresco/aca-settings", - "version": "2.6.0", + "version": "2.6.1", "peerDependencies": { "@angular/common": "^10.0.14", "@angular/core": "^10.0.14" diff --git a/projects/aca-shared/package.json b/projects/aca-shared/package.json index 52f074e5f..f7d2495b0 100644 --- a/projects/aca-shared/package.json +++ b/projects/aca-shared/package.json @@ -1,6 +1,6 @@ { "name": "@alfresco/aca-shared", - "version": "2.6.0", + "version": "2.6.1", "dependencies": { "tslib": "^2.0.0" }, 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 84fb7e277..bb8c4338b 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 @@ -888,6 +888,11 @@ describe('AppExtensionService', () => { describe('search', () => { beforeEach(() => { + extensions.setEvaluators({ + visible: () => true, + notVisible: () => false + }); + applyConfig({ $id: 'test', $name: 'test', @@ -916,14 +921,25 @@ describe('AppExtensionService', () => { { id: 'app.search-1', order: 200, - name: 'default', + name: 'search extension 1', + rules: { + visible: 'visible' + }, default: false }, { id: 'app.search-2', order: 200, - name: 'default', + name: 'search extension 2', disabled: true + }, + { + id: 'app.search-3', + order: 300, + name: 'search extension 3', + rules: { + visible: 'notVisible' + } } ] } @@ -939,6 +955,10 @@ describe('AppExtensionService', () => { 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'); }); + + it('should not load the not visible search extension', () => { + expect(service.search.find(({ id }) => id === 'app.search-3')).toBe(undefined, 'not visible configuration shown in the result'); + }); }); describe('rule disable', () => { 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 1332ffc67..dabcb13f9 100644 --- a/projects/aca-shared/src/lib/services/app.extension.service.ts +++ b/projects/aca-shared/src/lib/services/app.extension.service.ts @@ -295,7 +295,10 @@ export class AppExtensionService implements RuleContext { return null; } - const search = mergeArrays([], elements).filter((entry) => !entry.disabled); + const search = mergeArrays([], elements) + .filter((entry) => !entry.disabled) + .filter((entry) => this.filterVisible(entry)) + .sort(sortByOrder); try { this.appConfig.config['search'] = search; diff --git a/projects/aca-testing-shared/package.json b/projects/aca-testing-shared/package.json index 14631e636..695fcde4f 100644 --- a/projects/aca-testing-shared/package.json +++ b/projects/aca-testing-shared/package.json @@ -1,6 +1,6 @@ { "name": "aca-testing-shared", - "version": "2.6.0", + "version": "2.6.1", "main": "src/index.ts", "dependencies": { "tslib": "^2.0.0" diff --git a/projects/adf-office-services-ext/package.json b/projects/adf-office-services-ext/package.json index 344a5862d..b8e054eae 100644 --- a/projects/adf-office-services-ext/package.json +++ b/projects/adf-office-services-ext/package.json @@ -1,6 +1,6 @@ { "name": "@alfresco/adf-office-services-ext", - "version": "2.6.0", + "version": "2.6.1", "license": "Apache-2.0", "homepage": "https://github.com/Alfresco/alfresco-content-app", "keywords": [