mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
APPS-1568 : ACA should be extended to support visibility rules for Document List columns. (#2560)
* APPS-1568 Extended rules visibility functionality for Document List columns * APPS-1568 Unit test case added * APPS-1568
This commit is contained in:
@@ -126,6 +126,13 @@ describe('AppExtensionService', () => {
|
||||
});
|
||||
|
||||
describe('documentList', () => {
|
||||
beforeEach(() => {
|
||||
extensions.setEvaluators({
|
||||
notVisible: () => false,
|
||||
visible: () => true
|
||||
});
|
||||
});
|
||||
|
||||
it('should support column orders', () => {
|
||||
applyConfig({
|
||||
$id: 'test',
|
||||
@@ -149,6 +156,16 @@ describe('AppExtensionService', () => {
|
||||
title: 'APP.DOCUMENT_LIST.COLUMNS.NAME',
|
||||
type: 'text',
|
||||
order: 20
|
||||
},
|
||||
{
|
||||
id: 'app.files.securityMarks',
|
||||
key: 'securityMarks',
|
||||
title: 'GOVERNANCE.SECURITY_MARKS.COLUMNS.NAME',
|
||||
type: 'text',
|
||||
order: 55,
|
||||
rules: {
|
||||
visible: 'visible'
|
||||
}
|
||||
}
|
||||
],
|
||||
libraries: [
|
||||
@@ -172,14 +189,61 @@ describe('AppExtensionService', () => {
|
||||
|
||||
const { files, libraries } = service.documentListPresets;
|
||||
|
||||
expect(files.length).toBe(2);
|
||||
expect(files.length).toBe(3);
|
||||
expect(files[0].id).toBe('app.files.thumbnail');
|
||||
expect(files[1].id).toBe('app.files.name');
|
||||
expect(files[2].id).toBe('app.files.securityMarks');
|
||||
|
||||
expect(libraries.length).toBe(2);
|
||||
expect(libraries[0].id).toBe('app.libraries.name');
|
||||
expect(libraries[1].id).toBe('app.libraries.thumbnail');
|
||||
});
|
||||
|
||||
it('should ignore column if visibility in rules is false', () => {
|
||||
applyConfig({
|
||||
$id: 'test',
|
||||
$name: 'test',
|
||||
$version: '1.0.0',
|
||||
$license: 'MIT',
|
||||
$vendor: 'Good company',
|
||||
$runtime: '1.5.0',
|
||||
features: {
|
||||
documentList: {
|
||||
files: [
|
||||
{
|
||||
id: 'app.files.thumbnail',
|
||||
key: '$thumbnail',
|
||||
type: 'image',
|
||||
order: 10
|
||||
},
|
||||
{
|
||||
id: 'app.files.name',
|
||||
key: 'name',
|
||||
title: 'APP.DOCUMENT_LIST.COLUMNS.NAME',
|
||||
type: 'text',
|
||||
order: 20
|
||||
},
|
||||
{
|
||||
id: 'app.files.securityMarks',
|
||||
key: 'securityMarks',
|
||||
title: 'GOVERNANCE.SECURITY_MARKS.COLUMNS.NAME',
|
||||
type: 'text',
|
||||
order: 55,
|
||||
rules: {
|
||||
visible: 'notVisible'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const { files } = service.documentListPresets;
|
||||
|
||||
expect(files.length).toBe(2);
|
||||
expect(files[0].id).toBe('app.files.thumbnail');
|
||||
expect(files[1].id).toBe('app.files.name');
|
||||
});
|
||||
});
|
||||
|
||||
describe('actions', () => {
|
||||
|
@@ -211,6 +211,7 @@ export class AppExtensionService implements RuleContext {
|
||||
protected getDocumentListPreset(config: ExtensionConfig, key: string): DocumentListPresetRef[] {
|
||||
return this.loader
|
||||
.getElements<DocumentListPresetRef>(config, `features.documentList.${key}`)
|
||||
.filter((group) => this.filterVisible(group))
|
||||
.filter((entry) => !entry.disabled)
|
||||
.sort(sortByOrder);
|
||||
}
|
||||
@@ -476,7 +477,7 @@ export class AppExtensionService implements RuleContext {
|
||||
};
|
||||
}
|
||||
|
||||
filterVisible(action: ContentActionRef | SettingsGroupRef | SidebarTabRef): boolean {
|
||||
filterVisible(action: ContentActionRef | SettingsGroupRef | SidebarTabRef | DocumentListPresetRef): boolean {
|
||||
if (action && action.rules && action.rules.visible) {
|
||||
return this.extensions.evaluateRule(action.rules.visible, this);
|
||||
}
|
||||
|
Reference in New Issue
Block a user