Skip to content
Snippets Groups Projects
Commit 388f5b65 authored by Johannes Hörmann's avatar Johannes Hörmann
Browse files

enable / disable insert / edit buttons in relation tree

parent 4dd31b1f
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......
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
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
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
import("system.vars");
import("system.result");
result.string(vars.get("$field.INFO"));
\ No newline at end of file
......@@ -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);
......
......@@ -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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment