support ordering of document list columns (#1799)

This commit is contained in:
Denys Vuika
2020-11-19 19:38:26 +00:00
committed by GitHub
parent dab9ddbdca
commit 092d430470
3 changed files with 148 additions and 45 deletions

View File

@@ -111,6 +111,63 @@ describe('AppExtensionService', () => {
});
});
describe('documentList', () => {
it('should support column orders', () => {
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
}
],
libraries: [
{
id: 'app.libraries.thumbnail',
key: '$thumbnail',
type: 'image',
order: 20
},
{
id: 'app.libraries.name',
key: 'title',
title: 'APP.DOCUMENT_LIST.COLUMNS.NAME',
type: 'text',
order: 10
}
]
}
}
});
const { files, libraries } = service.documentListPresets;
expect(files.length).toBe(2);
expect(files[0].id).toBe('app.files.thumbnail');
expect(files[1].id).toBe('app.files.name');
expect(libraries.length).toBe(2);
expect(libraries[0].id).toBe('app.libraries.name');
expect(libraries[1].id).toBe('app.libraries.thumbnail');
});
});
describe('actions', () => {
beforeEach(() => {
applyConfig({

View File

@@ -195,8 +195,11 @@ export class AppExtensionService implements RuleContext {
return this.loader.getElements<NavBarGroupRef>(config, 'features.navbar');
}
protected getDocumentListPreset(config: ExtensionConfig, key: string) {
return this.loader.getElements<DocumentListPresetRef>(config, `features.documentList.${key}`).filter((entry) => !entry.disabled);
protected getDocumentListPreset(config: ExtensionConfig, key: string): DocumentListPresetRef[] {
return this.loader
.getElements<DocumentListPresetRef>(config, `features.documentList.${key}`)
.filter((entry) => !entry.disabled)
.sort(sortByOrder);
}
getApplicationNavigation(elements): Array<NavBarGroupRef> {