From b2a74d238c1123e1c22870a6d79d40a2fa0e8b4b Mon Sep 17 00:00:00 2001 From: "f.maier" <f.maier@adito.de> Date: Fri, 22 Oct 2021 10:35:08 +0200 Subject: [PATCH] =?UTF-8?q?[Projekt:=20xRM-ContactManagement][TicketNr.:?= =?UTF-8?q?=202001171][Serienaktion=20Eigenschaften=20setzen=20in=20Aktivi?= =?UTF-8?q?t=C3=A4t=20fehlerhaft]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- process/FilterViewAction_lib/process.js | 74 ++++++++++++++++--------- 1 file changed, 48 insertions(+), 26 deletions(-) diff --git a/process/FilterViewAction_lib/process.js b/process/FilterViewAction_lib/process.js index ede6618261..7bfa3759b7 100644 --- a/process/FilterViewAction_lib/process.js +++ b/process/FilterViewAction_lib/process.js @@ -1,3 +1,4 @@ +import("system.logging"); import("Util_lib"); import("system.neon"); import("Sql_lib"); @@ -23,15 +24,19 @@ function FilterViewActionUtils() {} FilterViewActionUtils.getUidsByEntityFilter = function (pContext, pFilter, pParameters) { if (Utils.isString(pFilter)) - pFilter = JSON.parse(pFilter); - - if (Utils.isString(pParameters)) - pParameters = JSON.parse(pParameters); - - //uids from Person and Organisation are loaded with simple sql queries because that's much faster than over the entity' - if (pContext == "Person" && "condition" in pFilter) - { - return new SqlBuilder() + { + pFilter = JSON.parse(pFilter); + } + if (Utils.isString(pParameters)) + { + pParameters = JSON.parse(pParameters); + } + + //uids from Person and Organisation are loaded with simple sql queries because that's much faster than over the entity' + //TODO: design modular + filter recipe + if (pContext == "Person" && "condition" in pFilter) + { + return new SqlBuilder() .selectDistinct("CONTACT.CONTACTID") .from("PERSON") .join("CONTACT", "CONTACT.PERSON_ID = PERSON.PERSONID") @@ -39,10 +44,10 @@ FilterViewActionUtils.getUidsByEntityFilter = function (pContext, pFilter, pPara .leftJoin("ADDRESS", "ADDRESS.ADDRESSID = CONTACT.ADDRESS_ID") .whereIfSet(pFilter.condition) .arrayColumn(); - } - if (pContext == "Organisation" && "condition" in pFilter) - { - return new SqlBuilder() + } + if (pContext == "Organisation" && "condition" in pFilter) + { + return new SqlBuilder() .selectDistinct("CONTACT.CONTACTID") .from("ORGANISATION") .join("CONTACT", newWhere("ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID").and("CONTACT.PERSON_ID is null")) @@ -50,22 +55,39 @@ FilterViewActionUtils.getUidsByEntityFilter = function (pContext, pFilter, pPara .leftJoin("CLASSIFICATIONSTORAGE", "CLASSIFICATIONSTORAGE.OBJECT_ROWID = CONTACT.CONTACTID") .whereIfSet(pFilter.condition) .arrayColumn(); - } + } + if(pContext == "Activity" && "condition" in pFilter) + { + return new SqlBuilder() + .selectDistinct("ACTIVITY.ACTIVITYID") + .from("ACTIVITY") + .leftJoin("CONTACT", "CONTACT.CONTACTID = ACTIVITY.RESPONSIBLE") + .leftJoin("PERSON", "PERSON.PERSONID = CONTACT.PERSON_ID") + .whereIfSet(pFilter.condition) + .arrayColumn(); + } - //General solution to get the uids using entities.getRows - var loadRowsConfig = entities.createConfigForLoadingRows() + //General solution to get the uids using entities.getRows + var loadRowsConfig = entities.createConfigForLoadingRows() .entity(ContextUtils.getEntity(pContext)) - .fields(["#UID"]) - if (pFilter.filter) - loadRowsConfig.filter(JSON.stringify(pFilter.filter)); - - if(pParameters) - Object.keys(pParameters).forEach(function(key){loadRowsConfig.addParameter(key, pParameters[key])}); + .fields(["#UID"]); + + if (pFilter.filter) + { + loadRowsConfig.filter(JSON.stringify(pFilter.filter)); + } - return entities.getRows(loadRowsConfig).map(function (row) - { - return row["#UID"]; - }); + if(pParameters) + { + Object.keys(pParameters).forEach(function(key){ + loadRowsConfig.addParameter(key, pParameters[key]) + }); + } + + return entities.getRows(loadRowsConfig).map(function (row) + { + return row["#UID"]; + }); } /** -- GitLab