diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/data-table/data-table-adapter.widget.spec.ts b/lib/process-services-cloud/src/lib/form/components/widgets/data-table/data-table-adapter.widget.spec.ts index 460e56a424d..59d9146806d 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/data-table/data-table-adapter.widget.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/data-table/data-table-adapter.widget.spec.ts @@ -20,7 +20,9 @@ import { mockEuropeCountriesData, mockCountriesIncorrectData, mockInvalidSchemaDefinition, - mockSchemaDefinition + mockSchemaDefinition, + mockMultipleTypesData, + mockMultipleTypesSchemaDefinition } from '../../../mocks/data-table-widget.mock'; import { ObjectDataRow } from '@alfresco/adf-core'; @@ -64,4 +66,17 @@ describe('WidgetDataTableAdapter', () => { expect(isValid).toBeTrue(); }); + + it('should hide specific column types', () => { + widgetDataTableAdapter = new WidgetDataTableAdapter(mockMultipleTypesData, mockMultipleTypesSchemaDefinition); + const columns = widgetDataTableAdapter.getColumns(); + + expect(columns.length).toBe(4); + + columns.forEach(column => { + WidgetDataTableAdapter.hiddenColumnTypes.includes(column.type) + ? expect(column.isHidden).toBeTrue() + : expect(column.isHidden).toBeFalse(); + }); + }); }); diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/data-table/data-table-adapter.widget.ts b/lib/process-services-cloud/src/lib/form/components/widgets/data-table/data-table-adapter.widget.ts index 26d5201f311..1cb91e304e0 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/data-table/data-table-adapter.widget.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/data-table/data-table-adapter.widget.ts @@ -23,6 +23,7 @@ import { export class WidgetDataTableAdapter extends ObjectDataTableAdapter { + static readonly hiddenColumnTypes = ['image', 'location']; private rows: DataRow[]; private columns: DataColumn[]; @@ -30,6 +31,7 @@ export class WidgetDataTableAdapter extends ObjectDataTableAdapter { super(data, schema); this.rows = super.getRows(); this.columns = super.getColumns(); + this.hideColumnTypes(WidgetDataTableAdapter.hiddenColumnTypes); } getRows(): DataRow[] { @@ -44,6 +46,12 @@ export class WidgetDataTableAdapter extends ObjectDataTableAdapter { return this.hasAllColumnsLinkedToData() && this.hasAllMandatoryColumnPropertiesHaveValues(); } + private hideColumnTypes(typesToHide: string[]): void { + this.columns + .filter(column => typesToHide.includes(column.type)) + .forEach(column => column.isHidden = true); + } + private hasAllMandatoryColumnPropertiesHaveValues(): boolean { return this.columns.every(column => !!column.key); } diff --git a/lib/process-services-cloud/src/lib/form/mocks/data-table-widget.mock.ts b/lib/process-services-cloud/src/lib/form/mocks/data-table-widget.mock.ts index ba06c4696fd..07215e2917a 100644 --- a/lib/process-services-cloud/src/lib/form/mocks/data-table-widget.mock.ts +++ b/lib/process-services-cloud/src/lib/form/mocks/data-table-widget.mock.ts @@ -52,6 +52,46 @@ export const mockInvalidSchemaDefinition: DataColumn[] = [ } ]; +export const mockMultipleTypesSchemaDefinition: DataColumn[] = [ + { + type: 'text', + key: 'text', + title: 'Text column', + sortable: true, + draggable: true + }, + { + type: 'location', + key: 'location', + title: 'Location column', + sortable: true, + draggable: true + }, + { + type: 'image', + key: 'imageUrl', + title: 'Image column', + sortable: true, + draggable: true + }, + { + type: 'fileSize', + key: 'fileSize', + title: 'FileSize column', + sortable: true, + draggable: true + } +]; + +export const mockMultipleTypesData = [ + { + text: 'Example text', + location: '-me-/logo.jpg', + imageUrl: 'https://exmaple.domain.com/logo.jpg', + fileSize: 223400 + } +]; + export const mockEuropeCountriesData = [ { id: 'PL',