diff --git a/entity/DistrictChangeField_entity/DistrictChangeField_entity.aod b/entity/DistrictChangeField_entity/DistrictChangeField_entity.aod new file mode 100644 index 0000000000000000000000000000000000000000..1fec39e5d5d5bf3e2dd4729f47e4ed31d8071f6f --- /dev/null +++ b/entity/DistrictChangeField_entity/DistrictChangeField_entity.aod @@ -0,0 +1,72 @@ +<?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.22" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.3.22"> + <name>DistrictChangeField_entity</name> + <title>Serial action</title> + <majorModelMode>DISTRIBUTED</majorModelMode> + <documentation>%aditoprj%/entity/DistrictChangeField_entity/documentation.adoc</documentation> + <siblings> + <element>District_entity</element> + </siblings> + <recordContainer>jDito</recordContainer> + <entityFields> + <entityProvider> + <name>#PROVIDER</name> + </entityProvider> + <entityProvider> + <name>#PROVIDER_AGGREGATES</name> + <useAggregates v="true" /> + </entityProvider> + <entityField> + <name>PARENTDISTRICT_DISTRICTID</name> + <title>{$DISTRICT_PARENT_DISTRICT}</title> + <consumer>ParentDistricts</consumer> + <stateProcess>%aditoprj%/entity/DistrictChangeField_entity/entityfields/parentdistrict_districtid/stateProcess.js</stateProcess> + <displayValueProcess>%aditoprj%/entity/DistrictChangeField_entity/entityfields/parentdistrict_districtid/displayValueProcess.js</displayValueProcess> + </entityField> + <entityField> + <name>DISTRICT_AUTOADD</name> + <title>Auto assignment</title> + <contentType>BOOLEAN</contentType> + <stateProcess>%aditoprj%/entity/DistrictChangeField_entity/entityfields/district_autoadd/stateProcess.js</stateProcess> + </entityField> + <entityParameter> + <name>Field_param</name> + <expose v="true" /> + <mandatory v="true" /> + </entityParameter> + <entityField> + <name>UID</name> + </entityField> + <entityConsumer> + <name>ParentDistricts</name> + <dependency> + <name>dependency</name> + <entityName>District_entity</entityName> + <fieldName>ValidParentDistricts</fieldName> + </dependency> + <children> + <entityParameter> + <name>ExcludedDistrictIds_param</name> + <valueProcess>%aditoprj%/entity/DistrictChangeField_entity/entityfields/parentdistricts/children/excludeddistrictids_param/valueProcess.js</valueProcess> + </entityParameter> + </children> + </entityConsumer> + <entityParameter> + <name>Ids_param</name> + <expose v="true" /> + <mandatory v="true" /> + </entityParameter> + </entityFields> + <recordContainers> + <jDitoRecordContainer> + <name>jDito</name> + <jDitoRecordAlias>Data_alias</jDitoRecordAlias> + <onInsert>%aditoprj%/entity/DistrictChangeField_entity/recordcontainers/jdito/onInsert.js</onInsert> + <recordFieldMappings> + <jDitoRecordFieldMapping> + <name>UID.value</name> + </jDitoRecordFieldMapping> + </recordFieldMappings> + </jDitoRecordContainer> + </recordContainers> +</entity> diff --git a/entity/DistrictChangeField_entity/documentation.adoc b/entity/DistrictChangeField_entity/documentation.adoc new file mode 100644 index 0000000000000000000000000000000000000000..c63f3bc5babe1e043230837823e4fe0292d5bb6a --- /dev/null +++ b/entity/DistrictChangeField_entity/documentation.adoc @@ -0,0 +1,18 @@ += DistrictChangeField_entity + +== Overview + +Serial action entity to update specific fields of the District_entity at once. + +== Relation to other entities + +Used to update multiple rows of the District_entity at once. + +== Best Practice + +== FAQ + +How to update a new field: +- Add a constant in the District_lib. +- Add the field to this entity. +- Fill in the corresponding entityfield processes (stateProcess, mandatoryProcess, etc..). diff --git a/entity/DistrictChangeField_entity/entityfields/district_autoadd/stateProcess.js b/entity/DistrictChangeField_entity/entityfields/district_autoadd/stateProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..1c272032fd4cc55d433efe06375848393c7476f5 --- /dev/null +++ b/entity/DistrictChangeField_entity/entityfields/district_autoadd/stateProcess.js @@ -0,0 +1,11 @@ +import("system.result"); +import("system.neon"); +import("system.vars"); +import("District_lib"); + +var state = neon.COMPONENTSTATE_INVISIBLE; +if(vars.get("$param.Field_param") == DistrictChangeField.autoadd()) +{ + state = neon.COMPONENTSTATE_EDITABLE; +} +result.string(state); diff --git a/entity/DistrictChangeField_entity/entityfields/parentdistrict_districtid/displayValueProcess.js b/entity/DistrictChangeField_entity/entityfields/parentdistrict_districtid/displayValueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..af36b01bff21f1b99573a67d243558792c534607 --- /dev/null +++ b/entity/DistrictChangeField_entity/entityfields/parentdistrict_districtid/displayValueProcess.js @@ -0,0 +1,5 @@ +import("system.result"); +import("system.vars"); +import("Context_lib"); + +result.string(ContextUtils.loadContentTitle("District_entity", vars.get("$this.value"))); diff --git a/entity/DistrictChangeField_entity/entityfields/parentdistrict_districtid/stateProcess.js b/entity/DistrictChangeField_entity/entityfields/parentdistrict_districtid/stateProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..82b5b85f3b06b1bc3b4dd85c92ec267f5acf6a64 --- /dev/null +++ b/entity/DistrictChangeField_entity/entityfields/parentdistrict_districtid/stateProcess.js @@ -0,0 +1,11 @@ +import("system.result"); +import("system.neon"); +import("system.vars"); +import("District_lib"); + +var state = neon.COMPONENTSTATE_INVISIBLE; +if(vars.get("$param.Field_param") == DistrictChangeField.parent()) +{ + state = neon.COMPONENTSTATE_EDITABLE; +} +result.string(state); diff --git a/entity/DistrictChangeField_entity/entityfields/parentdistricts/children/excludeddistrictids_param/valueProcess.js b/entity/DistrictChangeField_entity/entityfields/parentdistricts/children/excludeddistrictids_param/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..1e51a2584f8f4106a4a2f7c60eaba629b7d11f03 --- /dev/null +++ b/entity/DistrictChangeField_entity/entityfields/parentdistricts/children/excludeddistrictids_param/valueProcess.js @@ -0,0 +1,4 @@ +import("system.result"); +import("system.vars"); + +result.string(vars.get("$param.Ids_param")); diff --git a/entity/DistrictChangeField_entity/recordcontainers/jdito/onInsert.js b/entity/DistrictChangeField_entity/recordcontainers/jdito/onInsert.js new file mode 100644 index 0000000000000000000000000000000000000000..0e1b31ed479dc53ea50ae73fee146728c8841220 --- /dev/null +++ b/entity/DistrictChangeField_entity/recordcontainers/jdito/onInsert.js @@ -0,0 +1,15 @@ +import("system.vars"); +import("system.entities"); +import("Sql_lib"); + +var ids = JSON.parse(vars.get("$param.Ids_param")); +var field = vars.get("$param.Field_param"); + +var data = {}; // TODO: use ES6 'ComputedPropertyName' +data[field] = vars.get("$field." + field); + +newWhere("DISTRICT.DISTRICTID", ids, SqlBuilder.IN()).updateFields(data); +// invalidate the District db recordContainer cache, +// needed since we dont use write entity +// and thus the cache doesnt get refreshed automatically +entities.invalidateCache("District_entity", "db"); diff --git a/entity/District_entity/District_entity.aod b/entity/District_entity/District_entity.aod index d55ee865239d02f2a41998c96309f43819488a7e..d91597148d82a93f21055fc4a22c09bcf0143aa1 100644 --- a/entity/District_entity/District_entity.aod +++ b/entity/District_entity/District_entity.aod @@ -5,6 +5,9 @@ <majorModelMode>DISTRIBUTED</majorModelMode> <documentation>%aditoprj%/entity/District_entity/documentation.adoc</documentation> <icon>VAADIN:GLOBE</icon> + <siblings> + <element>DistrictChangeField_entity</element> + </siblings> <grantDelete v="true" /> <grantDeleteProcess>%aditoprj%/entity/District_entity/grantDeleteProcess.js</grantDeleteProcess> <contentTitleProcess>%aditoprj%/entity/District_entity/contentTitleProcess.js</contentTitleProcess> @@ -265,6 +268,18 @@ <onActionProcess>%aditoprj%/entity/District_entity/entityfields/actiongroup/children/assignallactivedistricts/onActionProcess.js</onActionProcess> <isObjectAction v="false" /> </entityActionField> + <entityActionField> + <name>setAutoAssignment</name> + <title>Set auto assignment</title> + <onActionProcess>%aditoprj%/entity/District_entity/entityfields/actiongroup/children/setautoassignment/onActionProcess.js</onActionProcess> + <isObjectAction v="false" /> + </entityActionField> + <entityActionField> + <name>setParentDistrict</name> + <title>Set parent district</title> + <onActionProcess>%aditoprj%/entity/District_entity/entityfields/actiongroup/children/setparentdistrict/onActionProcess.js</onActionProcess> + <isObjectAction v="false" /> + </entityActionField> </children> </entityActionGroup> <entityProvider> diff --git a/entity/District_entity/entityfields/actiongroup/children/setautoassignment/onActionProcess.js b/entity/District_entity/entityfields/actiongroup/children/setautoassignment/onActionProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..ff2b90597992bd69703ab199ae40acd749146de0 --- /dev/null +++ b/entity/District_entity/entityfields/actiongroup/children/setautoassignment/onActionProcess.js @@ -0,0 +1,10 @@ +import("system.neon"); +import("system.neonFilter"); +import("system.vars"); +import("District_lib"); + +neon.openContextWithRecipe("DistrictChangeField", null, + neonFilter.createEntityRecordsRecipeBuilder().parameters({ + Ids_param: JSON.stringify(vars.get("$sys.selection")), + Field_param: DistrictChangeField.autoadd() + }), neon.OPERATINGSTATE_NEW); diff --git a/entity/District_entity/entityfields/actiongroup/children/setparentdistrict/onActionProcess.js b/entity/District_entity/entityfields/actiongroup/children/setparentdistrict/onActionProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..4d6e37260b01ae757d68dbfda06d68d400d9c995 --- /dev/null +++ b/entity/District_entity/entityfields/actiongroup/children/setparentdistrict/onActionProcess.js @@ -0,0 +1,10 @@ +import("system.neon"); +import("system.neonFilter"); +import("system.vars"); +import("District_lib"); + +neon.openContextWithRecipe("DistrictChangeField", null, + neonFilter.createEntityRecordsRecipeBuilder().parameters({ + Ids_param: JSON.stringify(vars.get("$sys.selection")), + Field_param: DistrictChangeField.parent() + }), neon.OPERATINGSTATE_NEW); diff --git a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod index 0b5de0b220f55959336f96a598c1cdf95c28c4c6..06691d8a2a95c3ea4b68decc3bce8e4db4801cd8 100644 --- a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod +++ b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod @@ -14655,6 +14655,18 @@ Bitte Datumseingabe prüfen</value> <key>Offers / Receipts</key> <value>Angebote / Belege</value> </entry> + <entry> + <key>Serial action</key> + <value>Serienaktion</value> + </entry> + <entry> + <key>Set parent district</key> + <value>Übergeordnetes Gebiet setzen</value> + </entry> + <entry> + <key>Set auto assignment</key> + <value>Auto-Zuordnung setzen</value> + </entry> <entry> <key>Calculate sum</key> <value>Summe berechnen</value> diff --git a/neonContext/DistrictChangeField/DistrictChangeField.aod b/neonContext/DistrictChangeField/DistrictChangeField.aod new file mode 100644 index 0000000000000000000000000000000000000000..f7ae8af03e21147691ba188d6d2ee81d66ffffac --- /dev/null +++ b/neonContext/DistrictChangeField/DistrictChangeField.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>DistrictChangeField</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <editView>DistrictChangeField_view</editView> + <entity>DistrictChangeField_entity</entity> + <references> + <neonViewReference> + <name>c9bd3a38-4c54-45bd-b24e-ba5b9c49ec58</name> + <view>DistrictChangeField_view</view> + </neonViewReference> + </references> +</neonContext> diff --git a/neonView/DistrictChangeField_view/DistrictChangeField_view.aod b/neonView/DistrictChangeField_view/DistrictChangeField_view.aod new file mode 100644 index 0000000000000000000000000000000000000000..624da2dce500683c11a938171b82bedf0e03b71e --- /dev/null +++ b/neonView/DistrictChangeField_view/DistrictChangeField_view.aod @@ -0,0 +1,27 @@ +<?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>DistrictChangeField_view</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <size>SMALL</size> + <layout> + <noneLayout> + <name>layout</name> + </noneLayout> + </layout> + <children> + <genericViewTemplate> + <name>generic</name> + <editMode v="true" /> + <fields> + <entityFieldLink> + <name>b3bcd65d-ff54-40b3-91d6-8a883f95b1d6</name> + <entityField>DISTRICT_AUTOADD</entityField> + </entityFieldLink> + <entityFieldLink> + <name>32d20d9d-56a7-4b8f-b107-b7ccffb22fee</name> + <entityField>PARENTDISTRICT_DISTRICTID</entityField> + </entityFieldLink> + </fields> + </genericViewTemplate> + </children> +</neonView> diff --git a/neonView/DistrictFilter_view/DistrictFilter_view.aod b/neonView/DistrictFilter_view/DistrictFilter_view.aod index e979e1c1a0e09097bdb0c908ccb859f1dbb7c7e2..c7f6fc496e1866a209ac87fea5ac0bb374f9270b 100644 --- a/neonView/DistrictFilter_view/DistrictFilter_view.aod +++ b/neonView/DistrictFilter_view/DistrictFilter_view.aod @@ -14,7 +14,6 @@ <parentField>PARENTDISTRICT_DISTRICTID</parentField> <hideContentSearch v="false" /> <showChildrenCount v="false" /> - <entityField>#ENTITY</entityField> <favoriteActionGroup1>ActionGroup</favoriteActionGroup1> <linkedColumns> <element>DISTRICT_NAME</element> diff --git a/process/District_lib/process.js b/process/District_lib/process.js index fb5c443eae8871cedb58ad6499df077a51b3f674..93d26cf8a3aac3bf8044450c7cf5b0b7741665e5 100644 --- a/process/District_lib/process.js +++ b/process/District_lib/process.js @@ -468,3 +468,11 @@ DistrictUtils.setDistrictContactStatus = function (pArrIds, pStatus) } db.updates(updateArray); } + +/* + * See DistrictChangeField_entity + */ +DistrictChangeField = function() {} + +DistrictChangeField.autoadd = function(){return "DISTRICT_AUTOADD";}; +DistrictChangeField.parent = function(){return "PARENTDISTRICT_DISTRICTID";};