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', () => {
|
describe('documentList', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
extensions.setEvaluators({
|
||||||
|
notVisible: () => false,
|
||||||
|
visible: () => true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should support column orders', () => {
|
it('should support column orders', () => {
|
||||||
applyConfig({
|
applyConfig({
|
||||||
$id: 'test',
|
$id: 'test',
|
||||||
@@ -149,6 +156,16 @@ describe('AppExtensionService', () => {
|
|||||||
title: 'APP.DOCUMENT_LIST.COLUMNS.NAME',
|
title: 'APP.DOCUMENT_LIST.COLUMNS.NAME',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
order: 20
|
order: 20
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'app.files.securityMarks',
|
||||||
|
key: 'securityMarks',
|
||||||
|
title: 'GOVERNANCE.SECURITY_MARKS.COLUMNS.NAME',
|
||||||
|
type: 'text',
|
||||||
|
order: 55,
|
||||||
|
rules: {
|
||||||
|
visible: 'visible'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
libraries: [
|
libraries: [
|
||||||
@@ -172,14 +189,61 @@ describe('AppExtensionService', () => {
|
|||||||
|
|
||||||
const { files, libraries } = service.documentListPresets;
|
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[0].id).toBe('app.files.thumbnail');
|
||||||
expect(files[1].id).toBe('app.files.name');
|
expect(files[1].id).toBe('app.files.name');
|
||||||
|
expect(files[2].id).toBe('app.files.securityMarks');
|
||||||
|
|
||||||
expect(libraries.length).toBe(2);
|
expect(libraries.length).toBe(2);
|
||||||
expect(libraries[0].id).toBe('app.libraries.name');
|
expect(libraries[0].id).toBe('app.libraries.name');
|
||||||
expect(libraries[1].id).toBe('app.libraries.thumbnail');
|
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', () => {
|
describe('actions', () => {
|
||||||
|
@@ -211,6 +211,7 @@ export class AppExtensionService implements RuleContext {
|
|||||||
protected getDocumentListPreset(config: ExtensionConfig, key: string): DocumentListPresetRef[] {
|
protected getDocumentListPreset(config: ExtensionConfig, key: string): DocumentListPresetRef[] {
|
||||||
return this.loader
|
return this.loader
|
||||||
.getElements<DocumentListPresetRef>(config, `features.documentList.${key}`)
|
.getElements<DocumentListPresetRef>(config, `features.documentList.${key}`)
|
||||||
|
.filter((group) => this.filterVisible(group))
|
||||||
.filter((entry) => !entry.disabled)
|
.filter((entry) => !entry.disabled)
|
||||||
.sort(sortByOrder);
|
.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) {
|
if (action && action.rules && action.rules.visible) {
|
||||||
return this.extensions.evaluateRule(action.rules.visible, this);
|
return this.extensions.evaluateRule(action.rules.visible, this);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user