Skip to content

Commit

Permalink
Revert "AAE-21967 Use column id to reference process variables (#9604)…
Browse files Browse the repository at this point in the history
…" (#9613)

This reverts commit 7ac7db4.
  • Loading branch information
ehsan-2019 authored Apr 26, 2024
1 parent a039367 commit 571fc3d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ describe('VariableMapperService', () => {

const viewModel = service.mapVariablesByColumnTitle([objectWithVariables], [column]);

expect(viewModel[0].variablesMap[column.id].type).toEqual(expectedColumnType);
expect(viewModel[0].variablesMap[column.title].type).toEqual(expectedColumnType);
};

beforeEach(() => {
service = new VariableMapperService();

variable = getProcessInstanceVariableMock({
processDefinitionKey: 'processKey',
name: 'variableName'
});

column = getDataColumnMock<ProcessListDataColumnCustomData>({
title: 'Column Name',
id: 'columnId',
key: '',
customData: {
variableDefinitionsPayload: ['processKey/variableName'],
Expand All @@ -58,11 +58,11 @@ describe('VariableMapperService', () => {
};
});

it('should map variables by column id', () => {
it('should map variables by column title', () => {
const expectedObjectWithVariableMap = {
...objectWithVariables,
variablesMap: {
[column.id]: variable
[column.title]: variable
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { DataColumnType } from '@alfresco/adf-extensions';

@Injectable({ providedIn: 'root' })
export class VariableMapperService {
mapVariablesByColumnTitle<T extends { variables?: ProcessInstanceVariable[] }>(
mapVariablesByColumnTitle <T extends { variables?: ProcessInstanceVariable[] }>(
instancesList: T[] = [],
columnsSchema: DataColumn<ProcessListDataColumnCustomData>[] = []
): Array<WithVariablesMap<T>> {
Expand All @@ -34,22 +34,19 @@ export class VariableMapperService {
return instance;
}

const variablesMap = (instance.variables ?? []).reduce<{ [columnTitle: string]: ProcessInstanceVariable }>(
(variableAccumulator, variable) => {
const processVariableDefinitionPayload = `${variable.processDefinitionKey}/${variable.name}`;
const variablesMap = (instance.variables ?? []).reduce<{[columnTitle: string]: ProcessInstanceVariable}>((variableAccumulator, variable) => {
const processVariableDefinitionPayload = `${variable.processDefinitionKey}/${variable.name}`;

const column = columnsByVariables[processVariableDefinitionPayload];
if (column) {
variableAccumulator[column] = {
...variable,
type: this.mapProcessVariableTypes(variable.type)
};
}
const column = columnsByVariables[processVariableDefinitionPayload];
if (column) {
variableAccumulator[column] = {
...variable,
type: this.mapProcessVariableTypes(variable.type)
};
}

return variableAccumulator;
},
{}
);
return variableAccumulator;
}, {});

return {
...instance,
Expand All @@ -60,16 +57,20 @@ 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] = column.id;
columnsByVariable[key] = columnTitle;
});
return columnsByVariable;

}, {});

return columnsByVariables;
Expand Down

0 comments on commit 571fc3d

Please sign in to comment.