From c093ebf1c2f1e0b5515b75c510909cd1f4667e04 Mon Sep 17 00:00:00 2001 From: Johannes Hoermann <j.hoermann@adito.de> Date: Tue, 23 Apr 2019 13:34:20 +0200 Subject: [PATCH] addressValidation: preset with current value, use project preferences --- .../AddressValidation_entity.aod | 5 +++++ .../recordcontainers/jdito/contentProcess.js | 3 +++ entity/Address_entity/Address_entity.aod | 14 ++++++++++++++ .../children/country_param/valueProcess.js | 4 ++++ .../children/currentvalue_param/valueProcess.js | 4 ++++ .../children/currentvalue_param/valueProcess.js | 4 ++++ .../entityfields/addr/onValueChange.js | 2 ++ .../_____PREFERENCES_PROJECT.aod | 14 ++++++++++++++ process/AddressValidation_lib/process.js | 9 +++++---- 9 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 entity/Address_entity/entityfields/cityvalidation/children/country_param/valueProcess.js create mode 100644 entity/Address_entity/entityfields/cityvalidation/children/currentvalue_param/valueProcess.js create mode 100644 entity/Address_entity/entityfields/zipvalidation/children/currentvalue_param/valueProcess.js diff --git a/entity/AddressValidation_entity/AddressValidation_entity.aod b/entity/AddressValidation_entity/AddressValidation_entity.aod index 0f243581fef..824e75c1ded 100644 --- a/entity/AddressValidation_entity/AddressValidation_entity.aod +++ b/entity/AddressValidation_entity/AddressValidation_entity.aod @@ -96,6 +96,11 @@ </entityParameter> </children> </entityProvider> + <entityParameter> + <name>CurrentValue_param</name> + <expose v="true" /> + <description>PARAMETER</description> + </entityParameter> </entityFields> <recordContainers> <jDitoRecordContainer> diff --git a/entity/AddressValidation_entity/recordcontainers/jdito/contentProcess.js b/entity/AddressValidation_entity/recordcontainers/jdito/contentProcess.js index b816f84362c..513b5ed0150 100644 --- a/entity/AddressValidation_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/AddressValidation_entity/recordcontainers/jdito/contentProcess.js @@ -17,6 +17,9 @@ if(sysFilter.filter != null) { filter = JSON.parse(sysFilter.filter).childs[0].value; } +if (!filter && vars.exists("$param.CurrentValue_param") && vars.get("$param.CurrentValue_param")) + filter = vars.get("$param.CurrentValue_param"); + var foundAddresses = AddressValidationUtils.validate(filter, type, country); result.object(foundAddresses); \ No newline at end of file diff --git a/entity/Address_entity/Address_entity.aod b/entity/Address_entity/Address_entity.aod index cf8f5b77c53..8edd3abfe50 100644 --- a/entity/Address_entity/Address_entity.aod +++ b/entity/Address_entity/Address_entity.aod @@ -313,6 +313,10 @@ <name>Country_param</name> <valueProcess>%aditoprj%/entity/Address_entity/entityfields/zipvalidation/children/country_param/valueProcess.js</valueProcess> </entityParameter> + <entityParameter> + <name>CurrentValue_param</name> + <valueProcess>%aditoprj%/entity/Address_entity/entityfields/zipvalidation/children/currentvalue_param/valueProcess.js</valueProcess> + </entityParameter> </children> </entityConsumer> <entityConsumer> @@ -323,6 +327,16 @@ <entityName>AddressValidation_entity</entityName> <fieldName>CityValidation</fieldName> </dependency> + <children> + <entityParameter> + <name>CurrentValue_param</name> + <valueProcess>%aditoprj%/entity/Address_entity/entityfields/cityvalidation/children/currentvalue_param/valueProcess.js</valueProcess> + </entityParameter> + <entityParameter> + <name>Country_param</name> + <valueProcess>%aditoprj%/entity/Address_entity/entityfields/cityvalidation/children/country_param/valueProcess.js</valueProcess> + </entityParameter> + </children> </entityConsumer> </entityFields> <recordContainers> diff --git a/entity/Address_entity/entityfields/cityvalidation/children/country_param/valueProcess.js b/entity/Address_entity/entityfields/cityvalidation/children/country_param/valueProcess.js new file mode 100644 index 00000000000..bece889b8e3 --- /dev/null +++ b/entity/Address_entity/entityfields/cityvalidation/children/country_param/valueProcess.js @@ -0,0 +1,4 @@ +import("system.result"); +import("system.vars"); + +result.string(vars.get("$field.COUNTRY")) \ No newline at end of file diff --git a/entity/Address_entity/entityfields/cityvalidation/children/currentvalue_param/valueProcess.js b/entity/Address_entity/entityfields/cityvalidation/children/currentvalue_param/valueProcess.js new file mode 100644 index 00000000000..74c070329cd --- /dev/null +++ b/entity/Address_entity/entityfields/cityvalidation/children/currentvalue_param/valueProcess.js @@ -0,0 +1,4 @@ +import("system.vars"); +import("system.result"); + +result.string(vars.get("$field.CITY")) \ No newline at end of file diff --git a/entity/Address_entity/entityfields/zipvalidation/children/currentvalue_param/valueProcess.js b/entity/Address_entity/entityfields/zipvalidation/children/currentvalue_param/valueProcess.js new file mode 100644 index 00000000000..d9e7983e6f2 --- /dev/null +++ b/entity/Address_entity/entityfields/zipvalidation/children/currentvalue_param/valueProcess.js @@ -0,0 +1,4 @@ +import("system.vars"); +import("system.result"); + +result.string(vars.get("$field.ZIP")) \ No newline at end of file diff --git a/entity/Communication_entity/entityfields/addr/onValueChange.js b/entity/Communication_entity/entityfields/addr/onValueChange.js index c6bc6676a27..61a183ab8b7 100644 --- a/entity/Communication_entity/entityfields/addr/onValueChange.js +++ b/entity/Communication_entity/entityfields/addr/onValueChange.js @@ -6,6 +6,8 @@ import("KeywordRegistry_basic"); import("system.neon"); import("PostalAddress_lib"); +// TODO: put into AddressValidation_lib + var addr = vars.get("$this.value"); if (addr) diff --git a/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod b/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod index 2e627c2e517..50084ef3280 100644 --- a/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod +++ b/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod @@ -33,4 +33,18 @@ <indexsearchIncrementingIndexerInterval v="1000" /> <indexsearchIncrementingIndexerBunchSize v="250" /> <indexsearchMaximumHits v="50000" /> + <customProperties> + <customStringProperty> + <name>addressValidation.url</name> + <property>https://services.aditosoftware.local/services/rest/ws_checkAddress</property> + </customStringProperty> + <customStringProperty> + <name>addressValidation.user</name> + <property>Admin</property> + </customStringProperty> + <customStringProperty> + <name>addressValidation.pw</name> + <property>a</property> + </customStringProperty> + </customProperties> </preferences> diff --git a/process/AddressValidation_lib/process.js b/process/AddressValidation_lib/process.js index 38e23ed26f0..9f0ab520f0b 100644 --- a/process/AddressValidation_lib/process.js +++ b/process/AddressValidation_lib/process.js @@ -1,3 +1,5 @@ +import("system.logging"); +import("system.project"); import("system.vars"); import("system.neon"); import("system.net"); @@ -61,10 +63,9 @@ function AddressValidationUtils() {} */ AddressValidationUtils.validate = function(pValue, pType, pCountry) { - // TODO: Options for url, user, pw - var userName = "Admin"; - var pw = "a"; - var url = "https://services.aditosoftware.local/services/rest/ws_checkAddress"; + var userName = project.getPreferenceValue("custom.addressValidation.user"); + var pw = project.getPreferenceValue("custom.addressValidation.pw"); + var url = project.getPreferenceValue("custom.addressValidation.url"); var actionType = "GET"; // get AddressValidationType-Object if it is only the key -- GitLab