mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
AAE-21967 use column id to retrieve variable column types (#9629)
* AAE-21967 use column id to retrieve variable column types * AAE-21967 fix variable mapper units
This commit is contained in:
@@ -26,7 +26,7 @@ describe('ProcessListDatatableAdapter', () => {
|
||||
const viewModel: ProcessInstanceCloudListViewModel = {
|
||||
id: '1',
|
||||
variablesMap: {
|
||||
columnDisplayName1: getProcessInstanceVariableMock({ type: 'number' })
|
||||
columnId1: getProcessInstanceVariableMock({ type: 'number' })
|
||||
}
|
||||
};
|
||||
|
||||
@@ -38,7 +38,7 @@ describe('ProcessListDatatableAdapter', () => {
|
||||
};
|
||||
|
||||
const column: DataColumn<ProcessListDataColumnCustomData> = getDataColumnMock({
|
||||
title: 'columnDisplayName1',
|
||||
id: 'columnId1',
|
||||
customData: {
|
||||
assignedVariableDefinitionIds: ['1'],
|
||||
variableDefinitionsPayload: ['processKey/variableName'],
|
||||
|
@@ -20,17 +20,13 @@ import { ProcessListDataColumnCustomData, PROCESS_LIST_CUSTOM_VARIABLE_COLUMN }
|
||||
import { ProcessInstanceCloudListViewModel } from '../models/perocess-instance-cloud-view.model';
|
||||
|
||||
export class ProcessListDatatableAdapter extends ObjectDataTableAdapter {
|
||||
constructor(
|
||||
data: ProcessInstanceCloudListViewModel[],
|
||||
schema: DataColumn<ProcessListDataColumnCustomData>[]
|
||||
) {
|
||||
constructor(data: ProcessInstanceCloudListViewModel[], schema: DataColumn<ProcessListDataColumnCustomData>[]) {
|
||||
super(data, schema);
|
||||
}
|
||||
|
||||
getColumnType(row: DataRow, col: DataColumn<ProcessListDataColumnCustomData>): string {
|
||||
if (col.customData?.columnType === PROCESS_LIST_CUSTOM_VARIABLE_COLUMN) {
|
||||
const variableDisplayName = col.title;
|
||||
const columnType = row.obj.variablesMap?.[variableDisplayName]?.type;
|
||||
const columnType = row.obj.variablesMap?.[col.id]?.type;
|
||||
return columnType ?? 'text';
|
||||
}
|
||||
|
||||
|
@@ -32,7 +32,7 @@ describe('VariableMapperService', () => {
|
||||
|
||||
const viewModel = service.mapVariablesByColumnTitle([objectWithVariables], [column]);
|
||||
|
||||
expect(viewModel[0].variablesMap[column.title].type).toEqual(expectedColumnType);
|
||||
expect(viewModel[0].variablesMap[column.id].type).toEqual(expectedColumnType);
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -58,11 +58,11 @@ describe('VariableMapperService', () => {
|
||||
};
|
||||
});
|
||||
|
||||
it('should map variables by column title', () => {
|
||||
it('should map variables by column id', () => {
|
||||
const expectedObjectWithVariableMap = {
|
||||
...objectWithVariables,
|
||||
variablesMap: {
|
||||
[column.title]: variable
|
||||
[column.id]: variable
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -34,7 +34,8 @@ export class VariableMapperService {
|
||||
return instance;
|
||||
}
|
||||
|
||||
const variablesMap = (instance.variables ?? []).reduce<{[columnTitle: string]: ProcessInstanceVariable}>((variableAccumulator, variable) => {
|
||||
const variablesMap = (instance.variables ?? []).reduce<{ [columnTitle: string]: ProcessInstanceVariable }>(
|
||||
(variableAccumulator, variable) => {
|
||||
const processVariableDefinitionPayload = `${variable.processDefinitionKey}/${variable.name}`;
|
||||
|
||||
const column = columnsByVariables[processVariableDefinitionPayload];
|
||||
@@ -46,7 +47,9 @@ export class VariableMapperService {
|
||||
}
|
||||
|
||||
return variableAccumulator;
|
||||
}, {});
|
||||
},
|
||||
{}
|
||||
);
|
||||
|
||||
return {
|
||||
...instance,
|
||||
@@ -57,20 +60,16 @@ export class VariableMapperService {
|
||||
return rowsViewModel;
|
||||
}
|
||||
|
||||
private mapColumnKeysByVariable(
|
||||
columnsSchema: DataColumn<ProcessListDataColumnCustomData>[]
|
||||
): { [key: string]: string } {
|
||||
private mapColumnKeysByVariable(columnsSchema: DataColumn<ProcessListDataColumnCustomData>[]): { [key: string]: string } {
|
||||
const columnsByVariables = columnsSchema
|
||||
.filter(column => !!column.customData)
|
||||
.filter((column) => !!column.customData)
|
||||
.reduce<{ [key: string]: string }>((columnsByVariable, column) => {
|
||||
const columnTitle = column.title;
|
||||
const variables = column.customData.variableDefinitionsPayload;
|
||||
|
||||
variables.forEach((key) => {
|
||||
columnsByVariable[key] = columnTitle;
|
||||
columnsByVariable[key] = column.id;
|
||||
});
|
||||
return columnsByVariable;
|
||||
|
||||
}, {});
|
||||
|
||||
return columnsByVariables;
|
||||
|
@@ -36,7 +36,7 @@ describe('TasksListDatatableAdapter', () => {
|
||||
const viewModel: TaskInstanceCloudListViewModel = {
|
||||
...cloudModel,
|
||||
variablesMap: {
|
||||
columnDisplayName1: processVariable
|
||||
columnId1: processVariable
|
||||
}
|
||||
};
|
||||
|
||||
@@ -48,7 +48,7 @@ describe('TasksListDatatableAdapter', () => {
|
||||
};
|
||||
|
||||
const column: DataColumn<ProcessListDataColumnCustomData> = getDataColumnMock({
|
||||
title: 'columnDisplayName1',
|
||||
id: 'columnId1',
|
||||
customData: {
|
||||
assignedVariableDefinitionIds: ['variableDefinitionId'],
|
||||
variableDefinitionsPayload: ['processKey/variableName'],
|
||||
|
@@ -20,17 +20,13 @@ import { ProcessListDataColumnCustomData, PROCESS_LIST_CUSTOM_VARIABLE_COLUMN }
|
||||
import { TaskInstanceCloudListViewModel } from '../models/task-cloud-view.model';
|
||||
|
||||
export class TasksListDatatableAdapter extends ObjectDataTableAdapter {
|
||||
constructor(
|
||||
data: TaskInstanceCloudListViewModel[],
|
||||
schema: DataColumn<ProcessListDataColumnCustomData>[]
|
||||
) {
|
||||
constructor(data: TaskInstanceCloudListViewModel[], schema: DataColumn<ProcessListDataColumnCustomData>[]) {
|
||||
super(data, schema);
|
||||
}
|
||||
|
||||
getColumnType(row: DataRow, col: DataColumn<ProcessListDataColumnCustomData>): string {
|
||||
if (col.customData?.columnType === PROCESS_LIST_CUSTOM_VARIABLE_COLUMN) {
|
||||
const variableDisplayName = col.title;
|
||||
const columnType = row.obj.variablesMap?.[variableDisplayName]?.type;
|
||||
const columnType = row.obj.variablesMap?.[col.id]?.type;
|
||||
return columnType ?? 'text';
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user