Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AAE-19070] Disable broken column types ("location" and "image") in data table widget #9186

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import {
mockEuropeCountriesData,
mockCountriesIncorrectData,
mockInvalidSchemaDefinition,
mockSchemaDefinition
mockSchemaDefinition,
mockMultipleTypesData,
mockMultipleTypesSchemaDefinition
} from '../../../mocks/data-table-widget.mock';
import { ObjectDataRow } from '@alfresco/adf-core';

Expand Down Expand Up @@ -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();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ import {

export class WidgetDataTableAdapter extends ObjectDataTableAdapter {

static readonly hiddenColumnTypes = ['image', 'location'];
private rows: DataRow[];
private columns: DataColumn[];

constructor(data?: any[], schema?: DataColumn[]) {
super(data, schema);
this.rows = super.getRows();
this.columns = super.getColumns();
this.hideColumnTypes(WidgetDataTableAdapter.hiddenColumnTypes);
}

getRows(): DataRow[] {
Expand All @@ -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);
wiktord2000 marked this conversation as resolved.
Show resolved Hide resolved
}

private hasAllMandatoryColumnPropertiesHaveValues(): boolean {
return this.columns.every(column => !!column.key);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Loading