From 4be1c60de701085e9b3233faed12835dcc6f2b93 Mon Sep 17 00:00:00 2001 From: "S.Listl" <S.Listl@SLISTL.aditosoftware.local> Date: Tue, 9 Jun 2020 15:41:12 +0200 Subject: [PATCH] 1057635 Show Duplicates in OrganisationEdit_view --- .../Organisation_entity.aod | 2 +- .../onlyshowcontactids_param/valueProcess.js | 1 - .../onlyshowcontactids_param/valueProcess.js | 95 ++++++++----------- .../OrganisationEdit_view.aod | 5 + 4 files changed, 46 insertions(+), 57 deletions(-) diff --git a/entity/Organisation_entity/Organisation_entity.aod b/entity/Organisation_entity/Organisation_entity.aod index 96b76098fde..5d0a9854f2e 100644 --- a/entity/Organisation_entity/Organisation_entity.aod +++ b/entity/Organisation_entity/Organisation_entity.aod @@ -948,7 +948,6 @@ <entityProvider> <name>SelfDuplicatesProvider</name> <titlePlural>Duplicates</titlePlural> - <recordContainer>index</recordContainer> </entityProvider> <entityParameter> <name>OnlyShowContactIds_param</name> @@ -1022,6 +1021,7 @@ </entityParameter> <entityParameter> <name>DuplicateCurrentContactId_param</name> + <title></title> <valueProcess>%aditoprj%/entity/Organisation_entity/entityfields/selfduplicatesuncached/children/duplicatecurrentcontactid_param/valueProcess.js</valueProcess> </entityParameter> <entityParameter> diff --git a/entity/Organisation_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js b/entity/Organisation_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js index fdbb29bfe39..dc76aa3c55e 100644 --- a/entity/Organisation_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js +++ b/entity/Organisation_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js @@ -1,6 +1,5 @@ import("system.project"); import("system.indexsearch"); -import("system.logging"); import("system.vars"); import("DuplicateScanner_lib"); import("system.result"); diff --git a/entity/Person_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js b/entity/Person_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js index 495e2c4503d..298a3115245 100644 --- a/entity/Person_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js +++ b/entity/Person_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js @@ -5,65 +5,50 @@ import("system.vars"); import("DuplicateScanner_lib"); import("system.result"); -let scannerName = "PersonDuplicates"; -let targetEntity = "Person_entity"; -let valuesToCheck = {}; +var scannerName = "PersonDuplicates"; +var targetEntity = "Person_entity"; +var valuesToCheck = {}; var entityFieldsToLoad = DuplicateScannerUtils.GetEntityFieldsFromConfig(scannerName, targetEntity); -if(entityFieldsToLoad == null || entityFieldsToLoad.length == 0) - result.string(JSON.stringify(["nodata"])); +var idsForEmptyResult = JSON.stringify(["nodata"]); + +if (entityFieldsToLoad == null || entityFieldsToLoad.length == 0) + result.string(idsForEmptyResult); else { //Read the values of all available entity fields and write the fieldname7value combination //as key/value pairs into an object. This is used to trigger the scan for duplicates - vars.get("$field.STANDARD_CITY"); - vars.get("$field.STANDARD_ZIP"); - vars.get("$field.STANDARD_ADDRESS"); - vars.get("$field.FIRSTNAME"); - vars.get("$field.LASTNAME"); - vars.get("$field.PersAddresses.insertedRows") - vars.get("$field.PersAddresses.changedRows") - vars.get("$field.PersAddresses.deletedRows") - - - let field = ''; - let fieldValue = ''; - for (fieldname in entityFieldsToLoad) - { - field = entityFieldsToLoad[fieldname]; - fieldValue = vars.get("$field." + field); - - if(fieldValue != null && fieldValue != "") - { - valuesToCheck[field] = fieldValue; - } - } - - let scanResults = DuplicateScannerUtils.ScanForDuplicates(scannerName, targetEntity, - valuesToCheck, null); - - let duplicateIds = []; - - if(scanResults != undefined && scanResults != null) - { - //Run thru every duplicate result and read out the id. - //Do it now to have a simple array on all usages lateron. - for (let i = 0; i < scanResults.length; i++) - { - let duplicateContactId = scanResults[i][indexsearch.FIELD_ID]; - duplicateIds.push(duplicateContactId); - } - } - - /* - * To achieve that if there are no duplicates, no contacts should be shown and therefore returned by the - * recordcontainer, an invalid id gets returned. It then is used in the conditionProcess to load the duplicates. - * Because of its invalidity, no records are shown. - */ - if(duplicateIds.length == 0) - result.string(JSON.stringify(["nodata"])); - else - result.string(JSON.stringify(duplicateIds)); -} - + vars.get("$field.STANDARD_CITY"); + vars.get("$field.STANDARD_ZIP"); + vars.get("$field.STANDARD_ADDRESS"); + vars.get("$field.FIRSTNAME"); + vars.get("$field.LASTNAME"); + vars.get("$field.PersAddresses.insertedRows") + vars.get("$field.PersAddresses.changedRows") + vars.get("$field.PersAddresses.deletedRows") + + for (let fieldname in entityFieldsToLoad) + { + var field = entityFieldsToLoad[fieldname]; + var fieldValue = vars.get("$field." + field); + if (fieldValue) + valuesToCheck[field] = fieldValue; + } + + var scanResults = DuplicateScannerUtils.ScanForDuplicates(scannerName, targetEntity, valuesToCheck, null) || []; + var duplicateIds = scanResults.map(function (duplicate) + { + return duplicate[indexsearch.FIELD_ID]; + }); + + /* + * To achieve that if there are no duplicates, no contacts should be shown and therefore returned by the + * recordcontainer, an invalid id gets returned. It then is used in the conditionProcess to load the duplicates. + * Because of its invalidity, no records are shown. + */ + if (duplicateIds.length == 0) + result.string(idsForEmptyResult); + else + result.string(JSON.stringify(duplicateIds)); +} \ No newline at end of file diff --git a/neonView/OrganisationEdit_view/OrganisationEdit_view.aod b/neonView/OrganisationEdit_view/OrganisationEdit_view.aod index bf0627608ee..81ab6625297 100644 --- a/neonView/OrganisationEdit_view/OrganisationEdit_view.aod +++ b/neonView/OrganisationEdit_view/OrganisationEdit_view.aod @@ -11,6 +11,11 @@ </boxLayout> </layout> <children> + <neonViewReference> + <name>f2fa0351-15af-4d1c-b7dd-0e42d9c7889f</name> + <entityField>SelfDuplicatesUncached</entityField> + <view>OrganisationDuplicateEditview_view</view> + </neonViewReference> <genericViewTemplate> <name>Edit</name> <editMode v="true" /> -- GitLab