diff --git a/entity/ObservationMultiple_entity/ObservationMultiple_entity.aod b/entity/ObservationMultiple_entity/ObservationMultiple_entity.aod new file mode 100644 index 0000000000000000000000000000000000000000..2f9186f4f69144ae457fa6dcadbc871057f6643f --- /dev/null +++ b/entity/ObservationMultiple_entity/ObservationMultiple_entity.aod @@ -0,0 +1,153 @@ +<?xml version="1.0" encoding="UTF-8"?> +<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.3.18" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.3.18"> + <name>ObservationMultiple_entity</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <documentation>%aditoprj%/entity/ObservationMultiple_entity/documentation.adoc</documentation> + <siblings> + <element>Observation_entity</element> + </siblings> + <recordContainer>dataless</recordContainer> + <entityFields> + <entityProvider> + <name>#PROVIDER</name> + </entityProvider> + <entityProvider> + <name>#PROVIDER_AGGREGATES</name> + <useAggregates v="true" /> + </entityProvider> + <entityField> + <name>TRIGGEREVENTUPDATE</name> + <title>Update</title> + <contentType>BOOLEAN</contentType> + <groupable v="false" /> + <state>EDITABLE</state> + <valueProcess>%aditoprj%/entity/ObservationMultiple_entity/entityfields/triggereventupdate/valueProcess.js</valueProcess> + </entityField> + <entityField> + <name>TRIGGEREVENTINSERT</name> + <title>Insert</title> + <contentType>BOOLEAN</contentType> + <groupable v="false" /> + <state>EDITABLE</state> + <valueProcess>%aditoprj%/entity/ObservationMultiple_entity/entityfields/triggereventinsert/valueProcess.js</valueProcess> + </entityField> + <entityField> + <name>TRIGGEREVENTDELETE</name> + <title>Delete</title> + <contentType>BOOLEAN</contentType> + <groupable v="false" /> + <state>EDITABLE</state> + <valueProcess>%aditoprj%/entity/ObservationMultiple_entity/entityfields/triggereventdelete/valueProcess.js</valueProcess> + </entityField> + <entityField> + <name>OBJECT_FIELD</name> + <title>Fields</title> + <contentType>TEXT</contentType> + <dropDownProcess>%aditoprj%/entity/ObservationMultiple_entity/entityfields/object_field/dropDownProcess.js</dropDownProcess> + <selectionMode>MULTI</selectionMode> + <state>EDITABLE</state> + <stateProcess>%aditoprj%/entity/ObservationMultiple_entity/entityfields/object_field/stateProcess.js</stateProcess> + <valueProcess>%aditoprj%/entity/ObservationMultiple_entity/entityfields/object_field/valueProcess.js</valueProcess> + </entityField> + <entityField> + <name>NOTIFICATION_PRIO</name> + <title>Priority</title> + <consumer>PrioKeywords</consumer> + <state>EDITABLE</state> + <valueProcess>%aditoprj%/entity/ObservationMultiple_entity/entityfields/notification_prio/valueProcess.js</valueProcess> + <displayValueProcess>%aditoprj%/entity/ObservationMultiple_entity/entityfields/notification_prio/displayValueProcess.js</displayValueProcess> + </entityField> + <entityField> + <name>includeDependencies</name> + <title>incl. Dependencies</title> + <contentType>BOOLEAN</contentType> + <state>EDITABLE</state> + <valueProcess>%aditoprj%/entity/ObservationMultiple_entity/entityfields/includedependencies/valueProcess.js</valueProcess> + </entityField> + <entityField> + <name>OBSERVER</name> + <title>Observer</title> + <consumer>Users</consumer> + <groupable v="true" /> + <mandatory v="true" /> + <state>READONLY</state> + <valueProcess>%aditoprj%/entity/ObservationMultiple_entity/entityfields/observer/valueProcess.js</valueProcess> + <displayValueProcess>%aditoprj%/entity/ObservationMultiple_entity/entityfields/observer/displayValueProcess.js</displayValueProcess> + </entityField> + <entityField> + <name>OBJECT_TYPE</name> + <title>Object Type</title> + <consumer>Contexts</consumer> + <groupable v="false" /> + <mandatory v="true" /> + <state>READONLY</state> + <valueProcess>%aditoprj%/entity/ObservationMultiple_entity/entityfields/object_type/valueProcess.js</valueProcess> + <displayValueProcess>%aditoprj%/entity/ObservationMultiple_entity/entityfields/object_type/displayValueProcess.js</displayValueProcess> + </entityField> + <entityActionField> + <name>addObservations</name> + <onActionProcess>%aditoprj%/entity/ObservationMultiple_entity/entityfields/addobservations/onActionProcess.js</onActionProcess> + <titleProcess>%aditoprj%/entity/ObservationMultiple_entity/entityfields/addobservations/titleProcess.js</titleProcess> + </entityActionField> + <entityParameter> + <name>Observer_param</name> + <valueProcess>%aditoprj%/entity/ObservationMultiple_entity/entityfields/observer_param/valueProcess.js</valueProcess> + <expose v="true" /> + </entityParameter> + <entityParameter> + <name>ObjectType_param</name> + <expose v="true" /> + <mandatory v="false" /> + </entityParameter> + <entityConsumer> + <name>Contexts</name> + <dependency> + <name>dependency</name> + <entityName>Context_entity</entityName> + <fieldName>Exclusive</fieldName> + </dependency> + <children> + <entityParameter> + <name>Blacklist_param</name> + <valueProcess>%aditoprj%/entity/ObservationMultiple_entity/entityfields/contexts/children/blacklist_param/valueProcess.js</valueProcess> + </entityParameter> + <entityParameter> + <name>InvertBlacklist_param</name> + <valueProcess>%aditoprj%/entity/ObservationMultiple_entity/entityfields/contexts/children/invertblacklist_param/valueProcess.js</valueProcess> + </entityParameter> + </children> + </entityConsumer> + <entityConsumer> + <name>PrioKeywords</name> + <dependency> + <name>dependency</name> + <entityName>KeywordEntry_entity</entityName> + <fieldName>#PROVIDER</fieldName> + </dependency> + <children> + <entityParameter> + <name>ContainerName_param</name> + <valueProcess>%aditoprj%/entity/ObservationMultiple_entity/entityfields/priokeywords/children/containername_param/valueProcess.js</valueProcess> + </entityParameter> + </children> + </entityConsumer> + <entityConsumer> + <name>Users</name> + <dependency> + <name>dependency</name> + <entityName>Employee_entity</entityName> + <fieldName>EmployeesByUserId</fieldName> + </dependency> + </entityConsumer> + <entityParameter> + <name>ObjectIds_param</name> + <expose v="true" /> + </entityParameter> + </entityFields> + <recordContainers> + <datalessRecordContainer> + <name>dataless</name> + <alias>Data_alias</alias> + </datalessRecordContainer> + </recordContainers> +</entity> diff --git a/entity/ObservationMultiple_entity/documentation.adoc b/entity/ObservationMultiple_entity/documentation.adoc new file mode 100644 index 0000000000000000000000000000000000000000..cf6bba8ba432275e48b53876bff4401b3f58659b --- /dev/null +++ b/entity/ObservationMultiple_entity/documentation.adoc @@ -0,0 +1,4 @@ += ObservationMultible_entity + +This entity handling the seriel action to add more than one observation. +This action can´t be done with the Observation_entity, because a entity displays always one dataset. \ No newline at end of file diff --git a/entity/ObservationMultiple_entity/entityfields/addobservations/onActionProcess.js b/entity/ObservationMultiple_entity/entityfields/addobservations/onActionProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..186340d602bd55708ca6435b69786b4ad0727cd7 --- /dev/null +++ b/entity/ObservationMultiple_entity/entityfields/addobservations/onActionProcess.js @@ -0,0 +1,41 @@ +import("Sql_lib"); +import("system.entities"); +import("system.neon"); +import("system.vars"); + +var objectIds = JSON.parse(vars.getString("$param.ObjectIds_param")); + +var currentExitsObservations = newSelect("OBSERVATION.OBJECT_ID") + .from("OBSERVATION") + .where("OBSERVATION.OBJECT_TYPE", vars.get("$field.OBJECT_TYPE")) + .and("OBSERVATION.OBSERVER", vars.get("$field.OBSERVER")) + .and("OBSERVATION.TRIGGEREVENTDELETE", vars.get("$field.TRIGGEREVENTDELETE")) + .and("OBSERVATION.TRIGGEREVENTINSERT", vars.get("$field.TRIGGEREVENTINSERT")) + .and("OBSERVATION.TRIGGEREVENTUPDATE", vars.get("$field.TRIGGEREVENTUPDATE")) + .and("OBSERVATION.NOTIFICATION_PRIO", vars.get("$field.NOTIFICATION_PRIO")) + .and("OBSERVATION.OBJECT_ID", objectIds, SqlBuilder.IN()).arrayColumn(); + +// filter the allredy observed ids +objectIds = objectIds.filter(function (id) { + return !currentExitsObservations.includes(id); +}); + +var fields = { + "OBJECT_TYPE" : vars.get("$field.OBJECT_TYPE"), + "OBSERVER" : vars.get("$field.OBSERVER"), + "OBJECT_FIELD" : vars.get("$field.OBJECT_FIELD"), + "includeDependencies" : vars.get("$field.includeDependencies") == "1", + "TRIGGEREVENTDELETE" : vars.get("$field.TRIGGEREVENTDELETE") == "1", + "TRIGGEREVENTINSERT" : vars.get("$field.TRIGGEREVENTINSERT") == "1", + "TRIGGEREVENTUPDATE" : vars.get("$field.TRIGGEREVENTUPDATE") == "1", + "NOTIFICATION_PRIO" : vars.get("$field.NOTIFICATION_PRIO") + } + +let createRowConfig = entities.createConfigForAddingRows() + .entity("Observation_entity"); + + +objectIds.forEach(function (pObservationId) { + fields.OBJECT_ID = pObservationId; + entities.createRow(createRowConfig.fieldValues(fields)); +}); \ No newline at end of file diff --git a/entity/ObservationMultiple_entity/entityfields/addobservations/titleProcess.js b/entity/ObservationMultiple_entity/entityfields/addobservations/titleProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..f0bb020357d333ed7d2712953cb239ad2feb3782 --- /dev/null +++ b/entity/ObservationMultiple_entity/entityfields/addobservations/titleProcess.js @@ -0,0 +1,8 @@ +import("system.result"); +import("Sql_lib"); +import("system.vars"); +import("system.translate"); + +var objectIds = JSON.parse(vars.getString("$param.ObjectIds_param")); + +result.string(translate.withArguments("Add %0 Observations", [objectIds.length])); \ No newline at end of file diff --git a/entity/ObservationMultiple_entity/entityfields/contexts/children/blacklist_param/valueProcess.js b/entity/ObservationMultiple_entity/entityfields/contexts/children/blacklist_param/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..c40747f7e7256dd47edf175310a55a6b7293c3a3 --- /dev/null +++ b/entity/ObservationMultiple_entity/entityfields/contexts/children/blacklist_param/valueProcess.js @@ -0,0 +1,5 @@ +import("Observation_lib"); +import("system.vars"); +import("system.result"); + +result.object(Observation.getContextFields(vars.get("$field.OBSERVATION_ID"))); \ No newline at end of file diff --git a/entity/ObservationMultiple_entity/entityfields/contexts/children/invertblacklist_param/valueProcess.js b/entity/ObservationMultiple_entity/entityfields/contexts/children/invertblacklist_param/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..40effa0178464da0c7850912345f19c7fa95975a --- /dev/null +++ b/entity/ObservationMultiple_entity/entityfields/contexts/children/invertblacklist_param/valueProcess.js @@ -0,0 +1,3 @@ +import("system.result"); + +result.string(true); \ No newline at end of file diff --git a/entity/ObservationMultiple_entity/entityfields/includedependencies/valueProcess.js b/entity/ObservationMultiple_entity/entityfields/includedependencies/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..35371aba2179658a5d577832af3e554dd072c340 --- /dev/null +++ b/entity/ObservationMultiple_entity/entityfields/includedependencies/valueProcess.js @@ -0,0 +1,8 @@ +import("system.vars"); +import("system.result"); + +if (vars.get("$this.value") == null) +{ + result.string("1"); +} + \ No newline at end of file diff --git a/entity/ObservationMultiple_entity/entityfields/notification_prio/displayValueProcess.js b/entity/ObservationMultiple_entity/entityfields/notification_prio/displayValueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..0f475486d679f56d4a977f7e00a5cdb544331bbf --- /dev/null +++ b/entity/ObservationMultiple_entity/entityfields/notification_prio/displayValueProcess.js @@ -0,0 +1,6 @@ +import("system.result"); +import("system.vars"); +import("KeywordRegistry_basic"); +import("Keyword_lib"); + +result.string(KeywordUtils.getViewValue($KeywordRegistry.notificationPriority(), vars.get("$this.value"))); \ No newline at end of file diff --git a/entity/ObservationMultiple_entity/entityfields/notification_prio/valueProcess.js b/entity/ObservationMultiple_entity/entityfields/notification_prio/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..3a1600efc791c121ec23f293d72ad1a6de66f289 --- /dev/null +++ b/entity/ObservationMultiple_entity/entityfields/notification_prio/valueProcess.js @@ -0,0 +1,9 @@ +import("KeywordRegistry_basic"); +import("system.result"); +import("system.vars"); + +if (!vars.get("$this.value")) +{ + result.string($KeywordRegistry.notificationPriority$normal()); +} + \ No newline at end of file diff --git a/entity/ObservationMultiple_entity/entityfields/object_field/dropDownProcess.js b/entity/ObservationMultiple_entity/entityfields/object_field/dropDownProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..b0d5277bc58c7f968310c549db58fa67fa61e917 --- /dev/null +++ b/entity/ObservationMultiple_entity/entityfields/object_field/dropDownProcess.js @@ -0,0 +1,6 @@ +import("system.result"); +import("Observation_lib"); +import("system.vars"); + + +result.object(Observation.getAllPosibleFields(vars.get("$field.OBJECT_TYPE"))); diff --git a/entity/ObservationMultiple_entity/entityfields/object_field/stateProcess.js b/entity/ObservationMultiple_entity/entityfields/object_field/stateProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..9c287ee5a33089d7ec613102f8e2d30350e87f6c --- /dev/null +++ b/entity/ObservationMultiple_entity/entityfields/object_field/stateProcess.js @@ -0,0 +1,12 @@ +import("system.neon"); +import("system.vars"); +import("system.result"); + +if (vars.get("$field.OBJECT_TYPE")) +{ + result.string(neon.COMPONENTSTATE_EDITABLE); +} +else +{ + result.string(neon.COMPONENTSTATE_INVISIBLE); +} diff --git a/entity/ObservationMultiple_entity/entityfields/object_field/valueProcess.js b/entity/ObservationMultiple_entity/entityfields/object_field/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..6f113be8802678fc4c8dae77865af8f1c5fae8e7 --- /dev/null +++ b/entity/ObservationMultiple_entity/entityfields/object_field/valueProcess.js @@ -0,0 +1,10 @@ +import("system.vars"); +import("Observation_lib"); +import("system.result"); +import("system.neon"); + +if (!vars.get("$this.value") && vars.get("$field.OBJECT_TYPE") && (vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_NEW || vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_EDIT)) +{ + result.string(Observation.getAllFieldValue(vars.get("$field.OBJECT_TYPE"))); +} + \ No newline at end of file diff --git a/entity/ObservationMultiple_entity/entityfields/object_type/displayValueProcess.js b/entity/ObservationMultiple_entity/entityfields/object_type/displayValueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..76e020b3aadd1b62511b0efabc1179d3ec962140 --- /dev/null +++ b/entity/ObservationMultiple_entity/entityfields/object_type/displayValueProcess.js @@ -0,0 +1,12 @@ +import("system.translate"); +import("system.result"); +import("system.vars"); +import("Context_lib"); + +let type = vars.get("$field.OBJECT_TYPE"); + +if (type) +{ + result.string(translate.text(ContextUtils.getContextName(type))); +} + \ No newline at end of file diff --git a/entity/ObservationMultiple_entity/entityfields/object_type/valueProcess.js b/entity/ObservationMultiple_entity/entityfields/object_type/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..f55eb81a7a63ace42ea29a12606eee16090ce678 --- /dev/null +++ b/entity/ObservationMultiple_entity/entityfields/object_type/valueProcess.js @@ -0,0 +1,8 @@ +import("system.result"); +import("system.neon"); +import("system.vars"); + +if (!vars.get("$this.value") && vars.exists("$param.ObjectType_param") && vars.get("$param.ObjectType_param")) +{ + result.string(vars.get("$param.ObjectType_param")); +} \ No newline at end of file diff --git a/entity/ObservationMultiple_entity/entityfields/observer/displayValueProcess.js b/entity/ObservationMultiple_entity/entityfields/observer/displayValueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..19d424b79d975bd806ed0caf351c834dcac80174 --- /dev/null +++ b/entity/ObservationMultiple_entity/entityfields/observer/displayValueProcess.js @@ -0,0 +1,9 @@ +import("system.result"); +import("system.vars"); +import("system.tools"); + +var user = tools.getUserByAttribute(tools.NAME, vars.get("$field.OBSERVER"), tools.PROFILE_DEFAULT); +if (user) +{ + result.string((user.params.firstname + " " + user.params.lastname).trim()); +} \ No newline at end of file diff --git a/entity/ObservationMultiple_entity/entityfields/observer/valueProcess.js b/entity/ObservationMultiple_entity/entityfields/observer/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..be2b76bc769be6a403542e67c452d5f14ac643c3 --- /dev/null +++ b/entity/ObservationMultiple_entity/entityfields/observer/valueProcess.js @@ -0,0 +1,8 @@ +import("system.result"); +import("system.vars") + +if (!vars.get("$this.value") && vars.get("$param.Observer_param")) +{ + result.string(vars.get("$param.Observer_param")); +} + \ No newline at end of file diff --git a/entity/ObservationMultiple_entity/entityfields/observer_param/valueProcess.js b/entity/ObservationMultiple_entity/entityfields/observer_param/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..3bc7f5cd1797ce903128a6d074df6ee4cc34dd18 --- /dev/null +++ b/entity/ObservationMultiple_entity/entityfields/observer_param/valueProcess.js @@ -0,0 +1,5 @@ +import("Employee_lib"); +import("system.result"); + + +result.string( EmployeeUtils.getCurrentUserId()); \ No newline at end of file diff --git a/entity/ObservationMultiple_entity/entityfields/priokeywords/children/containername_param/valueProcess.js b/entity/ObservationMultiple_entity/entityfields/priokeywords/children/containername_param/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..2a473f8de51c830b161872dd3f102670e683296b --- /dev/null +++ b/entity/ObservationMultiple_entity/entityfields/priokeywords/children/containername_param/valueProcess.js @@ -0,0 +1,3 @@ +import("system.result"); + +result.string("NotificationPriority"); \ No newline at end of file diff --git a/entity/ObservationMultiple_entity/entityfields/triggereventdelete/valueProcess.js b/entity/ObservationMultiple_entity/entityfields/triggereventdelete/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..35371aba2179658a5d577832af3e554dd072c340 --- /dev/null +++ b/entity/ObservationMultiple_entity/entityfields/triggereventdelete/valueProcess.js @@ -0,0 +1,8 @@ +import("system.vars"); +import("system.result"); + +if (vars.get("$this.value") == null) +{ + result.string("1"); +} + \ No newline at end of file diff --git a/entity/ObservationMultiple_entity/entityfields/triggereventinsert/valueProcess.js b/entity/ObservationMultiple_entity/entityfields/triggereventinsert/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..63fa115623e45cb8e72ca6ba77f201a233027f36 --- /dev/null +++ b/entity/ObservationMultiple_entity/entityfields/triggereventinsert/valueProcess.js @@ -0,0 +1,8 @@ +import("system.vars"); +import("system.result"); + +if (vars.get("$this.value") == null) +{ + result.string("1"); +} + \ No newline at end of file diff --git a/entity/ObservationMultiple_entity/entityfields/triggereventupdate/valueProcess.js b/entity/ObservationMultiple_entity/entityfields/triggereventupdate/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..35371aba2179658a5d577832af3e554dd072c340 --- /dev/null +++ b/entity/ObservationMultiple_entity/entityfields/triggereventupdate/valueProcess.js @@ -0,0 +1,8 @@ +import("system.vars"); +import("system.result"); + +if (vars.get("$this.value") == null) +{ + result.string("1"); +} + \ No newline at end of file diff --git a/entity/Observation_entity/Observation_entity.aod b/entity/Observation_entity/Observation_entity.aod index bccdb0c9b868f6137c54681abf0cb4a05a4220d1..56b10c9389cc18e4ed0b4746638d4101a50874d1 100644 --- a/entity/Observation_entity/Observation_entity.aod +++ b/entity/Observation_entity/Observation_entity.aod @@ -43,7 +43,6 @@ <consumer>Users</consumer> <groupable v="true" /> <mandatory v="true" /> - <stateProcess>%aditoprj%/entity/Observation_entity/entityfields/observer/stateProcess.js</stateProcess> <valueProcess>%aditoprj%/entity/Observation_entity/entityfields/observer/valueProcess.js</valueProcess> <displayValueProcess>%aditoprj%/entity/Observation_entity/entityfields/observer/displayValueProcess.js</displayValueProcess> </entityField> @@ -58,6 +57,7 @@ <groupable v="false" /> <mandatory v="true" /> <stateProcess>%aditoprj%/entity/Observation_entity/entityfields/object_type/stateProcess.js</stateProcess> + <valueProcess>%aditoprj%/entity/Observation_entity/entityfields/object_type/valueProcess.js</valueProcess> <displayValueProcess>%aditoprj%/entity/Observation_entity/entityfields/object_type/displayValueProcess.js</displayValueProcess> <onValueChange>%aditoprj%/entity/Observation_entity/entityfields/object_type/onValueChange.js</onValueChange> </entityField> @@ -221,6 +221,25 @@ <valueProcess>%aditoprj%/entity/Observation_entity/entityfields/notification_prio/valueProcess.js</valueProcess> <displayValueProcess>%aditoprj%/entity/Observation_entity/entityfields/notification_prio/displayValueProcess.js</displayValueProcess> </entityField> + <entityField> + <name>includeDependencies</name> + <title>incl. Dependencies</title> + <contentType>BOOLEAN</contentType> + <stateProcess>%aditoprj%/entity/Observation_entity/entityfields/includedependencies/stateProcess.js</stateProcess> + <valueProcess>%aditoprj%/entity/Observation_entity/entityfields/includedependencies/valueProcess.js</valueProcess> + </entityField> + <entityParameter> + <name>ObjectType_param</name> + <expose v="true" /> + </entityParameter> + <entityParameter> + <name>ObjectId_param</name> + <expose v="true" /> + </entityParameter> + <entityParameter> + <name>ObjectFilter_param</name> + <expose v="true" /> + </entityParameter> </entityFields> <recordContainers> <dbRecordContainer> @@ -229,6 +248,7 @@ <hasDependentRecords v="true" /> <conditionProcess>%aditoprj%/entity/Observation_entity/recordcontainers/db/conditionProcess.js</conditionProcess> <orderClauseProcess>%aditoprj%/entity/Observation_entity/recordcontainers/db/orderClauseProcess.js</orderClauseProcess> + <onDBInsert>%aditoprj%/entity/Observation_entity/recordcontainers/db/onDBInsert.js</onDBInsert> <onDBDelete>%aditoprj%/entity/Observation_entity/recordcontainers/db/onDBDelete.js</onDBDelete> <alias>Data_alias</alias> <cacheType>GLOBAL</cacheType> diff --git a/entity/Observation_entity/entityfields/contexts/children/blacklist_param/valueProcess.js b/entity/Observation_entity/entityfields/contexts/children/blacklist_param/valueProcess.js index 8d6aa9e96bc961bf55a4e420addb8013057565af..ce4ed3a334253f41bc34a9e5751e2e316485f481 100644 --- a/entity/Observation_entity/entityfields/contexts/children/blacklist_param/valueProcess.js +++ b/entity/Observation_entity/entityfields/contexts/children/blacklist_param/valueProcess.js @@ -13,4 +13,4 @@ if (vars.get("$field.OBSERVATION_ID")) .cell(); } -result.object(Observation.getAllContextValue(type)); +result.object(Observation.getAllContextValue(type)); \ No newline at end of file diff --git a/entity/Observation_entity/entityfields/includedependencies/stateProcess.js b/entity/Observation_entity/entityfields/includedependencies/stateProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..2cc7df11aa6f726c65bcf5d39adc7690346b597f --- /dev/null +++ b/entity/Observation_entity/entityfields/includedependencies/stateProcess.js @@ -0,0 +1,8 @@ +import("system.neon"); +import("system.vars"); +import("system.result"); + +if (vars.get("$sys.recordstate") != neon.OPERATINGSTATE_NEW) +{ + result.string(neon.COMPONENTSTATE_INVISIBLE); +} diff --git a/entity/Observation_entity/entityfields/includedependencies/valueProcess.js b/entity/Observation_entity/entityfields/includedependencies/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..17d96815f787ef6b77dd7e341456d3c52a69f46a --- /dev/null +++ b/entity/Observation_entity/entityfields/includedependencies/valueProcess.js @@ -0,0 +1,23 @@ +import("system.neon"); +import("system.vars"); +import("system.result"); + +let isIncluded; + +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$this.value") == null) +{ + if (vars.get("$field.OBSERVATION_ID")) + { + isIncluded = "0"; + } + else + { + isIncluded = "1"; + } +} + +if (isIncluded) +{ + result.string(isIncluded); +} + diff --git a/entity/Observation_entity/entityfields/object_filter/valueProcess.js b/entity/Observation_entity/entityfields/object_filter/valueProcess.js index e1eab777e321453398af0f07b195fe48287fe6ff..4d4ffd9519726affce4f0ec8e8ffe1d9eb12576a 100644 --- a/entity/Observation_entity/entityfields/object_filter/valueProcess.js +++ b/entity/Observation_entity/entityfields/object_filter/valueProcess.js @@ -3,6 +3,19 @@ import("Context_lib"); import("system.vars"); import("system.result"); -if ((vars.get("$this.value") == null || vars.get("$this.value") == "") && vars.get("$field.OBJECT_TYPE") && !vars.get("$field.OBJECT_ID")) { - result.string(Observation.getContextFilter(vars.get("$field.OBJECT_TYPE"), null)); -} \ No newline at end of file +let isFilterParamExists = vars.exists("$param.ObjectFilter_param") && vars.get("$param.ObjectFilter_param"); +let resFilter; + +if ((vars.get("$this.value") == null || vars.get("$this.value") == "") && vars.get("$field.OBJECT_TYPE") && !vars.get("$field.OBJECT_ID") && !isFilterParamExists) +{ + resFilter = Observation.getContextFilter(vars.get("$field.OBJECT_TYPE"), null); +} +else if (!vars.get("$this.value") && isFilterParamExists) +{ + resFilter = vars.get("$param.ObjectFilter_param"); +} + +if (resFilter) +{ + result.string(resFilter); +} diff --git a/entity/Observation_entity/entityfields/object_id/valueProcess.js b/entity/Observation_entity/entityfields/object_id/valueProcess.js index 0d548d4da42d78867153de937258b1388ee775ec..3b52ba6e005efd0b253ccb4a2565b7167b8258f0 100644 --- a/entity/Observation_entity/entityfields/object_id/valueProcess.js +++ b/entity/Observation_entity/entityfields/object_id/valueProcess.js @@ -3,6 +3,19 @@ import("system.vars"); import("system.result"); let value = vars.get("$this.value"); +let resId; + +if (value) +{ + resId = vars.get("$field.OBJECT_TYPE") == "Employee" && value.length == 36 ? EmployeeUtils.prefixUserId(value) : value; +} +else if (!value && vars.exists("$param.ObjectId_param") && vars.get("$param.ObjectId_param")) +{ + resId = vars.get("$param.ObjectId_param"); +} + +if (resId) +{ + result.string(resId); +} -if (vars.get("$this.value")) - result.string(vars.get("$field.OBJECT_TYPE") == "Employee" && value.length == 36 ? EmployeeUtils.prefixUserId(value) : value); \ No newline at end of file diff --git a/entity/Observation_entity/entityfields/object_type/valueProcess.js b/entity/Observation_entity/entityfields/object_type/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..e153d160e1a743b72e278e9cb2b2283ea8d6d573 --- /dev/null +++ b/entity/Observation_entity/entityfields/object_type/valueProcess.js @@ -0,0 +1,7 @@ +import("system.result"); +import("system.vars"); + + if (!vars.get("$this.value") && vars.exists("$param.ObjectType_param") && vars.get("$param.ObjectType_param")) +{ + result.string(vars.get("$param.ObjectType_param")); +} diff --git a/entity/Observation_entity/entityfields/observer/stateProcess.js b/entity/Observation_entity/entityfields/observer/stateProcess.js deleted file mode 100644 index e930c613bf00b043822b8deda3fb50fffc555121..0000000000000000000000000000000000000000 --- a/entity/Observation_entity/entityfields/observer/stateProcess.js +++ /dev/null @@ -1,8 +0,0 @@ -import("system.neon"); -import("system.vars"); -import("system.result"); - -if (vars.get("$sys.recordstate") != neon.OPERATINGSTATE_EDIT && vars.get("$param.OnlyMyObservations_param") != "true") - result.string(neon.COMPONENTSTATE_EDITABLE); -else - result.string(neon.COMPONENTSTATE_READONLY); \ No newline at end of file diff --git a/entity/Observation_entity/recordcontainers/db/onDBInsert.js b/entity/Observation_entity/recordcontainers/db/onDBInsert.js new file mode 100644 index 0000000000000000000000000000000000000000..aa3b524a0b205afb4d6793903fc229447669fc89 --- /dev/null +++ b/entity/Observation_entity/recordcontainers/db/onDBInsert.js @@ -0,0 +1,24 @@ +import("system.vars"); +import("Observation_lib"); +import("system.entities"); + +if (vars.get("$field.includeDependencies") == "1") +{ + let observer = vars.get("$field.OBSERVER"); + let observation_id = vars.get("$field.OBSERVATIONID"); + + Observation.getAllContextValue(vars.get("$field.OBJECT_TYPE")).forEach(function (contextID) { + var fields = { + "OBJECT_TYPE" : contextID, + "OBSERVER" : observer, + "OBJECT_FIELD" : Observation.getAllFieldValue(contextID).toString(), + "includeDependencies" : false, + "OBSERVATION_ID" : observation_id, + "OBJECT_FILTER" : Observation.getContextFilter(contextID, null) + } + + let createRowConfig = entities.createConfigForAddingRows() + .entity("Observation_entity"); + entities.createRow(createRowConfig.fieldValues(fields)); + }); +} \ No newline at end of file diff --git a/entity/Organisation_entity/Organisation_entity.aod b/entity/Organisation_entity/Organisation_entity.aod index 3a13ba89f60d6699ecc536ae743e06833d91c333..a48ba1eec23d65e66922c12f14aab572ef4db15e 100644 --- a/entity/Organisation_entity/Organisation_entity.aod +++ b/entity/Organisation_entity/Organisation_entity.aod @@ -14,7 +14,6 @@ <useFavorites v="true" /> <iconId>VAADIN:BUILDING</iconId> <imageProcess>%aditoprj%/entity/Organisation_entity/imageProcess.js</imageProcess> - <usePermissions v="false" /> <titlePlural>Companies</titlePlural> <recordContainer>db</recordContainer> <entityFields> diff --git a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod index 8c4aa272cf416ead6fc2dbe2e75bb838e98d65d1..4977ca99620fa54558dd514557ef430cdfefc357 100644 --- a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod +++ b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod @@ -8091,6 +8091,12 @@ <entry> <key>Participant is already participating</key> </entry> + <entry> + <key>incl. Dependencies</key> + </entry> + <entry> + <key>Add %0 Observations</key> + </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> <sqlModels> diff --git a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod index 92402864cf86208fb0cdd62e1a83dc21f2eb1200..eb940e2e187c6f2d9bd15be019453a648008d6a2 100644 --- a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod +++ b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod @@ -10680,6 +10680,14 @@ Bitte Datumseingabe prüfen</value> <key>Participant is already participating</key> <value>Teilnehmer nimmt bereits teil.</value> </entry> + <entry> + <key>incl. Dependencies</key> + <value>incl. Abhänigkeiten</value> + </entry> + <entry> + <key>Add %0 Observations</key> + <value>%0 Beobachtungen hinzufügen</value> + </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> </language> diff --git a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod index 1f52888b2bb78f99fbfb61e7bfbec898054ecf2d..0a5ecf54a311eb525f0e1b612939cb90a30cdeab 100644 --- a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod +++ b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod @@ -8193,6 +8193,12 @@ <entry> <key>Participant is already participating</key> </entry> + <entry> + <key>incl. Dependencies</key> + </entry> + <entry> + <key>Add %0 Observations</key> + </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> </language> diff --git a/neonContext/ObservationMultiple/ObservationMultiple.aod b/neonContext/ObservationMultiple/ObservationMultiple.aod new file mode 100644 index 0000000000000000000000000000000000000000..049e52936cc40e8a4c78f426bc4078247f29a679 --- /dev/null +++ b/neonContext/ObservationMultiple/ObservationMultiple.aod @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<neonContext xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonContext/1.1.1"> + <name>ObservationMultiple</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <editView>ObservationMultipleEdit_view</editView> + <entity>ObservationMultiple_entity</entity> + <references> + <neonViewReference> + <name>4601f612-0fce-4195-97dc-82e05c046484</name> + <view>ObservationMultipleEdit_view</view> + </neonViewReference> + </references> +</neonContext> diff --git a/neonView/ObservationEdit_view/ObservationEdit_view.aod b/neonView/ObservationEdit_view/ObservationEdit_view.aod index 6de89791e0f557e7b7c4c2a0e1448200c5618906..4540877e882f98774d37d42d786452ae592fe8d9 100644 --- a/neonView/ObservationEdit_view/ObservationEdit_view.aod +++ b/neonView/ObservationEdit_view/ObservationEdit_view.aod @@ -45,6 +45,10 @@ <name>c545362b-42d8-4cd5-83c8-9e4f2426c4ca</name> <entityField>TRIGGEREVENTDELETE</entityField> </entityFieldLink> + <entityFieldLink> + <name>aa93c341-578b-4da9-8ee8-2b3d9ea9e1ca</name> + <entityField>includeDependencies</entityField> + </entityFieldLink> <entityFieldLink> <name>c6fa82e2-5830-46c5-9127-e273ddf5a194</name> <entityField>NOTIFICATION_PRIO</entityField> diff --git a/neonView/ObservationMultipleEdit_view/ObservationMultipleEdit_view.aod b/neonView/ObservationMultipleEdit_view/ObservationMultipleEdit_view.aod new file mode 100644 index 0000000000000000000000000000000000000000..a44ccaaa0822d9c91ef6d7818c09929a7ba2d39f --- /dev/null +++ b/neonView/ObservationMultipleEdit_view/ObservationMultipleEdit_view.aod @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="UTF-8"?> +<neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.8" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.1.8"> + <name>ObservationMultipleEdit_view</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <size>SMALL</size> + <layout> + <boxLayout> + <name>layout</name> + </boxLayout> + </layout> + <children> + <genericViewTemplate> + <name>ObserverationEditMultibleGeneric</name> + <editMode v="true" /> + <fields> + <entityFieldLink> + <name>f519c0bd-8c1c-4a8e-aba2-9bd94d70ccb0</name> + <entityField>OBSERVER</entityField> + </entityFieldLink> + <entityFieldLink> + <name>ac1990a8-fe10-4feb-93b2-7def0792c00f</name> + <entityField>OBJECT_TYPE</entityField> + </entityFieldLink> + <entityFieldLink> + <name>86222081-5406-4a85-8c43-189166566ed1</name> + <entityField>OBJECT_FIELD</entityField> + </entityFieldLink> + <entityFieldLink> + <name>d5f4cb5d-c70d-46fd-ab78-bef71a205f37</name> + <entityField>TRIGGEREVENTINSERT</entityField> + </entityFieldLink> + <entityFieldLink> + <name>ba0cde17-7efb-481f-ae6c-6a75c2d41451</name> + <entityField>TRIGGEREVENTUPDATE</entityField> + </entityFieldLink> + <entityFieldLink> + <name>c545362b-42d8-4cd5-83c8-9e4f2426c4ca</name> + <entityField>TRIGGEREVENTDELETE</entityField> + </entityFieldLink> + <entityFieldLink> + <name>aa93c341-578b-4da9-8ee8-2b3d9ea9e1ca</name> + <entityField>includeDependencies</entityField> + </entityFieldLink> + <entityFieldLink> + <name>c6fa82e2-5830-46c5-9127-e273ddf5a194</name> + <entityField>NOTIFICATION_PRIO</entityField> + </entityFieldLink> + </fields> + </genericViewTemplate> + <actionsViewTemplate> + <name>ObservationEditMultibleActions</name> + <actions> + <element>addObservations</element> + </actions> + </actionsViewTemplate> + </children> +</neonView> diff --git a/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod b/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod index f48aa4fd1691d2091d0b8e3a25243074e083743e..ea1112320a62bb4d9bca624009ec4e671d5adfbd 100644 --- a/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod +++ b/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod @@ -164,6 +164,11 @@ <description>Whether the observations are enabled or not</description> <property v="false" /> </customBooleanProperty> + <customBooleanProperty> + <name>observation.isMultiselectionEnabled</name> + <description>Whether the multiselectionaction for observations are enabled or not.</description> + <property v="false" /> + </customBooleanProperty> <customStringProperty> <name>sales.vat</name> <description>Default VAT in percent</description> diff --git a/process/Dependency_lib/process.js b/process/Dependency_lib/process.js index 79bfcf0f79776ec91166c5a6d075e05695b23d53..76b94543fc436be99897773a884b33279c618644 100644 --- a/process/Dependency_lib/process.js +++ b/process/Dependency_lib/process.js @@ -75,9 +75,9 @@ Dependency.defaultFunctionForRelation = function (pRelationTable, pRelationField return newSelect(pRelationTable + "." + (pSourceField || "OBJECT_ROWID")) .from(pRelationTable) - .groupBy(pRelationTable + ".OBJECT_ROWID") + .groupBy(pRelationTable + "." + pSourceField || "OBJECT_ROWID") .whereIfSet(pRelationTable + "." + pRelationField, relationFieldValue) - .and(pRelationTable + ".OBJECT_TYPE", pContext) + .andIfSet(pRelationTable + ".OBJECT_TYPE", pContext) .arrayColumn(); } } diff --git a/process/Observation_lib/process.js b/process/Observation_lib/process.js index 33d05fbff61766bbc813d8b56f26e96b6652bd5d..b2e80061c7b805fc9bcbfa405a8790c1bc257f5a 100644 --- a/process/Observation_lib/process.js +++ b/process/Observation_lib/process.js @@ -18,6 +18,7 @@ import("system.tools"); import("system.datetime"); import("system.db"); import("system.favorite"); +import("system.neon"); function Observation(){} @@ -257,15 +258,14 @@ Observation._notifiyUsers = function (pVariables, pObservers) if (pObservers && observers.length != 0 && pVariables) { var user = tools.getUserByAttribute(tools.NAME, pVariables[WorkflowVariables.EVENT_USER()], tools.PROFILE_DEFAULT); - var notificationCaption; + var beginNotificationDescription = (user.params.firstname + " " + user.params.lastname).trim() + " " + translate.text("has") + " "; var filteredVariables = { - notificationCaption : translate.text(notificationCaption), notificationUser : JSON.stringify(observers), notificationType : "ObservationNotification" } observers.forEach(function (pObserver) { - filteredVariables.notificationDescription = (user.params.firstname + " " + user.params.lastname).trim() + " " + translate.text("has") + " "; + filteredVariables.notificationDescription = beginNotificationDescription; // If there is a OBJECT_TYPE, this is a dependency observation if (pObservers[pObserver][Observation.OBJECT_TYPE()]) { @@ -362,8 +362,10 @@ Observation._notification = function (pVariables, pFilteredVariables, pObservers if (pFilteredVariables.notificationDescription.length > 980) { - pFilteredVariables.notificationDescription.slice(0, 980) + pFilteredVariables.notificationDescription = pFilteredVariables.notificationDescription.slice(0, 980) pFilteredVariables.notificationDescription += "....there is more data available"; + isNewDescription = true; + isfirstField = false; return; } @@ -470,47 +472,32 @@ Observation.formatFieldValue = function (pRowData, pTypes, pField) */ Observation.insertAction = function () { - let contextID = ContextUtils.getCurrentContextId(); - let observer = EmployeeUtils.getCurrentUserId(); - let rowCount = newSelect("COUNT(*)") - .from("OBSERVATION") - .where("OBSERVATION.OBJECT_TYPE", contextID) - .and("OBSERVATION.OBSERVER", observer); + let contextId = ContextUtils.getCurrentContextId(); - var fields = { - "OBJECT_TYPE" : contextID, - "OBSERVER" : observer, - "OBJECT_FIELD" : Observation.getAllFieldValue(contextID).toString() + var params = { + "ObjectType_param" : contextId } - let createRowConfig = entities.createConfigForAddingRows() - .entity("Observation_entity"); - let selectedUIDs = vars.get("$sys.selection"); - if (selectedUIDs.length){ - selectedUIDs.forEach(function (uid) - { - let tempRowCount = rowCount.copy() - .and("OBSERVATION.OBJECT_ID", uid); - - if (tempRowCount.cell() == 0) - { - fields.OBJECT_ID = uid; - entities.createRow(createRowConfig.fieldValues(fields)); - } + if (selectedUIDs.length > 1) + { + params["ObjectIds_param"] = JSON.stringify(selectedUIDs); + neon.openContext("ObservationMultiple", "ObservationMultipleEdit_view", null, neon.OPERATINGSTATE_VIEW, params); + return; - }); - } else { - let filter = Observation.getContextFilter(contextID,vars.get("$sys.filter").filter); + } + else if (selectedUIDs.length) + { + params["ObjectId_param"] = selectedUIDs[0]; + } + else + { + let filter = Observation.getContextFilter(contextId,vars.get("$sys.filter").filter); - rowCount.and("OBSERVATION.OBJECT_FILTER", filter, SqlBuilder.LIKE()); - if (rowCount.cell() == 0) - { - fields.OBJECT_FILTER = filter; - entities.createRow(createRowConfig.fieldValues(fields)); - } + params["ObjectFilter_param"] = filter; } + neon.openContext("Observation", "ObservationEdit_view", null, neon.OPERATINGSTATE_NEW, params); } /** @@ -597,16 +584,15 @@ Observation.countObservations = function (pSelectedUIDs) { let contextID = ContextUtils.getCurrentContextId(); let observer = EmployeeUtils.getCurrentUserId(); - let selectedUIDs = pSelectedUIDs.filter(function (el) { - return el; - }); + let rowCount = newSelect("COUNT(*)") .from("OBSERVATION") .where("OBSERVATION.OBJECT_TYPE", contextID) - .and("OBSERVATION.OBSERVER", observer); + .and("OBSERVATION.OBSERVER", observer) + .and("OBSERVATION.OBSERVATION_ID is null"); - if (selectedUIDs && selectedUIDs.length){ - rowCount.and("OBSERVATION.OBJECT_ID", selectedUIDs, SqlBuilder.IN()); + if (pSelectedUIDs && pSelectedUIDs.length){ + rowCount.and("OBSERVATION.OBJECT_ID", pSelectedUIDs, SqlBuilder.IN()); } else { rowCount.and("OBSERVATION.OBJECT_FILTER", Observation.getContextFilter(contextID,vars.get("$sys.filter").filter), SqlBuilder.LIKE()); } @@ -622,13 +608,19 @@ Observation.countObservations = function (pSelectedUIDs) */ Observation.actionState = function (pSelectedUIDs, pIsCancelAction) { + + let selectedUIDs = pSelectedUIDs.filter(function (el) { + return el; + }); let isEnabled = project.getPreferenceValue("custom.observation.isEnabled", "false"); - if (isEnabled == "false") + let isMultiselectionAction = project.getPreferenceValue("custom.observation.isMultiselectionEnabled", "false"); + if (isEnabled == "false" || + (isMultiselectionAction == "false" && (pSelectedUIDs && pSelectedUIDs.length) && vars.get("$sys.presentationmode") == neon.CONTEXT_PRESENTATIONMODE_FILTER)) { return neon.COMPONENTSTATE_INVISIBLE; } - let cond = pIsCancelAction ? Observation.countObservations(pSelectedUIDs) : !Observation.countObservations(pSelectedUIDs); + let cond = pIsCancelAction ? Observation.countObservations(selectedUIDs) : !Observation.countObservations(selectedUIDs); if (cond) {