mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-06-30 18:15:11 +00:00
[AAE-10089] Process variables values are not shown for old tasks and … (#7744)
* [AAE-10089] Process variables values are not shown for old tasks and processes * fix unit test and variable names * change variableId
This commit is contained in:
parent
fd0110e5c7
commit
26c46cfb9d
@ -20,6 +20,7 @@ import { ProcessInstanceVariable } from '../models/process-instance-variable.mod
|
||||
export const getProcessInstanceVariableMock = (variable: Partial<ProcessInstanceVariable> = {}): ProcessInstanceVariable => ({
|
||||
id: 1,
|
||||
variableDefinitionId: 'variableDefinitionId',
|
||||
processDefinitionKey: 'processDefinitionKey',
|
||||
value: 'value',
|
||||
appName: 'appName',
|
||||
createTime: 'createTime',
|
||||
|
@ -22,6 +22,7 @@ export type WithVariablesMap<T> = T & {
|
||||
export interface ProcessInstanceVariable {
|
||||
id: number;
|
||||
variableDefinitionId: string;
|
||||
processDefinitionKey: string;
|
||||
value: string;
|
||||
appName: string;
|
||||
createTime: string;
|
||||
|
@ -31,7 +31,8 @@ describe('VariableMapperService', () => {
|
||||
|
||||
it('should map variables by column title', () => {
|
||||
const variable: ProcessInstanceVariable = getProcessInstanceVariableMock({
|
||||
variableDefinitionId: 'variableDefinitionIdOne'
|
||||
processDefinitionKey: 'processKey',
|
||||
name: 'variableName'
|
||||
});
|
||||
|
||||
const objectWithVariables = {
|
||||
|
@ -26,7 +26,7 @@ export class VariableMapperService {
|
||||
instancesList: T[] = [],
|
||||
columnsSchema: DataColumn<ProcessListDataColumnCustomData>[] = []
|
||||
): Array<WithVariablesMap<T>> {
|
||||
const columnsByVariableId = this.mapColumnKeysByVariableId(columnsSchema);
|
||||
const columnsByVariables = this.mapColumnKeysByVariable(columnsSchema);
|
||||
|
||||
const rowsViewModel = instancesList.map<WithVariablesMap<T>>((instance) => {
|
||||
if (!instance.variables?.length) {
|
||||
@ -34,9 +34,9 @@ export class VariableMapperService {
|
||||
}
|
||||
|
||||
const variablesMap = (instance.variables ?? []).reduce<{[columnTitle: string]: ProcessInstanceVariable}>((variableAccumulator, variable) => {
|
||||
const processVariableDefinitionId = variable.variableDefinitionId;
|
||||
const processVariableDefinitionPayload = `${variable.processDefinitionKey}/${variable.name}`;
|
||||
|
||||
const column = columnsByVariableId[processVariableDefinitionId];
|
||||
const column = columnsByVariables[processVariableDefinitionPayload];
|
||||
if (column) {
|
||||
variableAccumulator[column] = {
|
||||
...variable,
|
||||
@ -56,23 +56,23 @@ export class VariableMapperService {
|
||||
return rowsViewModel;
|
||||
}
|
||||
|
||||
private mapColumnKeysByVariableId(
|
||||
private mapColumnKeysByVariable(
|
||||
columnsSchema: DataColumn<ProcessListDataColumnCustomData>[]
|
||||
): { [variableId: string]: string } {
|
||||
const columnsByVariableId = columnsSchema
|
||||
): { [key: string]: string } {
|
||||
const columnsByVariables = columnsSchema
|
||||
.filter(column => !!column.customData)
|
||||
.reduce<{ [variableId: string]: string }>((columnsByVariable, column) => {
|
||||
.reduce<{ [key: string]: string }>((columnsByVariable, column) => {
|
||||
const columnTitle = column.title;
|
||||
const variableIds = column.customData.assignedVariableDefinitionIds;
|
||||
const variables = column.customData.variableDefinitionsPayload;
|
||||
|
||||
variableIds.forEach((variableId) => {
|
||||
columnsByVariable[variableId] = columnTitle;
|
||||
variables.forEach((key) => {
|
||||
columnsByVariable[key] = columnTitle;
|
||||
});
|
||||
return columnsByVariable;
|
||||
|
||||
}, {});
|
||||
|
||||
return columnsByVariableId;
|
||||
return columnsByVariables;
|
||||
}
|
||||
|
||||
private mapProcessVariableTypes(variableType: string): DataColumnType {
|
||||
|
Loading…
x
Reference in New Issue
Block a user