[MNT-22574] Conditional AI Search (#2339)

* [MNT-22574] Support rules for search forms

* * fix lints

* Patch version increment

Co-authored-by: dhrn <dharan.g@muraai.com>
This commit is contained in:
Popovics András 2021-11-04 15:09:18 +01:00 committed by GitHub
parent f89833461c
commit 46a179c75a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 55 additions and 11 deletions

View File

@ -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": "<name of the rule>"
}
}
]
}
}
```

View File

@ -684,7 +684,7 @@
"description": "Element rules",
"type": "object",
"properties": {
"disabled": {
"visible": {
"description": "Rule to evaluate the visibility state",
"type": "string"
}

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "alfresco-content-app",
"version": "2.6.0",
"version": "2.6.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "alfresco-content-app",
"version": "2.6.0",
"version": "2.6.1",
"commit": "",
"license": "LGPL-3.0",
"scripts": {

View File

@ -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"

View File

@ -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"

View File

@ -1,6 +1,6 @@
{
"name": "@alfresco/aca-shared",
"version": "2.6.0",
"version": "2.6.1",
"dependencies": {
"tslib": "^2.0.0"
},

View File

@ -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', () => {

View File

@ -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;

View File

@ -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"

View File

@ -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": [