From 0a6ba9edf0cb868882076f99dcff80a0ce5c0fcd Mon Sep 17 00:00:00 2001 From: "S.Listl" <S.Listl@SLISTL.aditosoftware.local> Date: Wed, 20 Nov 2019 13:44:28 +0100 Subject: [PATCH] Workflow fix --- .../WorkflowDefinition_entity.aod | 2 + .../entityfields/diagram/valueProcess.js | 2 +- .../entityfields/isactive/stateProcess.js | 8 ++++ .../entityfields/key/stateProcess.js | 8 ++++ .../recordcontainers/jdito/onUpdate.js | 7 ++- .../WorkflowDefinitionEdit_view.aod | 5 +++ .../ViewTemplateData_lib.aod | 9 ++++ process/ViewTemplateData_lib/process.js | 45 +++++++++++++++++++ 8 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 entity/WorkflowDefinition_entity/entityfields/isactive/stateProcess.js create mode 100644 entity/WorkflowDefinition_entity/entityfields/key/stateProcess.js create mode 100644 process/ViewTemplateData_lib/ViewTemplateData_lib.aod create mode 100644 process/ViewTemplateData_lib/process.js diff --git a/entity/WorkflowDefinition_entity/WorkflowDefinition_entity.aod b/entity/WorkflowDefinition_entity/WorkflowDefinition_entity.aod index 3b6b3359ef..b37be8dac2 100644 --- a/entity/WorkflowDefinition_entity/WorkflowDefinition_entity.aod +++ b/entity/WorkflowDefinition_entity/WorkflowDefinition_entity.aod @@ -42,6 +42,7 @@ <title>Active</title> <contentType>BOOLEAN</contentType> <dropDownProcess>%aditoprj%/entity/WorkflowDefinition_entity/entityfields/isactive/dropDownProcess.js</dropDownProcess> + <stateProcess>%aditoprj%/entity/WorkflowDefinition_entity/entityfields/isactive/stateProcess.js</stateProcess> </entityField> <entityField> <name>FILEUPLOAD</name> @@ -66,6 +67,7 @@ <name>KEY</name> <title>Key</title> <mandatory v="true" /> + <stateProcess>%aditoprj%/entity/WorkflowDefinition_entity/entityfields/key/stateProcess.js</stateProcess> <valueProcess>%aditoprj%/entity/WorkflowDefinition_entity/entityfields/key/valueProcess.js</valueProcess> </entityField> <entityField> diff --git a/entity/WorkflowDefinition_entity/entityfields/diagram/valueProcess.js b/entity/WorkflowDefinition_entity/entityfields/diagram/valueProcess.js index 4ce7a3f7fc..732cf42d0b 100644 --- a/entity/WorkflowDefinition_entity/entityfields/diagram/valueProcess.js +++ b/entity/WorkflowDefinition_entity/entityfields/diagram/valueProcess.js @@ -3,5 +3,5 @@ import("system.result"); import("system.neon"); import("system.workflow"); -if (vars.get("$sys.viewmode") == neon.FRAME_VIEWMODE_DATASET && vars.get("$sys.recordstate") == neon.OPERATINGSTATE_VIEW) +if (vars.get("$sys.viewmode") == neon.FRAME_VIEWMODE_DATASET && vars.get("$sys.recordstate") == neon.OPERATINGSTATE_VIEW && vars.get("$field.VERSION")) result.string(workflow.getProcessDiagram(vars.get("$field.UID"))); \ No newline at end of file diff --git a/entity/WorkflowDefinition_entity/entityfields/isactive/stateProcess.js b/entity/WorkflowDefinition_entity/entityfields/isactive/stateProcess.js new file mode 100644 index 0000000000..a107fbe311 --- /dev/null +++ b/entity/WorkflowDefinition_entity/entityfields/isactive/stateProcess.js @@ -0,0 +1,8 @@ +import("system.neon"); +import("system.vars"); +import("system.result"); + +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) + result.string(neon.COMPONENTSTATE_INVISIBLE); +else + result.string(neon.COMPONENTSTATE_AUTO); \ No newline at end of file diff --git a/entity/WorkflowDefinition_entity/entityfields/key/stateProcess.js b/entity/WorkflowDefinition_entity/entityfields/key/stateProcess.js new file mode 100644 index 0000000000..b24d4beb6d --- /dev/null +++ b/entity/WorkflowDefinition_entity/entityfields/key/stateProcess.js @@ -0,0 +1,8 @@ +import("system.neon"); +import("system.vars"); +import("system.result"); + +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) + result.string(neon.COMPONENTSTATE_AUTO); +else + result.string(neon.COMPONENTSTATE_READONLY); \ No newline at end of file diff --git a/entity/WorkflowDefinition_entity/recordcontainers/jdito/onUpdate.js b/entity/WorkflowDefinition_entity/recordcontainers/jdito/onUpdate.js index 23cf24a9af..612fa49109 100644 --- a/entity/WorkflowDefinition_entity/recordcontainers/jdito/onUpdate.js +++ b/entity/WorkflowDefinition_entity/recordcontainers/jdito/onUpdate.js @@ -1,5 +1,10 @@ import("system.vars"); import("system.workflow"); -if (vars.get("$local.changed")) var rowdata = vars.get("$local.rowdata"); + +vars.get("$local.changed").forEach(function (field) +{ + if (field == "ISACTIVE.value") + workflow.setProcessActive(rowdata["UID.value"], rowdata["ISACTIVE.value"] == "true"); +}); \ No newline at end of file diff --git a/neonView/WorkflowDefinitionEdit_view/WorkflowDefinitionEdit_view.aod b/neonView/WorkflowDefinitionEdit_view/WorkflowDefinitionEdit_view.aod index eacb4831a7..a9cdf16d3e 100644 --- a/neonView/WorkflowDefinitionEdit_view/WorkflowDefinitionEdit_view.aod +++ b/neonView/WorkflowDefinitionEdit_view/WorkflowDefinitionEdit_view.aod @@ -2,6 +2,7 @@ <neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.2" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.1.2"> <name>WorkflowDefinitionEdit_view</name> <majorModelMode>DISTRIBUTED</majorModelMode> + <isSmall v="true" /> <layout> <boxLayout> <name>layout</name> @@ -21,6 +22,10 @@ <name>88c2c956-966a-4ad9-b744-ccb729b024bc</name> <entityField>KEY</entityField> </entityFieldLink> + <entityFieldLink> + <name>14bd4671-d876-430e-8574-277118395ff0</name> + <entityField>ISACTIVE</entityField> + </entityFieldLink> </fields> </genericViewTemplate> </children> diff --git a/process/ViewTemplateData_lib/ViewTemplateData_lib.aod b/process/ViewTemplateData_lib/ViewTemplateData_lib.aod new file mode 100644 index 0000000000..5bb4548465 --- /dev/null +++ b/process/ViewTemplateData_lib/ViewTemplateData_lib.aod @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<process xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.2.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/process/1.2.1"> + <name>ViewTemplateData_lib</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <process>%aditoprj%/process/ViewTemplateData_lib/process.js</process> + <variants> + <element>LIBRARY</element> + </variants> +</process> diff --git a/process/ViewTemplateData_lib/process.js b/process/ViewTemplateData_lib/process.js new file mode 100644 index 0000000000..0343fcb207 --- /dev/null +++ b/process/ViewTemplateData_lib/process.js @@ -0,0 +1,45 @@ + +/** + * Object to make the creation of a JSON for the Dynamic Form component simpler + * + * @param {String} [pFormDefinition] an already existing form JSON as string + */ +function DynamicFormDefinition (pFormDefinition) +{ + if (pFormDefinition) + this.fields = JSON.parse(pFormDefinition) + else + this.fields = []; +} + +DynamicFormDefinition.prototype.addField = function (pId, pName, pContentType, pMandatory, pReadOnly, pIsReadable) +{ + //TODO: check if id is unique + this.fields.push({ + id : pId, + name : pName, + contentType : pContentType || "TEXT", + isReadable : pIsReadable || true, + isWritable : !pReadOnly, + isRequired : pMandatory || false + }); + return this; +} + +DynamicFormDefinition.prototype.removeField = function (pId) +{ + for (let i = 0, l = this.fields.length; i < l; i++) + { + if (this.fields[i].id == pId) + { + this.fields.splice(i, 1); + return this; + } + } + return this; +} + +DynamicFormDefinition.prototype.toString = function () +{ + return JSON.stringify(this.fields); +} -- GitLab