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

Classification admin improvements

parent 5e52d51a
No related branches found
No related tags found
No related merge requests found
Showing
with 162 additions and 20 deletions
...@@ -8,12 +8,21 @@ ...@@ -8,12 +8,21 @@
<grantCreate v="false" /> <grantCreate v="false" />
<grantUpdate v="false" /> <grantUpdate v="false" />
<grantDelete v="false" /> <grantDelete v="false" />
<contentTitleProcess>%aditoprj%/entity/ClassificationAdmin_entity/contentTitleProcess.js</contentTitleProcess>
<usePermissions v="true" /> <usePermissions v="true" />
<titlePlural>Classifications</titlePlural> <titlePlural>Classifications</titlePlural>
<recordContainer>jdito</recordContainer> <recordContainer>jdito</recordContainer>
<entityFields> <entityFields>
<entityProvider> <entityProvider>
<name>#PROVIDER</name> <name>#PROVIDER</name>
<dependencies>
<entityDependency>
<name>75825cca-fbff-45a0-9a46-b1b0f639ae6a</name>
<entityName>Classification_entity</entityName>
<fieldName>ClassificationTypes</fieldName>
<isConsumer v="false" />
</entityDependency>
</dependencies>
</entityProvider> </entityProvider>
<entityField> <entityField>
<name>UID</name> <name>UID</name>
......
import("system.vars");
import("system.result");
result.string(vars.get("$field.UID.displayValue"))
\ No newline at end of file
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
<name>Classification_entity</name> <name>Classification_entity</name>
<majorModelMode>DISTRIBUTED</majorModelMode> <majorModelMode>DISTRIBUTED</majorModelMode>
<title>Classification</title> <title>Classification</title>
<grantDeleteProcess>%aditoprj%/entity/Classification_entity/grantDeleteProcess.js</grantDeleteProcess>
<afterOperatingState>%aditoprj%/entity/Classification_entity/afterOperatingState.js</afterOperatingState> <afterOperatingState>%aditoprj%/entity/Classification_entity/afterOperatingState.js</afterOperatingState>
<titlePlural>Classifications</titlePlural> <titlePlural>Classifications</titlePlural>
<recordContainer>jdito</recordContainer> <recordContainer>jdito</recordContainer>
...@@ -78,14 +79,14 @@ ...@@ -78,14 +79,14 @@
</entityField> </entityField>
<entityField> <entityField>
<name>CLASSIFICATIONGROUP</name> <name>CLASSIFICATIONGROUP</name>
<title>Classification group</title>
<contentType>TEXT</contentType> <contentType>TEXT</contentType>
<mandatoryProcess>%aditoprj%/entity/Classification_entity/entityfields/classificationgroup/mandatoryProcess.js</mandatoryProcess> <mandatoryProcess>%aditoprj%/entity/Classification_entity/entityfields/classificationgroup/mandatoryProcess.js</mandatoryProcess>
<dropDownProcess>%aditoprj%/entity/Classification_entity/entityfields/classificationgroup/dropDownProcess.js</dropDownProcess> <dropDownProcess>%aditoprj%/entity/Classification_entity/entityfields/classificationgroup/dropDownProcess.js</dropDownProcess>
<textInputAllowed v="true" /> <textInputAllowed v="true" />
<groupable v="true" /> <groupable v="true" />
<stateProcess>%aditoprj%/entity/Classification_entity/entityfields/classificationgroup/stateProcess.js</stateProcess> <titleProcess>%aditoprj%/entity/Classification_entity/entityfields/classificationgroup/titleProcess.js</titleProcess>
<displayValueProcess>%aditoprj%/entity/Classification_entity/entityfields/classificationgroup/displayValueProcess.js</displayValueProcess> <displayValueProcess>%aditoprj%/entity/Classification_entity/entityfields/classificationgroup/displayValueProcess.js</displayValueProcess>
<onValidation>%aditoprj%/entity/Classification_entity/entityfields/classificationgroup/onValidation.js</onValidation>
</entityField> </entityField>
<entityField> <entityField>
<name>CLASSIFICATIONTYPE_ID</name> <name>CLASSIFICATIONTYPE_ID</name>
...@@ -137,6 +138,9 @@ ...@@ -137,6 +138,9 @@
</entityParameter> </entityParameter>
<entityField> <entityField>
<name>CLASSIFICATIONTYPE</name> <name>CLASSIFICATIONTYPE</name>
<consumer>ClassificationTypes</consumer>
<groupable v="true" />
<state>EDITABLE</state>
<valueProcess>%aditoprj%/entity/Classification_entity/entityfields/classificationtype/valueProcess.js</valueProcess> <valueProcess>%aditoprj%/entity/Classification_entity/entityfields/classificationtype/valueProcess.js</valueProcess>
</entityField> </entityField>
<entityProvider> <entityProvider>
...@@ -178,6 +182,15 @@ ...@@ -178,6 +182,15 @@
<entityField> <entityField>
<name>SCORE_RESULTS</name> <name>SCORE_RESULTS</name>
</entityField> </entityField>
<entityConsumer>
<name>ClassificationTypes</name>
<fieldType>DEPENDENCY_OUT</fieldType>
<dependency>
<name>dependency</name>
<entityName>ClassificationAdmin_entity</entityName>
<fieldName>#PROVIDER</fieldName>
</dependency>
</entityConsumer>
</entityFields> </entityFields>
<recordContainers> <recordContainers>
<jDitoRecordContainer> <jDitoRecordContainer>
......
import("system.logging");
import("Classification_lib");
import("system.neon");
import("system.vars");
import("system.db"); import("system.db");
import("system.result"); import("system.result");
logging.log(vars.get("$param.IsAdminMode_param"))
result.object(db.table("select distinct CLASSIFICATIONGROUP, CLASSIFICATIONGROUP from CLASSIFICATIONTYPE order by CLASSIFICATIONGROUP")); if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.exists("$param.IsAdminMode_param") && vars.get("$param.IsAdminMode_param") == "1")
\ No newline at end of file {
logging.log(vars.get("$param.ClassificationType_param"))
logging.log(ClassificationUtils.getAllGroups(vars.get("$param.ClassificationType_param"), true).toSource())
result.object(ClassificationUtils.getAllGroups(vars.get("$param.ClassificationType_param"), true));
}
\ No newline at end of file
import("system.neon");
import("system.translate");
import("system.result");
import("system.vars");
import("Classification_lib");
import("Entity_lib");
if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT && vars.exists("$param.IsAdminMode_param") && vars.get("$param.IsAdminMode_param") == "1")
{
var newGroup = ProcessHandlingUtils.getOnValidationValue();
var groups = ClassificationUtils.getAllGroups(vars.get("$param.ClassificationType_param"), false)
if (groups.indexOf(newGroup, 0) != -1 && ClassificationUtils.getGroupFromDb(vars.get("$field.CLASSIFICATIONTYPEID")) != newGroup)
{
result.string(translate.text("The new Classification name already exists."));
}
}
import("system.neon");
import("system.result");
import("system.vars");
if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
{
result.string(neon.COMPONENTSTATE_AUTO);
}
else
{
result.string(neon.COMPONENTSTATE_DISABLED);
}
\ No newline at end of file
import("system.neon");
import("system.translate");
import("system.vars");
import("system.result");
if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.exists("$param.IsAdminMode_param") && vars.exists("$param.IsAdminMode_param") == "1")
{
result.string(translate.text("Group"));
}
else
{
result.string(translate.text("Group name"));
}
\ No newline at end of file
import("system.logging");
import("system.vars"); import("system.vars");
import("system.neon"); import("system.neon");
import("KeywordRegistry_basic"); import("KeywordRegistry_basic");
...@@ -5,6 +6,7 @@ import("KeywordRegistry_basic"); ...@@ -5,6 +6,7 @@ import("KeywordRegistry_basic");
var selection = vars.get("$sys.selectionRows"); var selection = vars.get("$sys.selectionRows");
if (selection.length > 0) if (selection.length > 0)
{ {
logging.log(selection.toSource())
var params = { var params = {
"ClassificationType_param" : vars.get("$param.ClassificationType_param"), "ClassificationType_param" : vars.get("$param.ClassificationType_param"),
"ObjectType_param" : vars.get("$param.ObjectType_param"), "ObjectType_param" : vars.get("$param.ObjectType_param"),
......
import("system.logging");
import("system.result");
import("system.db");
import("system.vars");
import("Sql_lib");
/*logging.log(db.cell(SqlCondition.begin()
.andPrepare("CLASSIFICATION.CLASSIFICATIONTYPE_ID", vars.get("$field.CLASSIFICATIONTYPEID"))
.buildSql("select count(*) from CLASSIFICATION", "1=2")))
/*result.object(parseInt(db.cell(SqlCondition.begin()
.andPrepare("CLASSIFICATION.CLASSIFICATIONTYPE_ID", vars.get("$field.CLASSIFICATIONTYPEID"))
.buildSql("select count(*) from CLASSIFICATION", "1=2"))) <= 0);*/
//{
/*db.deleteData("CLASSIFICATION", "CLASSIFICATION.CLASSIFICATIONTYPE_ID in (" + db.translateStatement(
SqlCondition.begin()
.andPrepare("CLASSIFICATIONTYPE.SCORETYPE", type)
.buildSql("select CLASSIFICATIONTYPE.CLASSIFICATIONTYPEID from CLASSIFICATIONTYPE", "1=2")) + ")");
db.deleteData("CLASSIFICATIONTYPE", SqlCondition.equals("CLASSIFICATIONTYPE.SCORETYPE", type, "1=2"));
db.deleteData("CLASSIFICATIONSCORE", SqlCondition.equals("CLASSIFICATIONSCORE.SCORETYPE", type, "1=2"));*/
//}
//neon.refreshAll();
\ No newline at end of file
import("system.logging");
import("Classification_lib"); import("Classification_lib");
import("system.vars"); import("system.vars");
import("Sql_lib"); import("Sql_lib");
...@@ -46,9 +47,18 @@ if (!classificationId) ...@@ -46,9 +47,18 @@ if (!classificationId)
.andSqlCondition(SqlCondition.begin().orPrepareVars("CLASSIFICATION.OBJECT_ROWID", "$param.ObjectRowid_param") .andSqlCondition(SqlCondition.begin().orPrepareVars("CLASSIFICATION.OBJECT_ROWID", "$param.ObjectRowid_param")
.or("CLASSIFICATION.OBJECT_ROWID is null")) .or("CLASSIFICATION.OBJECT_ROWID is null"))
} }
logging.log(db.translateStatement(cond.buildSql("select case when CLASSIFICATIONID is not null then 'C,' || CLASSIFICATIONID else 'T,' || CLASSIFICATIONTYPEID end, CLASSIFICATIONID, CLASSIFICATIONGROUP, CLASSIFICATIONSCORE_ID, CLASSIFICATIONTYPEID, CLASSIFICATIONTYPE_ID, OBJECT_TYPE, OBJECT_ROWID, SCORETYPE, CLASSIFICATIONTYPE.CLASSIFICATIONTYPE from CLASSIFICATION \n\
right join CLASSIFICATIONTYPE on " + db.translateCondition(SqlCondition.begin()
.and("CLASSIFICATIONTYPE_ID = CLASSIFICATIONTYPEID")
.andPrepareVars("CLASSIFICATION.OBJECT_TYPE", "$param.ObjectType_param")
.andPrepareVars("CLASSIFICATION.OBJECT_ROWID", "$param.ObjectRowid_param").build()), (admin ? "1=1" : "1=2"), "order by CLASSIFICATIONGROUP asc")))
result.object(db.table(cond.buildSql("select case when CLASSIFICATIONID is not null then 'C,' || CLASSIFICATIONID else 'T,' || CLASSIFICATIONTYPEID end, CLASSIFICATIONID, CLASSIFICATIONGROUP, CLASSIFICATIONSCORE_ID, CLASSIFICATIONTYPEID, CLASSIFICATIONTYPE_ID, OBJECT_TYPE, OBJECT_ROWID, SCORETYPE, CLASSIFICATIONTYPE.CLASSIFICATIONTYPE from CLASSIFICATION \n\ result.object(db.table(cond.buildSql("select case when CLASSIFICATIONID is not null then 'C,' || CLASSIFICATIONID else 'T,' || CLASSIFICATIONTYPEID end, CLASSIFICATIONID, CLASSIFICATIONGROUP, CLASSIFICATIONSCORE_ID, CLASSIFICATIONTYPEID, CLASSIFICATIONTYPE_ID, OBJECT_TYPE, OBJECT_ROWID, SCORETYPE, CLASSIFICATIONTYPE.CLASSIFICATIONTYPE from CLASSIFICATION \n\
right join CLASSIFICATIONTYPE on CLASSIFICATIONTYPE_ID = CLASSIFICATIONTYPEID", "1=2", "order by CLASSIFICATIONGROUP asc")) right join CLASSIFICATIONTYPE on " + db.translateCondition(SqlCondition.begin()
.and("CLASSIFICATIONTYPE_ID = CLASSIFICATIONTYPEID")
.andPrepareVars("CLASSIFICATION.OBJECT_TYPE", "$param.ObjectType_param")
.andPrepareVars("CLASSIFICATION.OBJECT_ROWID", "$param.ObjectRowid_param").build()), (admin ? "1=1" : "1=2"), "order by CLASSIFICATIONGROUP asc"))
.map(function(pRow) .map(function(pRow)
{ {
pRow.push(scores); pRow.push(scores);
......
import("Classification_lib");
import("system.logging");
import("system.neon"); import("system.neon");
import("system.util"); import("system.util");
import("Sql_lib"); import("Sql_lib");
...@@ -6,6 +8,7 @@ import("system.vars"); ...@@ -6,6 +8,7 @@ import("system.vars");
var changed = vars.get("$local.changed"); var changed = vars.get("$local.changed");
logging.log(vars.get("$field.CLASSIFICATIONID"))
// check if it already exists. Else it only exists as ScoreType but has no Classification-Entry // check if it already exists. Else it only exists as ScoreType but has no Classification-Entry
if (vars.get("$field.CLASSIFICATIONID")) if (vars.get("$field.CLASSIFICATIONID"))
{ {
...@@ -32,4 +35,22 @@ else if (vars.get("$field.CLASSIFICATIONSCORE_ID")) ...@@ -32,4 +35,22 @@ else if (vars.get("$field.CLASSIFICATIONSCORE_ID"))
]); ]);
neon.setFieldValue("$field.CLASSIFICATIONID", newId); neon.setFieldValue("$field.CLASSIFICATIONID", newId);
}
// update classificationgroup-name if it was changed (only in admin)
if (vars.exists("$param.IsAdminMode_param") && vars.exists("$param.IsAdminMode_param") == "1")
{
changed.forEach(function(change)
{
logging.log(change)
switch (change)
{
case "CLASSIFICATIONGROUP.value":
var oldGroupName = ClassificationUtils.getGroupFromDb(vars.get("$field.CLASSIFICATIONTYPEID"));
var newGroupName = vars.get("$field.CLASSIFICATIONGROUP");
ClassificationUtils.changeGroupName(oldGroupName, newGroupName, vars.get("$field.CLASSIFICATIONTYPE"))
}
})
} }
\ No newline at end of file
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
<defaultGroupFields> <defaultGroupFields>
<element>CLASSIFICATIONGROUP</element> <element>CLASSIFICATIONGROUP</element>
</defaultGroupFields> </defaultGroupFields>
<hideContentSearch v="true" />
<showChildrenCount v="false" /> <showChildrenCount v="false" />
<entryAction>edit</entryAction> <entryAction>edit</entryAction>
<entityField>#ENTITY</entityField> <entityField>#ENTITY</entityField>
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
<majorModelMode>DISTRIBUTED</majorModelMode> <majorModelMode>DISTRIBUTED</majorModelMode>
<isSmall v="true" /> <isSmall v="true" />
<layout> <layout>
<noneLayout> <drawerLayout>
<name>layout</name> <name>layout</name>
</noneLayout> <layoutCaption>Possible Values</layoutCaption>
</drawerLayout>
</layout> </layout>
<children> <children>
<genericMultipleViewTemplate> <genericMultipleViewTemplate>
......
import("system.logging");
import("system.vars");
import("system.db"); import("system.db");
import("Sql_lib"); import("Sql_lib");
...@@ -62,4 +64,33 @@ ClassificationUtils.mapToClass = function(pScore) ...@@ -62,4 +64,33 @@ ClassificationUtils.mapToClass = function(pScore)
return "A"; return "A";
return "_"; return "_";
}
ClassificationUtils.getAllGroups = function(pClassificationtype, twoCol)
{
var sql = SqlCondition.begin()
.andPrepare("CLASSIFICATIONTYPE.CLASSIFICATIONTYPE", pClassificationtype)
.buildSql("select distinct CLASSIFICATIONGROUP" + (twoCol ? ", CLASSIFICATIONGROUP" : "") + " from CLASSIFICATIONTYPE", "", " order by CLASSIFICATIONGROUP")
if (twoCol)
return db.table(sql);
else
return db.array(db.COLUMN, sql);
}
ClassificationUtils.getGroupFromDb = function(pClassificationtypeId)
{
return db.cell(SqlCondition.begin()
.andPrepare("CLASSIFICATIONTYPE.CLASSIFICATIONTYPEID", pClassificationtypeId)
.buildSql("select CLASSIFICATIONGROUP from CLASSIFICATIONTYPE", "", " order by CLASSIFICATIONGROUP"))
}
ClassificationUtils.changeGroupName = function(pOldName, pNewName, pClassificationType)
{
var groups = ClassificationUtils.getAllGroups(pClassificationType, false)
if (groups.indexOf(pNewName, 0) == -1)
{
db.updateData("CLASSIFICATIONTYPE", ["CLASSIFICATIONGROUP"], null, [pNewName], SqlCondition.equals("CLASSIFICATIONTYPE.CLASSIFICATIONGROUP", pOldName, "1=2"));
}
} }
\ No newline at end of file
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