From 8cddb29f3c42347e8f749e4f4bce116536ee77a0 Mon Sep 17 00:00:00 2001
From: "S.Listl" <S.Listl@SLISTL.aditosoftware.local>
Date: Wed, 2 Oct 2019 13:04:17 +0000
Subject: [PATCH] Attribute DropDownDefinition fix

(cherry picked from commit 3e5544d3ebb9362f112b6521395263a5f10fe5c7)
---
 entity/Attribute_entity/Attribute_entity.aod              | 2 +-
 .../entityfields/attribute_type/onValueChange.js          | 8 --------
 .../entityfields/dropdowndefinition/stateProcess.js       | 4 +---
 .../entityfields/dropdowndefinition/valueProcess.js       | 7 +++++++
 4 files changed, 9 insertions(+), 12 deletions(-)
 delete mode 100644 entity/Attribute_entity/entityfields/attribute_type/onValueChange.js
 create mode 100644 entity/Attribute_entity/entityfields/dropdowndefinition/valueProcess.js

diff --git a/entity/Attribute_entity/Attribute_entity.aod b/entity/Attribute_entity/Attribute_entity.aod
index 316aa16f8e..13cc5acc14 100644
--- a/entity/Attribute_entity/Attribute_entity.aod
+++ b/entity/Attribute_entity/Attribute_entity.aod
@@ -37,7 +37,6 @@
       <stateProcess>%aditoprj%/entity/Attribute_entity/entityfields/attribute_type/stateProcess.js</stateProcess>
       <valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/attribute_type/valueProcess.js</valueProcess>
       <displayValueProcess>%aditoprj%/entity/Attribute_entity/entityfields/attribute_type/displayValueProcess.js</displayValueProcess>
-      <onValueChange>%aditoprj%/entity/Attribute_entity/entityfields/attribute_type/onValueChange.js</onValueChange>
     </entityField>
     <entityField>
       <name>ATTRIBUTE_PARENT_ID</name>
@@ -186,6 +185,7 @@
       <dropDownProcess>%aditoprj%/entity/Attribute_entity/entityfields/dropdowndefinition/dropDownProcess.js</dropDownProcess>
       <stateProcess>%aditoprj%/entity/Attribute_entity/entityfields/dropdowndefinition/stateProcess.js</stateProcess>
       <titleProcess>%aditoprj%/entity/Attribute_entity/entityfields/dropdowndefinition/titleProcess.js</titleProcess>
+      <valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/dropdowndefinition/valueProcess.js</valueProcess>
     </entityField>
     <entityParameter>
       <name>AttrParentType_param</name>
diff --git a/entity/Attribute_entity/entityfields/attribute_type/onValueChange.js b/entity/Attribute_entity/entityfields/attribute_type/onValueChange.js
deleted file mode 100644
index 24139923a7..0000000000
--- a/entity/Attribute_entity/entityfields/attribute_type/onValueChange.js
+++ /dev/null
@@ -1,8 +0,0 @@
-import("system.neon");
-import("system.vars");
-import("Attribute_lib");
-import("Entity_lib");
-
-var type = vars.get("local.value") || "";
-if (type.trim() != $AttributeTypes.KEYWORD && vars.exists("$field.DROPDOWNDEFINITION") && vars.get("$field.DROPDOWNDEFINITION"))
-    neon.setFieldValue("$field.DROPDOWNDEFINITION", "");
\ No newline at end of file
diff --git a/entity/Attribute_entity/entityfields/dropdowndefinition/stateProcess.js b/entity/Attribute_entity/entityfields/dropdowndefinition/stateProcess.js
index f4447a5915..e7b5653772 100644
--- a/entity/Attribute_entity/entityfields/dropdowndefinition/stateProcess.js
+++ b/entity/Attribute_entity/entityfields/dropdowndefinition/stateProcess.js
@@ -8,9 +8,7 @@ var type = vars.get("$field.ATTRIBUTE_TYPE").trim();
 if (type && $AttributeTypes[type] && $AttributeTypes[type].getDropDownDefinitions
         && !AttributeUtil.hasRelations(vars.get("$field.UID")))
     fieldState = neon.COMPONENTSTATE_EDITABLE;
-else if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_VIEW)
-    fieldState = neon.COMPONENTSTATE_INVISIBLE;
 else
-    fieldState = neon.COMPONENTSTATE_READONLY;
+    fieldState = neon.COMPONENTSTATE_INVISIBLE;
 
 result.string(fieldState);
\ No newline at end of file
diff --git a/entity/Attribute_entity/entityfields/dropdowndefinition/valueProcess.js b/entity/Attribute_entity/entityfields/dropdowndefinition/valueProcess.js
new file mode 100644
index 0000000000..009292106e
--- /dev/null
+++ b/entity/Attribute_entity/entityfields/dropdowndefinition/valueProcess.js
@@ -0,0 +1,7 @@
+import("system.result");
+import("system.vars");
+import("Attribute_lib");
+
+var type = vars.get("$field.ATTRIBUTE_TYPE").trim();
+if (type && $AttributeTypes[type] && typeof($AttributeTypes[type].getDropDownDefinitions) !== "function")
+    result.string("");
\ No newline at end of file
-- 
GitLab