diff --git a/.liquibase/Data_alias/changelog.xml b/.liquibase/Data_alias/changelog.xml index 7eea5966581a44cf29ffb6bdf99ab97e95eb3e10..c3a1d3c5759b118fd0d3d4e30e38f246a3f28166 100644 --- a/.liquibase/Data_alias/changelog.xml +++ b/.liquibase/Data_alias/changelog.xml @@ -19,4 +19,4 @@ <!--enable this only when you definetly want to overwrite the existing data with demo records:--> <!--<include relativeToChangelogFile="true" file="basic/_demoData/changelog.xml" context="example"/>--> -</databaseChangeLog> +</databaseChangeLog> \ No newline at end of file diff --git a/entity/DistrictContact_entity/DistrictContact_entity.aod b/entity/DistrictContact_entity/DistrictContact_entity.aod index 56cffc5739509bcd270b3ad7ca418f1a1a730827..12fe5d39edc04596007be9aa4cfb4c264276dd0d 100644 --- a/entity/DistrictContact_entity/DistrictContact_entity.aod +++ b/entity/DistrictContact_entity/DistrictContact_entity.aod @@ -21,7 +21,7 @@ <title>Company</title> <consumer>Organisations</consumer> <groupable v="true" /> - <linkedContext>Person</linkedContext> + <linkedContext>Organisation</linkedContext> <state>READONLY</state> <valueProcess>%aditoprj%/entity/DistrictContact_entity/entityfields/contact_id/valueProcess.js</valueProcess> <displayValueProcess>%aditoprj%/entity/DistrictContact_entity/entityfields/contact_id/displayValueProcess.js</displayValueProcess> @@ -191,11 +191,38 @@ <name>RowId_param</name> <expose v="true" /> </entityParameter> + <entityActionGroup> + <name>setStatus</name> + <children> + <entityActionField> + <name>setActive</name> + <title>Set active</title> + <onActionProcess>%aditoprj%/entity/DistrictContact_entity/entityfields/setstatus/children/setactive/onActionProcess.js</onActionProcess> + <isSelectionAction v="true" /> + <iconId>VAADIN:THUMBS_UP</iconId> + <tooltip>Set status to active</tooltip> + </entityActionField> + <entityActionField> + <name>setInactive</name> + <title>Set inactive</title> + <onActionProcess>%aditoprj%/entity/DistrictContact_entity/entityfields/setstatus/children/setinactive/onActionProcess.js</onActionProcess> + <isSelectionAction v="true" /> + <iconId>VAADIN:THUMBS_DOWN</iconId> + <tooltip>Set status to inactive</tooltip> + </entityActionField> + </children> + </entityActionGroup> + <entityParameter> + <name>isDashletView_param</name> + <expose v="true" /> + </entityParameter> </entityFields> <recordContainers> <dbRecordContainer> <name>db</name> <alias>Data_alias</alias> + <isRequireContainerFiltering v="false" /> + <hasDependentRecords v="true" /> <fromClauseProcess>%aditoprj%/entity/DistrictContact_entity/recordcontainers/db/fromClauseProcess.js</fromClauseProcess> <conditionProcess>%aditoprj%/entity/DistrictContact_entity/recordcontainers/db/conditionProcess.js</conditionProcess> <linkInformation> diff --git a/entity/DistrictContact_entity/entityfields/setstatus/children/setactive/onActionProcess.js b/entity/DistrictContact_entity/entityfields/setstatus/children/setactive/onActionProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..fe3a3b291449212b033f1e9676ad64f9977497e4 --- /dev/null +++ b/entity/DistrictContact_entity/entityfields/setstatus/children/setactive/onActionProcess.js @@ -0,0 +1,8 @@ +import("KeywordRegistry_basic"); +import("system.vars"); +import("system.neon"); +import("District_lib"); + +var arrIds = vars.get("$sys.selection"); +DistrictUtils.setDistrictContactStatus(arrIds, $KeywordRegistry.contactStatus$active()); +neon.openHome(); \ No newline at end of file diff --git a/entity/DistrictContact_entity/entityfields/setstatus/children/setinactive/onActionProcess.js b/entity/DistrictContact_entity/entityfields/setstatus/children/setinactive/onActionProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..6ea33256099f1ea89c827744bf95ad29ce5c650c --- /dev/null +++ b/entity/DistrictContact_entity/entityfields/setstatus/children/setinactive/onActionProcess.js @@ -0,0 +1,8 @@ +import("KeywordRegistry_basic"); +import("system.vars"); +import("system.neon"); +import("District_lib"); + +var arrIds = vars.get("$sys.selection"); +DistrictUtils.setDistrictContactStatus(arrIds, $KeywordRegistry.contactStatus$inactive()); +neon.openHome(); diff --git a/entity/DistrictContact_entity/recordcontainers/db/conditionProcess.js b/entity/DistrictContact_entity/recordcontainers/db/conditionProcess.js index 2847b1e2b17599d13ff5d26a5602608adfc20fbe..6cb4972435d40a84e4567d31f46c37748a7405e3 100644 --- a/entity/DistrictContact_entity/recordcontainers/db/conditionProcess.js +++ b/entity/DistrictContact_entity/recordcontainers/db/conditionProcess.js @@ -1,8 +1,11 @@ +import("KeywordRegistry_basic"); +import("Employee_lib"); import("system.entities"); import("system.result"); import("system.vars"); import("Sql_lib"); +var isDashletView = vars.get("$param.isDashletView_param"); var organisationID = vars.get("$param.currentOrganisationId_param"); var cond = newWhere(); @@ -18,4 +21,15 @@ if (organisationID) cond.and("DISTRICTCONTACT.CONTACT_ID", organisationID); } +if(isDashletView) +{ + var statusInReview = $KeywordRegistry.contactStatus$inReview(); + var districtOrigin = $KeywordRegistry.districtOrigin$auto(); + var currentContactId = EmployeeUtils.getCurrentContactId(); + + cond.and("DISTRICTCONTACT.STATUS", statusInReview); + cond.and("DISTRICTCONTACT.ORIGIN", districtOrigin); + cond.and("DISTRICTCONTACT.ADVISER_CONTACT_ID", currentContactId); +} + result.string(cond.toString()); \ No newline at end of file diff --git a/neonView/DistrictContactFilter_view/DistrictContactFilter_view.aod b/neonView/DistrictContactFilter_view/DistrictContactFilter_view.aod index fe94c7158652cc235602300a5f84385b0178dd09..49a72f748c22e43589957c054b6ad5681e9e233e 100644 --- a/neonView/DistrictContactFilter_view/DistrictContactFilter_view.aod +++ b/neonView/DistrictContactFilter_view/DistrictContactFilter_view.aod @@ -3,6 +3,27 @@ <name>DistrictContactFilter_view</name> <majorModelMode>DISTRIBUTED</majorModelMode> <filterable v="true" /> + <dashletConfigurations> + <neonDashletConfiguration> + <name>OwnDistrictContactsToCheck</name> + <title>My district assignments to check</title> + <description>Show my district assignments with status review</description> + <fragment>DistrictContact/filter</fragment> + <icon>VAADIN:GLOBE</icon> + <categories> + <neonDashletCategory> + <name>district</name> + <title>District</title> + </neonDashletCategory> + </categories> + <parameters> + <neonDashletParameter> + <name>isDashletView_param</name> + <value>true</value> + </neonDashletParameter> + </parameters> + </neonDashletConfiguration> + </dashletConfigurations> <layout> <boxLayout> <name>layout</name> @@ -11,6 +32,7 @@ <children> <tableViewTemplate> <name>districtContacts</name> + <favoriteActionGroup1>setStatus</favoriteActionGroup1> <entityField>#ENTITY</entityField> <linkedColumns /> <fixedFilterFields /> diff --git a/others/language_DE.txt b/others/language_DE.txt index e21ad1cb8b6eb4c6aae186be2a34d464ffb35148..e679f1ca46db60d8d533f25039a7f0bcc535de01 100644 --- a/others/language_DE.txt +++ b/others/language_DE.txt @@ -60,13 +60,33 @@ </entry> <entry> <key>Assign all selected districts</key> - <value>Zuordnung für alle selektierten Gebiete</value> + <value>Zuordnung für alle selektierten Gebiete</value> </entry> <entry> <key>Assignment for all selected districts will start now!</key> - <value>Zuordnung für alle selektierten Gebiete wird jetzt gestartet</value> + <value>Zuordnung für alle selektierten Gebiete wird jetzt gestartet</value> </entry> <entry> <key>Assignment of all selected districts is completed!</key> - <value>Zuordnung für alle selektierten Gebiete abgeschlossen</value> + <value>Zuordnung für alle selektierten Gebiete abgeschlossen</value> + </entry> + <entry> + <key>Set active</key> + <value>Aktiv setzen</value> + </entry> + <entry> + <key>Set inactive</key> + <value>Inaktiv setzen</value> + </entry> + <entry> + <key>Set status to active</key + <value>Status auf aktiv setzen</value> + </entry> + <entry> + <key>Set status to inactive</key> + <value>Status auf inaktiv setzen</value> + </entry> + <entry> + <key>My district assignments to check</key> + <value>Meine zu prüfenden Gebietszuweisungen</value> </entry> \ No newline at end of file diff --git a/others/language_EN.txt b/others/language_EN.txt index 64983f276c87d57079e98f1f2899620e996db567..ed4fb3d3337cb9dcb36550a281b8f11eaab86294 100644 --- a/others/language_EN.txt +++ b/others/language_EN.txt @@ -51,4 +51,19 @@ </entry> <entry> <key>Assignment of all selected districts is completed!</key> + </entry> + <entry> + <key>Set active</key> + </entry> + <entry> + <key>Set inactive</key> + </entry> + <entry> + <key>Set status to active</key> + </entry> + <entry> + <key>Set status to inactive</key> + </entry> + <entry> + <key>My district assignments to check</key> </entry> \ No newline at end of file diff --git a/process/District_lib/process.js b/process/District_lib/process.js index 10344edf69541f54ef5e642a1df9d3bb77165d51..47c2f38c68eeae7c8ec11f665f7ea31feebd219e 100644 --- a/process/District_lib/process.js +++ b/process/District_lib/process.js @@ -33,9 +33,9 @@ function DistrictUtils () {} DistrictUtils.getDistrictName = function (pDistrictId) { var districtName = newSelect("DISTRICT_NAME") - .from("DISTRICT") - .where("DISTRICT.DISTRICTID", pDistrictId) - .cell(true); + .from("DISTRICT") + .where("DISTRICT.DISTRICTID", pDistrictId) + .cell(true); return(districtName) } @@ -51,9 +51,9 @@ DistrictUtils.getDistrictName = function (pDistrictId) DistrictUtils.getDataFromDistrict = function (pDistrictId) { var districtData = newSelect("DISTRICT_FILTER, PARENTDISTRICT_DISTRICTID") - .from("DISTRICT") - .where("DISTRICT.DISTRICTID", pDistrictId) - .arrayRow(); + .from("DISTRICT") + .where("DISTRICT.DISTRICTID", pDistrictId) + .arrayRow(); return(districtData); } @@ -68,10 +68,10 @@ DistrictUtils.getDataFromDistrict = function (pDistrictId) */ DistrictUtils.getDataFromDistrictContact = function (pDistrictContactId) { - var arrData = newSelect("DISTRICT_ID, ADVISER_CONTACT_ID, CONTACT_ID") - .from("DISTRICTCONTACT") - .where("DISTRICTCONTACT.DISTRICTCONTACTID", pDistrictContactId) - .arrayRow(); + var arrData = newSelect("DISTRICT_ID, ADVISER_CONTACT_ID") + .from("DISTRICTCONTACT") + .where("DISTRICTCONTACT.DISTRICTCONTACTID", pDistrictContactId) + .arrayRow(); return(arrData); } @@ -93,12 +93,12 @@ DistrictUtils.assignDistrictOnServer = function (pArrDistrictIds, pUser) if (pUser === undefined) pUser = EmployeeUtils.getCurrentUserId(); var processConfig = process.createStartAsyncConfig() - .setName("assignDistrict_serverProcess") - .setLocalVariables({ - arrDistrictIds : pArrDistrictIds.join(";"), - user : pUser || "" - }) - .setUser(pUser) + .setName("assignDistrict_serverProcess") + .setLocalVariables({ + arrDistrictIds : pArrDistrictIds.join(";"), + user : pUser || "" + }) + .setUser(pUser) process.startAsync(processConfig); } @@ -131,21 +131,21 @@ DistrictUtils.assignDistrict = function (pDistrictId, pAppliedFilter, pContactId if (!pContactId) { arrExistingIds = new SqlBuilder() - .select("DISTRICTCONTACT.DISTRICTCONTACTID, DISTRICTCONTACT.CONTACT_ID, DISTRICTCONTACT.ADVISER_CONTACT_ID") - .from("DISTRICTCONTACT") - .where("DISTRICTCONTACT.DISTRICT_ID", pDistrictId) - .and ("DISTRICTCONTACT.ORIGIN", $KeywordRegistry.districtOrigin$auto()) - .and ("DISTRICTCONTACT.STATUS", $KeywordRegistry.contactStatus$inReview(), SqlBuilder.NOT_EQUAL()) - .table(); + .select("DISTRICTCONTACT.DISTRICTCONTACTID, DISTRICTCONTACT.CONTACT_ID, DISTRICTCONTACT.ADVISER_CONTACT_ID") + .from("DISTRICTCONTACT") + .where("DISTRICTCONTACT.DISTRICT_ID", pDistrictId) + .and ("DISTRICTCONTACT.ORIGIN", $KeywordRegistry.districtOrigin$auto()) + .and ("DISTRICTCONTACT.STATUS", $KeywordRegistry.contactStatus$inReview(), SqlBuilder.NOT_EQUAL()) + .table(); } //Einlesen aller Betreuer, die dem übergebenen Gebiet zugeordnet sind var arrResponsibleIds = new SqlBuilder() - .select("DISTRICTRESPONSIBLE.EMPLOYEE_CONTACT_ID, DISTRICTRESPONSIBLE.ADVISER_ROLE, " + - "DISTRICTRESPONSIBLE.ADVISER_STATUS, DISTRICTRESPONSIBLE.VALID_FROM, DISTRICTRESPONSIBLE.VALID_UNTIL") - .from("DISTRICTRESPONSIBLE") - .where("DISTRICTRESPONSIBLE.DISTRICT_ID", pDistrictId) - .table(); + .select("DISTRICTRESPONSIBLE.EMPLOYEE_CONTACT_ID, DISTRICTRESPONSIBLE.ADVISER_ROLE, " + + "DISTRICTRESPONSIBLE.ADVISER_STATUS, DISTRICTRESPONSIBLE.VALID_FROM, DISTRICTRESPONSIBLE.VALID_UNTIL") + .from("DISTRICTRESPONSIBLE") + .where("DISTRICTRESPONSIBLE.DISTRICT_ID", pDistrictId) + .table(); //Aufbereiten des im JSON-Format übergebenen Filters in eine SQL-Condition var appliedFilterCondition = JSON.parse(pAppliedFilter).filter; @@ -155,35 +155,35 @@ DistrictUtils.assignDistrict = function (pDistrictId, pAppliedFilter, pContactId logging.log("sqlCondition: " + sqlCondition) //Einlesen der Contact-IDs zu den Firmen, die gemäß Filter diesem Gebiet zugeordnet sind var arrOrgContactIds = new SqlBuilder() - .selectDistinct("CONTACT.CONTACTID") - .from("ORGANISATION") - .join("CONTACT", newWhere("ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID").and("CONTACT.PERSON_ID is null")) - .leftJoin("ADDRESS", "ADDRESS.ADDRESSID = CONTACT.ADDRESS_ID") - .leftJoin("CLASSIFICATIONSTORAGE", "CLASSIFICATIONSTORAGE.OBJECT_ROWID = CONTACT.CONTACTID") - .whereIfSet(sqlCondition) - .andIfSet("CONTACT.CONTACTID", pContactId) - .arrayColumn(); + .selectDistinct("CONTACT.CONTACTID") + .from("ORGANISATION") + .join("CONTACT", newWhere("ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID").and("CONTACT.PERSON_ID is null")) + .leftJoin("ADDRESS", "ADDRESS.ADDRESSID = CONTACT.ADDRESS_ID") + .leftJoin("CLASSIFICATIONSTORAGE", "CLASSIFICATIONSTORAGE.OBJECT_ROWID = CONTACT.CONTACTID") + .whereIfSet(sqlCondition) + .andIfSet("CONTACT.CONTACTID", pContactId) + .arrayColumn(); logging.log("arrOrgContactIds.length: " + arrOrgContactIds.length) var insertArray = []; var colsInsert = [ - "DISTRICTCONTACTID", - "CONTACT_ID", - "DISTRICT_ID", - "ADVISER_CONTACT_ID", - "ADVISER_ROLE", - "STATUS", - "VALID_FROM", - "VALID_UNTIL", - "ORIGIN", - "USER_NEW", - "DATE_NEW" - ]; + "DISTRICTCONTACTID", + "CONTACT_ID", + "DISTRICT_ID", + "ADVISER_CONTACT_ID", + "ADVISER_ROLE", + "STATUS", + "VALID_FROM", + "VALID_UNTIL", + "ORIGIN", + "USER_NEW", + "DATE_NEW" + ]; var updateArray = []; var colsUpdate = [ - "STATUS", - "USER_EDIT", - "DATE_EDIT" - ]; + "STATUS", + "USER_EDIT", + "DATE_EDIT" + ]; //Anlegen der Firmen-Betreuer-Datensätze in der Tabelle DISTRICTCONTACT for (var i=0; i<arrOrgContactIds.length; i++) @@ -212,17 +212,17 @@ DistrictUtils.assignDistrict = function (pDistrictId, pAppliedFilter, pContactId arrResponsibleIds[j][2] = $KeywordRegistry.contactStatus$active(); var valsInsert = [ - util.getNewUUID(), - arrOrgContactIds[i], - pDistrictId, - arrResponsibleIds[j][0], - arrResponsibleIds[j][1], - arrResponsibleIds[j][2], - arrResponsibleIds[j][3], - arrResponsibleIds[j][4], - $KeywordRegistry.districtOrigin$auto(), - vars.get("$sys.user"), - vars.get("$sys.date") + util.getNewUUID(), + arrOrgContactIds[i], + pDistrictId, + arrResponsibleIds[j][0], + arrResponsibleIds[j][1], + arrResponsibleIds[j][2], + arrResponsibleIds[j][3], + arrResponsibleIds[j][4], + $KeywordRegistry.districtOrigin$auto(), + vars.get("$sys.user"), + vars.get("$sys.date") ]; insertArray.push(["DISTRICTCONTACT", colsInsert, null, valsInsert]); } @@ -235,20 +235,12 @@ DistrictUtils.assignDistrict = function (pDistrictId, pAppliedFilter, pContactId if (arrExistingIds.length > 0) { invalid = arrExistingIds.length; - for (var l=0; l<arrExistingIds.length; l++) - { - var valsUpdate = [ - $KeywordRegistry.contactStatus$inReview(), - vars.get("$sys.user"), - vars.get("$sys.date") - ]; - var condition = newWhere("DISTRICTCONTACT.DISTRICTCONTACTID", arrExistingIds[l][0]); - updateArray.push(["DISTRICTCONTACT", colsUpdate, null, valsUpdate, condition.build()]); - } - db.updates(updateArray) + + //die erste Spalte enthält die Ids der zu aktualisierenden Datensätze + var arrIds = arrExistingIds.map(function(value) { return value[0]; }); + DistrictUtils.setDistrictContactStatus (arrIds, $KeywordRegistry.contactStatus$inReview()); } - - + return { newAssigned : newAssigned, invalid : invalid, @@ -349,9 +341,9 @@ DistrictUtils._getParentFilter = function (pParentDistrict_DistrictId, pPrevious { var parentDistrictFilter, grandParentDistrict; [parentDistrictFilter, grandParentDistrict] = newSelect(["DISTRICT.DISTRICT_FILTER", "DISTRICT.PARENTDISTRICT_DISTRICTID"]) - .from("DISTRICT") - .where("DISTRICT.DISTRICTID", pParentDistrict_DistrictId) - .arrayRow(); + .from("DISTRICT") + .where("DISTRICT.DISTRICTID", pParentDistrict_DistrictId) + .arrayRow(); parentDistrictFilter = JSON.parse(parentDistrictFilter); @@ -370,6 +362,37 @@ DistrictUtils._getParentFilter = function (pParentDistrict_DistrictId, pPrevious } +/** + * This function will set the status of districtcontact datasets + * @param {Array} pArrIds <p> + * IDs of districtcontact<br> + * @param {String} pStatus <p> + * Status, for example $KeywordRegistry.contactStatus$active<br> + * @return {none} <p> + */ +DistrictUtils.setDistrictContactStatus = function (pArrIds, pStatus) +{ + var updateArray = []; + var colsUpdate = [ + "STATUS", + "USER_EDIT", + "DATE_EDIT" + ]; + var valsUpdate = [ + pStatus, + vars.get("$sys.user"), + vars.get("$sys.date") + ]; + + for (var i=0; i<pArrIds.length; i++) + { + var condition = newWhere("DISTRICTCONTACT.DISTRICTCONTACTID", pArrIds[i]); + updateArray.push(["DISTRICTCONTACT", colsUpdate, null, valsUpdate, condition.build()]); + } + db.updates(updateArray); +} + + /** * This function will assign a new organisation to all districts, which * - have the property "auto assignment" @@ -387,9 +410,9 @@ DistrictUtils.assignOrganisationToDistrict = function (pOrganisationId, pUserLog //alle Filter ermitteln, die auf auto-assignment gleich true gesetzt sind var allAutoDistricts = newSelect("DISTRICTID") - .from("DISTRICT") - .where("DISTRICT.DISTRICT_AUTOADD", 1) - .arrayColumn(); + .from("DISTRICT") + .where("DISTRICT.DISTRICT_AUTOADD", 1) + .arrayColumn(); //TODO: pUserLogin noch bis zum Schreiben von date_new durchschleusen logging.log("pUerLogin: " + pUserLogin)