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 reference process variables (#9604)
This commit is contained in:
@@ -32,12 +32,11 @@ describe('VariableMapperService', () => {
|
|||||||
|
|
||||||
const viewModel = service.mapVariablesByColumnTitle([objectWithVariables], [column]);
|
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(() => {
|
beforeEach(() => {
|
||||||
service = new VariableMapperService();
|
service = new VariableMapperService();
|
||||||
|
|
||||||
variable = getProcessInstanceVariableMock({
|
variable = getProcessInstanceVariableMock({
|
||||||
processDefinitionKey: 'processKey',
|
processDefinitionKey: 'processKey',
|
||||||
name: 'variableName'
|
name: 'variableName'
|
||||||
@@ -45,6 +44,7 @@ describe('VariableMapperService', () => {
|
|||||||
|
|
||||||
column = getDataColumnMock<ProcessListDataColumnCustomData>({
|
column = getDataColumnMock<ProcessListDataColumnCustomData>({
|
||||||
title: 'Column Name',
|
title: 'Column Name',
|
||||||
|
id: 'columnId',
|
||||||
key: '',
|
key: '',
|
||||||
customData: {
|
customData: {
|
||||||
variableDefinitionsPayload: ['processKey/variableName'],
|
variableDefinitionsPayload: ['processKey/variableName'],
|
||||||
@@ -58,11 +58,11 @@ describe('VariableMapperService', () => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should map variables by column title', () => {
|
it('should map variables by column id', () => {
|
||||||
const expectedObjectWithVariableMap = {
|
const expectedObjectWithVariableMap = {
|
||||||
...objectWithVariables,
|
...objectWithVariables,
|
||||||
variablesMap: {
|
variablesMap: {
|
||||||
[column.title]: variable
|
[column.id]: variable
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -34,7 +34,8 @@ export class VariableMapperService {
|
|||||||
return instance;
|
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 processVariableDefinitionPayload = `${variable.processDefinitionKey}/${variable.name}`;
|
||||||
|
|
||||||
const column = columnsByVariables[processVariableDefinitionPayload];
|
const column = columnsByVariables[processVariableDefinitionPayload];
|
||||||
@@ -46,7 +47,9 @@ export class VariableMapperService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return variableAccumulator;
|
return variableAccumulator;
|
||||||
}, {});
|
},
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...instance,
|
...instance,
|
||||||
@@ -57,20 +60,16 @@ export class VariableMapperService {
|
|||||||
return rowsViewModel;
|
return rowsViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private mapColumnKeysByVariable(
|
private mapColumnKeysByVariable(columnsSchema: DataColumn<ProcessListDataColumnCustomData>[]): { [key: string]: string } {
|
||||||
columnsSchema: DataColumn<ProcessListDataColumnCustomData>[]
|
|
||||||
): { [key: string]: string } {
|
|
||||||
const columnsByVariables = columnsSchema
|
const columnsByVariables = columnsSchema
|
||||||
.filter(column => !!column.customData)
|
.filter((column) => !!column.customData)
|
||||||
.reduce<{ [key: string]: string }>((columnsByVariable, column) => {
|
.reduce<{ [key: string]: string }>((columnsByVariable, column) => {
|
||||||
const columnTitle = column.title;
|
|
||||||
const variables = column.customData.variableDefinitionsPayload;
|
const variables = column.customData.variableDefinitionsPayload;
|
||||||
|
|
||||||
variables.forEach((key) => {
|
variables.forEach((key) => {
|
||||||
columnsByVariable[key] = columnTitle;
|
columnsByVariable[key] = column.id;
|
||||||
});
|
});
|
||||||
return columnsByVariable;
|
return columnsByVariable;
|
||||||
|
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
return columnsByVariables;
|
return columnsByVariables;
|
||||||
|
Reference in New Issue
Block a user