Skip to content
Snippets Groups Projects
Commit 306d9b67 authored by S.Listl's avatar S.Listl
Browse files

Attribute parent selection fixed

parent ef0f0ef9
No related branches found
No related tags found
No related merge requests found
Showing
with 1806 additions and 2557 deletions
......@@ -17,6 +17,10 @@ if (attrType == $AttributeTypes.COMBO)
.andPrepare("AB_ATTRIBUTE.ATTRIBUTE_TYPE", $AttributeTypes.COMBOVALUE)
.buildSql("select AB_ATTRIBUTEID, ATTRIBUTE_NAME from AB_ATTRIBUTE", "1=2", "order by SORTING asc");
var valueList = db.table(valueSql);
for (let i = 0; i < valueList.length; i++)
{
valueList[i][1] = translate.text(valueList[i][1]);
}
result.object(valueList);
}
else if (attrType == $AttributeTypes.BOOLEAN)
......
......@@ -16,7 +16,7 @@
</entityProvider>
<entityField>
<name>ATTRIBUTE_NAME</name>
<title>Name</title>
<title>Title (original language)</title>
<mandatory v="true" />
<state>EDITABLE</state>
</entityField>
......@@ -24,8 +24,7 @@
<name>ATTRIBUTE_TYPE</name>
<title>Type</title>
<consumer>KeywordAttributeTypes</consumer>
<mandatory v="false" />
<mandatoryProcess>%aditoprj%/entity/Attribute_entity/entityfields/attribute_type/mandatoryProcess.js</mandatoryProcess>
<mandatory v="true" />
<state>READONLY</state>
<stateProcess>%aditoprj%/entity/Attribute_entity/entityfields/attribute_type/stateProcess.js</stateProcess>
<valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/attribute_type/valueProcess.js</valueProcess>
......@@ -318,12 +317,6 @@
<expose v="true" />
<description>PARAMETER</description>
</entityParameter>
<entityParameter>
<name>AttributeTypeState_param</name>
<valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/attributetypestate_param/valueProcess.js</valueProcess>
<expose v="false" />
<description>PARAMETER</description>
</entityParameter>
</entityFields>
<recordContainers>
<jDitoRecordContainer>
......
import("system.result");
import("system.neon");
import("system.vars");
import("Attribute_lib");
var fieldState;
if(vars.get("$field.ATTRIBUTE_TYPE").trim() == $AttributeTypes.COMBOVALUE)
fieldState = neon.COMPONENTSTATE_READONLY;
else
fieldState = neon.COMPONENTSTATE_AUTO;
result.string(fieldState);
\ No newline at end of file
//import("system.result");
//import("system.neon");
//import("system.vars");
//import("Attribute_lib");
//
//var fieldState;
//if(vars.get("$field.ATTRIBUTE_TYPE").trim() == $AttributeTypes.COMBOVALUE)
// fieldState = neon.COMPONENTSTATE_READONLY;
//else
// fieldState = neon.COMPONENTSTATE_AUTO;
//
//result.string(fieldState);
\ No newline at end of file
import("system.db");
import("system.neon");
import("system.result");
import("system.vars");
import("Attribute_lib");
import("Keyword_lib");
import("KeywordRegistry_basic");
if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$field.ATTRIBUTE_PARENT_ID") != "")
{
var type = vars.get("$field.ATTRIBUTE_TYPE").trim();
result.string(KeywordUtils.getViewValue($KeywordRegistry.attributeType(), type));
import("system.db");
import("system.neon");
import("system.result");
import("system.vars");
import("Attribute_lib");
import("Keyword_lib");
import("KeywordRegistry_basic");
if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$field.ATTRIBUTE_PARENT_ID") != "")
{
var type = vars.get("$field.ATTRIBUTE_TYPE");
for (let i = 0; l = 36 - type.length; i++) //the key is always 36 characters long
type += " ";
result.string(KeywordUtils.getViewValue($KeywordRegistry.attributeType(), type));
}
\ No newline at end of file
import("system.vars");
import("system.result");
import("system.neon");
var res = true;
var state = vars.get("$param.AttributeTypeState_param");
if (state == neon.COMPONENTSTATE_READONLY)
res = false;
result.string(res);
\ No newline at end of file
import("system.logging");
import("system.db");
import("system.neon");
import("system.result");
import("system.vars");
var state = vars.get("$param.AttributeTypeState_param");
import("Attribute_lib");
import("Sql_lib");
result.string(state);
\ No newline at end of file
var state = neon.COMPONENTSTATE_EDITABLE;
if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
{
var type = vars.get("$field.ATTRIBUTE_TYPE").trim();
var parentType = AttributeUtil.getAttributeType(vars.get("$field.ATTRIBUTE_PARENT_ID"));
if (parentType == $AttributeTypes.COMBO || parentType == $AttributeTypes.VOID)
{
state = neon.COMPONENTSTATE_READONLY;
}
else if (AttributeTypeUtil.isGroupType(type))
{
var hasSubordinate = db.cell(SqlCondition.begin()
.andPrepareVars("AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID", "$field.UID")
.buildSql(
"select count(*) = 0 from AB_ATTRIBUTE", "1=2"
)
) != "true";
if (hasSubordinate)
state = neon.COMPONENTSTATE_READONLY;
}
else if (AttributeUtil.hasRelations(vars.get("$field.UID")))
state = neon.COMPONENTSTATE_READONLY;
}
result.string(state)
\ No newline at end of file
import("system.db");
import("system.neon");
import("system.result");
import("system.vars");
import("Attribute_lib");
if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$field.ATTRIBUTE_PARENT_ID") != "")
{
var type = AttributeUtil.getAttributeType(vars.get("$field.ATTRIBUTE_PARENT_ID"));
if (type == $AttributeTypes.COMBO)
result.string($AttributeTypes.COMBOVALUE);
else if (type == $AttributeTypes.VOID)
result.string($AttributeTypes.VOID);
import("system.db");
import("system.neon");
import("system.result");
import("system.vars");
import("Attribute_lib");
if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$field.ATTRIBUTE_PARENT_ID") != "")
{
var type = AttributeUtil.getAttributeType(vars.get("$field.ATTRIBUTE_PARENT_ID"));
if (type == $AttributeTypes.COMBO)
result.string($AttributeTypes.COMBOVALUE);
else if (type == $AttributeTypes.VOID)
result.string($AttributeTypes.VOID);
else if (vars.get("$this.value") == $AttributeTypes.COMBOVALUE)
result.string("");
}
\ No newline at end of file
import("system.db");
import("system.neon");
import("system.result");
import("system.vars");
import("Attribute_lib");
import("Sql_lib");
var state = neon.COMPONENTSTATE_AUTO;
if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT)
{
var type = vars.get("$field.ATTRIBUTE_TYPE").trim();
var parentType = AttributeUtil.getAttributeType(vars.get("$field.ATTRIBUTE_PARENT_ID"));
if (parentType == $AttributeTypes.COMBO || parentType == $AttributeTypes.VOID)
{
state = neon.COMPONENTSTATE_READONLY;
}
else if (AttributeTypeUtil.isGroupType(type))
{
var hasSubordinate = db.cell(SqlCondition.begin()
.andPrepareVars("AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID", "$field.UID")
.buildSql(
"select count(AB_ATTRIBUTEID) from AB_ATTRIBUTE", "1=2"
)
) > 0;
if (hasSubordinate)
state = neon.COMPONENTSTATE_READONLY;
}
else if (AttributeUtil.hasRelations(vars.get("$field.UID")))
state = neon.COMPONENTSTATE_READONLY;
}
result.string(state)
\ No newline at end of file
......@@ -41,8 +41,7 @@ else if (getGroups) //if getGroups == true, it is the lookup for selecting the s
var isGroupCondition = SqlCondition.begin();
for (let type in $AttributeTypes)
if ($AttributeTypes[type].isGroup && $AttributeTypes[type] != $AttributeTypes.COMBO
&& (parentType == $AttributeTypes.VOID || $AttributeTypes[type] != $AttributeTypes.VOID))
if ($AttributeTypes[type].isGroup)
{
isGroupCondition.orPrepare(["AB_ATTRIBUTE", "ATTRIBUTE_TYPE", uidTableAlias], $AttributeTypes[type]);
}
......@@ -74,6 +73,19 @@ else if (objectType) //if there's an objectType, it comes from the AttributeRel
fetchUsages = false;
translateName = true;
}
else if (parentType) //condition for all subordinate attributes of an attribute (for the tree of subordinate attributes in an attribute)
{
if (AttributeTypeUtil.isGroupType(parentType))
{
var parentId = vars.exists("$param.AttrParentId_param") && vars.get("$param.AttrParentId_param");
if (parentId)
condition.and("UIDROW.AB_ATTRIBUTEID in ('" + AttributeUtil.getAllChildren(vars.getString("$param.AttrParentId_param")).join("','") + "')");
}
else
condition.and("1=2");
translateName = true;
}
//when there are filters selected, add them to the conditon
if (vars.exists("$local.filter") && vars.get("$local.filter"))
......@@ -156,30 +168,31 @@ function _buildAttributeTable (pAttributes, pUsages, pTranslate)
}
return sortedArray;
}
/**
* builds the full attribute name from the pre-loaded parent names and adds all parent names
* if required
*/
function _getFullName (pAttributeName, pParent1Name, pParent2Name, pParent3Name, pParent4Id, pTranslate)
{
var parent4FullName;
if (pParent4Id && pParent4Id in nameCache)
parent4FullName = nameCache[pParent4Id];
else
{
parent4FullName = pParent4Id ? AttributeUtil.getFullAttributeName(pParent4Id, false, pTranslate) : null;
nameCache[pParent4Id] = parent4FullName;
}
if (pTranslate)
/**
* builds the full attribute name from the pre-loaded parent names and adds all parent names
* if required
*/
function _getFullName (pAttributeName, pParent1Name, pParent2Name, pParent3Name, pParent4Id)
{
pAttributeName = translate.text(pAttributeName);
pParent1Name = translate.text(pParent1Name);
pParent2Name = translate.text(pParent2Name);
pParent3Name = translate.text(pParent3Name);
var parent4FullName;
if (pParent4Id && pParent4Id in nameCache)
parent4FullName = nameCache[pParent4Id];
else
{
parent4FullName = pParent4Id ? AttributeUtil.getFullAttributeName(pParent4Id, false, pTranslate) : null;
nameCache[pParent4Id] = parent4FullName;
}
if (pTranslate)
{
pAttributeName = translate.text(pAttributeName);
pParent1Name = translate.text(pParent1Name);
pParent2Name = translate.text(pParent2Name);
pParent3Name = translate.text(pParent3Name);
}
pAttributeName = ArrayUtils.joinNonEmptyFields([parent4FullName, pParent3Name, pParent2Name, pParent1Name, pAttributeName], " / ");
return pAttributeName;
}
pAttributeName = ArrayUtils.joinNonEmptyFields([parent4FullName, pParent3Name, pParent2Name, pParent1Name, pAttributeName], " / ");
return pAttributeName;
}
......@@ -199,9 +199,6 @@
<fieldName>Documents</fieldName>
</dependency>
<children>
<entityParameter>
<name>AssignmentName_param</name>
</entityParameter>
<entityParameter>
<name>AssignmentTable_param</name>
<valueProcess>%aditoprj%/entity/Employee_entity/entityfields/documents/children/assignmenttable_param/valueProcess.js</valueProcess>
......
import("system.result");
result.string("87d4ff5b-0ab6-4534-be26-76c6ef486072");
\ No newline at end of file
import("AttributeRegistry_basic");
import("system.result");
result.string($AttributeRegistry.departments());
\ No newline at end of file
import("system.neon");
import("Context_lib");
openAdminView();
function openAdminView (pViewName)
{
var context = ContextUtils.getCurrentContextId();
if (!pViewName)
pViewName = context + "Admin_view"
neon.openContext(context, pViewName, id, neon.OPERATINGSTATE_VIEW, null);
}
\ No newline at end of file
......@@ -15,3 +15,4 @@ $AttributeRegistry.paymentTerm = function(){return "292fae38-6557-466d-8843-3b1b
$AttributeRegistry.deliveryTerm = function(){return "3a6e11fc-b00a-4cf3-975a-a5e8b60fc5cb";};
$AttributeRegistry.targetGroup = function(){return "c7d28377-8cb1-4f92-a9ac-ed08041a782b";};
$AttributeRegistry.targetGroup$competitior = function(){return "1d30d0ab-6103-4972-84c0-fd23eef15ca1";};
$AttributeRegistry.departments = function(){return "87d4ff5b-0ab6-4534-be26-76c6ef486072";};
import("system.logging");
import("KeywordRegistry_basic");
import("KeywordData_lib");
import("system.vars");
......
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