mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[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:
committed by
Eugenio Romano
parent
42c9a2e833
commit
ce50e9a3d3
@@ -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 {
|
||||
|
Reference in New Issue
Block a user