mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-16969] Remove force casting of all types to text (#8963)
This commit is contained in:
@@ -20,8 +20,7 @@ import {
|
|||||||
mockEuropeCountriesData,
|
mockEuropeCountriesData,
|
||||||
mockCountriesIncorrectData,
|
mockCountriesIncorrectData,
|
||||||
mockInvalidSchemaDefinition,
|
mockInvalidSchemaDefinition,
|
||||||
mockSchemaDefinition,
|
mockSchemaDefinition
|
||||||
mockSchemaDefinitionWithDifferentTypes
|
|
||||||
} from '../../../mocks/data-table-widget.mock';
|
} from '../../../mocks/data-table-widget.mock';
|
||||||
import { ObjectDataRow } from '@alfresco/adf-core';
|
import { ObjectDataRow } from '@alfresco/adf-core';
|
||||||
|
|
||||||
@@ -32,14 +31,6 @@ describe('WidgetDataTableAdapter', () => {
|
|||||||
widgetDataTableAdapter = new WidgetDataTableAdapter(mockEuropeCountriesData, mockSchemaDefinition);
|
widgetDataTableAdapter = new WidgetDataTableAdapter(mockEuropeCountriesData, mockSchemaDefinition);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set columns type to "text" during initialization', () => {
|
|
||||||
widgetDataTableAdapter = new WidgetDataTableAdapter(mockEuropeCountriesData, mockSchemaDefinitionWithDifferentTypes);
|
|
||||||
|
|
||||||
widgetDataTableAdapter.getColumns().forEach(column =>
|
|
||||||
expect(column.type).toBe('text')
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return rows if all columns are linked to data', () => {
|
it('should return rows if all columns are linked to data', () => {
|
||||||
const rows = widgetDataTableAdapter.getRows();
|
const rows = widgetDataTableAdapter.getRows();
|
||||||
|
|
||||||
|
@@ -30,8 +30,6 @@ export class WidgetDataTableAdapter extends ObjectDataTableAdapter {
|
|||||||
super(data, schema);
|
super(data, schema);
|
||||||
this.rows = super.getRows();
|
this.rows = super.getRows();
|
||||||
this.columns = super.getColumns();
|
this.columns = super.getColumns();
|
||||||
|
|
||||||
this.setColumnsTypeToText();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getRows(): DataRow[] {
|
getRows(): DataRow[] {
|
||||||
@@ -55,8 +53,4 @@ export class WidgetDataTableAdapter extends ObjectDataTableAdapter {
|
|||||||
|
|
||||||
return availableColumnKeys.every(columnKey => this.rows.some(row => Object.keys(row.obj).includes(columnKey)));
|
return availableColumnKeys.every(columnKey => this.rows.some(row => Object.keys(row.obj).includes(columnKey)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private setColumnsTypeToText(): void {
|
|
||||||
super.setColumns(this.columns.map(column => ({ ...column, type: 'text' })));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -35,23 +35,6 @@ export const mockSchemaDefinition: DataColumn[] = [
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
export const mockSchemaDefinitionWithDifferentTypes: DataColumn[] = [
|
|
||||||
{
|
|
||||||
type: 'json',
|
|
||||||
key: 'id',
|
|
||||||
title: 'Country ID',
|
|
||||||
sortable: true,
|
|
||||||
draggable: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'date',
|
|
||||||
key: 'name',
|
|
||||||
title: 'Country Name',
|
|
||||||
sortable: true,
|
|
||||||
draggable: true
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
export const mockInvalidSchemaDefinition: DataColumn[] = [
|
export const mockInvalidSchemaDefinition: DataColumn[] = [
|
||||||
{
|
{
|
||||||
type: 'text',
|
type: 'text',
|
||||||
|
Reference in New Issue
Block a user