[ACTIVITI-3720] form variables enhancements (#5028)

* support form variables on the model level

* take 'variables.name' convention into account

* move API to a proper place

* unit tests and code fixes

* unit tests for form field model

* process variable interface
This commit is contained in:
Denys Vuika
2019-09-02 11:20:54 +01:00
committed by Eugenio Romano
parent 42c9a2e833
commit ce50e9a3d3
12 changed files with 422 additions and 1828 deletions

View File

@@ -193,40 +193,24 @@ export class WidgetVisibilityService {
getVariableValue(form: FormModel, name: string, processVarList: TaskProcessVariableModel[]): string {
const processVariableValue = this.getProcessVariableValue(name, processVarList);
const variableDefaultValue = this.getFormVariableDefaultValue(form, name);
const variableDefaultValue = form.getFormVariableValue(name);
return (processVariableValue === undefined) ? variableDefaultValue : processVariableValue;
}
private getFormVariableDefaultValue(form: FormModel, identifier: string): string {
const variables = this.getFormVariables(form);
if (variables) {
const formVariable = variables.find((formVar) => {
return formVar.name === identifier || formVar.id === identifier;
});
let value;
if (formVariable) {
value = formVariable.value;
if (formVariable.type === 'date') {
value += 'T00:00:00.000Z';
}
}
return value;
}
}
private getFormVariables(form: FormModel): any[] {
return form.json.variables;
}
private getProcessVariableValue(name: string, processVarList: TaskProcessVariableModel[]): string {
if (processVarList) {
const processVariable = processVarList.find((variable) => variable.id === name);
const processVariable = processVarList.find(
variable =>
variable.id === name ||
variable.id === `variables.${name}`
);
if (processVariable) {
return processVariable.value;
}
}
return undefined;
}
evaluateLogicalOperation(logicOp, previousValue, newValue): boolean {