From 388f5b65c9cf05ab9bc6a640258ff5e1fda7a4d7 Mon Sep 17 00:00:00 2001 From: Johannes Hoermann <j.hoermann@adito.de> Date: Wed, 10 Apr 2019 14:27:22 +0200 Subject: [PATCH] enable / disable insert / edit buttons in relation tree --- .../ObjectTree_entity/ObjectTree_entity.aod | 5 +- .../alter/children/edit/stateProcess.js | 25 +++++++++ .../alter/children/insert/onActionProcess.js | 55 ++++++++++--------- .../alter/children/insert/stateProcess.js | 26 +++++++++ .../entityfields/info/tooltipProcess.js | 4 ++ .../recordcontainers/jdito/contentProcess.js | 18 +++--- .../_____PREFERENCES_PROJECT.aod | 2 +- 7 files changed, 96 insertions(+), 39 deletions(-) create mode 100644 entity/ObjectTree_entity/entityfields/alter/children/edit/stateProcess.js create mode 100644 entity/ObjectTree_entity/entityfields/alter/children/insert/stateProcess.js create mode 100644 entity/ObjectTree_entity/entityfields/info/tooltipProcess.js diff --git a/entity/ObjectTree_entity/ObjectTree_entity.aod b/entity/ObjectTree_entity/ObjectTree_entity.aod index a654c8f2aad..732a7815ac7 100644 --- a/entity/ObjectTree_entity/ObjectTree_entity.aod +++ b/entity/ObjectTree_entity/ObjectTree_entity.aod @@ -124,6 +124,7 @@ <title>Description</title> <contentType>LONG_TEXT</contentType> <searchable v="false" /> + <tooltipProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/info/tooltipProcess.js</tooltipProcess> </entityField> <entityField> <name>OBJECTRELATIONTYPEID</name> @@ -163,15 +164,15 @@ <name>insert</name> <fieldType>ACTION</fieldType> <onActionProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/alter/children/insert/onActionProcess.js</onActionProcess> - <isSelectionAction v="true" /> <iconId>VAADIN:FILE_TREE_SMALL</iconId> + <stateProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/alter/children/insert/stateProcess.js</stateProcess> </entityActionField> <entityActionField> <name>edit</name> <fieldType>ACTION</fieldType> <onActionProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/alter/children/edit/onActionProcess.js</onActionProcess> - <isSelectionAction v="true" /> <iconId>NEON:PENCIL</iconId> + <stateProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/alter/children/edit/stateProcess.js</stateProcess> </entityActionField> </children> </entityActionGroup> diff --git a/entity/ObjectTree_entity/entityfields/alter/children/edit/stateProcess.js b/entity/ObjectTree_entity/entityfields/alter/children/edit/stateProcess.js new file mode 100644 index 00000000000..e46436ab939 --- /dev/null +++ b/entity/ObjectTree_entity/entityfields/alter/children/edit/stateProcess.js @@ -0,0 +1,25 @@ +import("system.result"); +import("system.neon"); +import("system.vars"); + +if (vars.exists("$sys.selection") && vars.get("$sys.selection")) +{ + var selectedRows = JSON.parse(vars.get("$sys.selection")); + var isObjectRelationNode = false; + if (selectedRows.length > 0) + { + var uid = JSON.parse(selectedRows[0]); + isObjectRelationNode = typeof uid[2] == "string"; + } + + if (isObjectRelationNode) + { + result.string(neon.COMPONENTSTATE_EDITABLE) + } + else + { + result.string(neon.COMPONENTSTATE_DISABLED) + } +} +else + result.string(neon.COMPONENTSTATE_DISABLED) \ No newline at end of file diff --git a/entity/ObjectTree_entity/entityfields/alter/children/insert/onActionProcess.js b/entity/ObjectTree_entity/entityfields/alter/children/insert/onActionProcess.js index 16288da8047..2291f0b04c1 100644 --- a/entity/ObjectTree_entity/entityfields/alter/children/insert/onActionProcess.js +++ b/entity/ObjectTree_entity/entityfields/alter/children/insert/onActionProcess.js @@ -1,33 +1,34 @@ -import("ObjectRelation_lib"); +import("system.logging"); +import("system.result"); import("system.neon"); import("system.vars"); -if (vars.exists("$local.rows") && vars.get("$local.rows")) -{ - var selectedRows = JSON.parse(vars.get("$local.rows")); - var uid = JSON.parse(selectedRows[0]["#LOOKUPID"]); - var isObjectRelationNode = typeof uid[2] == "string"; - - var parentId; - var parentObjectType; - var relationType; - - if (isObjectRelationNode) - { - parentId = uid[0]; - parentObjectType = uid[3]; - } - else +if (vars.exists("$sys.selection") && vars.get("$sys.selection")) +{ + var selectedRows = JSON.parse(vars.get("$sys.selection")); + var isObjectRelationNode = false; + if (selectedRows.length > 0) { - parentId = vars.getString("$param.ObjectId_param"); - parentObjectType = vars.getString("$param.ObjectType_param"); - } - - var params = { - "ObjectId_param" : parentId, - "ObjectType_param" : parentObjectType, - "RelationType_param" : vars.get("$field.OBJECTRELATIONTYPEID") - }; + var uid = JSON.parse(selectedRows[0]); + isObjectRelationNode = typeof uid[2] == "string"; + + if (isObjectRelationNode) + { + parentId = uid[0]; + parentObjectType = uid[3]; + } + else + { + parentId = vars.getString("$param.ObjectId_param"); + parentObjectType = vars.getString("$param.ObjectType_param"); + } - neon.openContext("ObjectTree", "ObjectTreeEdit_view", null, neon.OPERATINGSTATE_NEW, params); + var params = { + "ObjectId_param" : parentId, + "ObjectType_param" : parentObjectType, + "RelationType_param" : vars.get("$field.OBJECTRELATIONTYPEID") + }; + + neon.openContext("ObjectTree", "ObjectTreeEdit_view", null, neon.OPERATINGSTATE_NEW, params); + } } \ No newline at end of file diff --git a/entity/ObjectTree_entity/entityfields/alter/children/insert/stateProcess.js b/entity/ObjectTree_entity/entityfields/alter/children/insert/stateProcess.js new file mode 100644 index 00000000000..5e1e7308c70 --- /dev/null +++ b/entity/ObjectTree_entity/entityfields/alter/children/insert/stateProcess.js @@ -0,0 +1,26 @@ +import("system.result"); +import("system.neon"); +import("system.vars"); +import("system.neon"); + +if (vars.exists("$sys.selection") && vars.get("$sys.selection")) +{ + var selectedRows = JSON.parse(vars.get("$sys.selection")); + var isObjectRelationNode = false; + if (selectedRows.length > 0) + { + var uid = JSON.parse(selectedRows[0]); + isObjectRelationNode = typeof uid[2] == "string"; + + if (!isObjectRelationNode || isObjectRelationNode && uid[7] == 1) + { + result.string(neon.COMPONENTSTATE_EDITABLE); + } + else + result.string(neon.COMPONENTSTATE_DISABLED); + } + else + result.string(neon.COMPONENTSTATE_DISABLED); +} +else + result.string(neon.COMPONENTSTATE_DISABLED); \ No newline at end of file diff --git a/entity/ObjectTree_entity/entityfields/info/tooltipProcess.js b/entity/ObjectTree_entity/entityfields/info/tooltipProcess.js new file mode 100644 index 00000000000..702c61b00fa --- /dev/null +++ b/entity/ObjectTree_entity/entityfields/info/tooltipProcess.js @@ -0,0 +1,4 @@ +import("system.vars"); +import("system.result"); + +result.string(vars.get("$field.INFO")); \ No newline at end of file diff --git a/entity/ObjectTree_entity/recordcontainers/jdito/contentProcess.js b/entity/ObjectTree_entity/recordcontainers/jdito/contentProcess.js index fe657ea0e68..850e7a7b8b5 100644 --- a/entity/ObjectTree_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/ObjectTree_entity/recordcontainers/jdito/contentProcess.js @@ -28,7 +28,7 @@ if (uidParam) if (isObjectRelationNode) { let relationTypeData = ObjectRelationUtils.getRelationType(uid[2]); - _insertEntry(tree, _getEntryData(uid[0], relationTypeData[3], relationTypeData[7], relationTypeData[8], undefined, false, uid[6]), "", 0, uid[3], relationTypeData[10]); + _insertEntry(tree, _getEntryData(uid[0], relationTypeData[3], relationTypeData[7], relationTypeData[8], undefined, false, uid[6]), "", 0, uid[3], relationTypeData[10], relationTypeData[4]); } } @@ -80,8 +80,8 @@ function _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId, relationTypeData = ObjectRelationUtils.getRelationType(relationTypeData[8]); currentObjectId = _getRootID(currentObjectId, relationTypeData); } - - let uids = _insertEntry(tree, [[currentObjectId, "", "", "", "", relationTypeData[7]]], pNodeId, pLayer, pObjectType, selectedRelationType) + // true to enable the insert button always --v + let uids = _insertEntry(tree, [[currentObjectId, "", "", "", "", relationTypeData[7]]], pNodeId, pLayer, pObjectType, selectedRelationType, true) for (let i = 0; i < uids.length; i++) { _loadObjectRelationTree(uids[i][0], uids[i][3], relationTypeData[0], uids[i], pLayer+1, relationTypeData); @@ -137,7 +137,7 @@ function _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId, relationTypeIdForNew = thisRelationTypeId; - let uids = _insertEntry(tree, myData, pNodeId, pLayer, destObjectType, relationTypeIdForNew) + let uids = _insertEntry(tree, myData, pNodeId, pLayer, destObjectType, relationTypeIdForNew, hierarchy) for (let i = 0; i < uids.length; i++) { _loadObjectRelationTree(uids[i][0], uids[i][3], pObjectRelationTypeId, uids[i], pLayer+1, pRelationTypeData); @@ -158,11 +158,11 @@ function _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId, relationTypeIdForNew = thisRelationTypeId // add both sides. Only one will succeed, because the prevObjectId will be filtered - _insertEntry(tree, entryData, pNodeId, pLayer, destObjectType, thisRelationTypeId, 0); + _insertEntry(tree, entryData, pNodeId, pLayer, destObjectType, thisRelationTypeId, hierarchy, 0); if (direction == "same") { var otherEntryData = _getEntryData(pNodeId[0], "normal", relationType1, relationType2, prevObjectId, true); - _insertEntry(tree, otherEntryData, pNodeId, pLayer, destObjectType, thisRelationTypeId, 1); + _insertEntry(tree, otherEntryData, pNodeId, pLayer, destObjectType, thisRelationTypeId, hierarchy, 1); } } } @@ -250,9 +250,9 @@ function _getRelationTypes(pObjectType) * @param {String} pNewRelationTypeId the RelationType, a new relation should have, if this node is selected. * @param {Integer} [pNum=undefined] optional number added to the key. Needed, if the key would not be unique. * - * @return {Array[][]} the uids of the inserted data. Consists of [ObjectId, pEntryData-Index, AB_OBJECTRELATIONTYPEID, pObjectType (from param), pNodeId, objecttype (from entryId), objectrelationid] + * @return {Array[][]} the uids of the inserted data. Consists of [ObjectId, pEntryData-Index, AB_OBJECTRELATIONTYPEID, pObjectType (from param), pNodeId, objecttype (from entryId), objectrelationid, hierarchy] */ -function _insertEntry(pTree, pEntryData, pNodeId, pLayer, pObjectType, pNewRelationTypeId, pNum) +function _insertEntry(pTree, pEntryData, pNodeId, pLayer, pObjectType, pNewRelationTypeId, pHierarchy, pNum) { var expanded = true; if (pLayer > 10) expanded = false; @@ -262,7 +262,7 @@ function _insertEntry(pTree, pEntryData, pNodeId, pLayer, pObjectType, pNewRelat { var display = db.cell(ContextUtils.getNameSql(pObjectType, pEntryData[i][0])); // TODO: Icon - var uid = [pEntryData[i][0], i, pEntryData[i][5], pObjectType, pNodeId, pEntryData[i][2], pEntryData[i][1]] + var uid = [pEntryData[i][0], i, pEntryData[i][5], pObjectType, pNodeId, pEntryData[i][2], pEntryData[i][1], pHierarchy] if (pNum) uid.push(pNum); uids.push(uid); diff --git a/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod b/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod index 2e627c2e517..35430f5089f 100644 --- a/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod +++ b/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod @@ -2,7 +2,7 @@ <preferences xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="3.1.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/preferences/3.1.0"> <name>_____PREFERENCES_PROJECT</name> <majorModelMode>DISTRIBUTED</majorModelMode> - <projectName>xRM-Basic2019</projectName> + <projectName>xRM-Basic5</projectName> <jditoMaxContentSize v="57671680" /> <calendarCategoriesEvent> <entry> -- GitLab