diff --git a/entity/Address_entity/Address_entity.aod b/entity/Address_entity/Address_entity.aod index 871854a52648ee83a5ca7a559eea276cac27aa8b..8f105a34685c616bc771d3f5e4113e0971834b3a 100644 --- a/entity/Address_entity/Address_entity.aod +++ b/entity/Address_entity/Address_entity.aod @@ -60,6 +60,7 @@ <consumer>Countries</consumer> <mandatory v="true" /> <valueProcess>%aditoprj%/entity/Address_entity/entityfields/country/valueProcess.js</valueProcess> + <displayValueProcess>%aditoprj%/entity/Address_entity/entityfields/country/displayValueProcess.js</displayValueProcess> </entityField> <entityField> <name>DISTRICT</name> diff --git a/entity/Address_entity/entityfields/address/mandatoryProcess.js b/entity/Address_entity/entityfields/address/mandatoryProcess.js index c8c795a3080f3034b154cb73d55fb737a47dc7e1..c92fea5dd7288af13944c5a3486d3f25f3fb72fc 100644 --- a/entity/Address_entity/entityfields/address/mandatoryProcess.js +++ b/entity/Address_entity/entityfields/address/mandatoryProcess.js @@ -1,5 +1,6 @@ +import("system.vars"); import("AddressEntity_lib"); import("system.result"); import("WsValidation_lib"); -result.string(WsValidationFieldUtils.mainFieldMandatoryProcess(WsValidationType.get().TYPE_STREET_NOMINATIM, AddressEntityValidation.isMandatoryField())); \ No newline at end of file +result.string(WsValidationFieldUtils.mainFieldMandatoryProcess(WsValidationType.get().TYPE_STREET_NOMINATIM, AddressEntityValidation.isMandatoryField(vars.get("$field.COUNTRY")))); \ No newline at end of file diff --git a/entity/Address_entity/entityfields/address_ws/mandatoryProcess.js b/entity/Address_entity/entityfields/address_ws/mandatoryProcess.js index 3e9f416503faa722f6f1d37ca4cfdbada1f7f25c..305a67d36c0ece587ff4b7f57a46bd2f567d9621 100644 --- a/entity/Address_entity/entityfields/address_ws/mandatoryProcess.js +++ b/entity/Address_entity/entityfields/address_ws/mandatoryProcess.js @@ -1,5 +1,6 @@ +import("system.vars"); import("AddressEntity_lib"); import("WsValidation_lib"); import("system.result"); -result.object(WsValidationFieldUtils.wsFieldMandatoryProcess(WsValidationType.get().TYPE_STREET_NOMINATIM, AddressEntityValidation.isMandatoryField("ADDRESS"))); \ No newline at end of file +result.object(WsValidationFieldUtils.wsFieldMandatoryProcess(WsValidationType.get().TYPE_STREET_NOMINATIM, AddressEntityValidation.isMandatoryField(vars.get("$field.COUNTRY"), "ADDRESS"))); \ No newline at end of file diff --git a/entity/Address_entity/entityfields/city/mandatoryProcess.js b/entity/Address_entity/entityfields/city/mandatoryProcess.js index df67f6f85d7921e362daabb66453b4ecf258d262..255d63dfb4bded4c3ac581fb4d22902c6aa91172 100644 --- a/entity/Address_entity/entityfields/city/mandatoryProcess.js +++ b/entity/Address_entity/entityfields/city/mandatoryProcess.js @@ -1,5 +1,6 @@ +import("system.vars"); import("AddressEntity_lib"); import("system.result"); import("WsValidation_lib"); -result.string(WsValidationFieldUtils.mainFieldMandatoryProcess(WsValidationType.get().TYPE_CITY_NOMINATIM, AddressEntityValidation.isMandatoryField())); \ No newline at end of file +result.string(WsValidationFieldUtils.mainFieldMandatoryProcess(WsValidationType.get().TYPE_CITY_NOMINATIM, AddressEntityValidation.isMandatoryField(vars.get("$field.COUNTRY")))); \ No newline at end of file diff --git a/entity/Address_entity/entityfields/city_ws/mandatoryProcess.js b/entity/Address_entity/entityfields/city_ws/mandatoryProcess.js index 7dba637e9dc830390f59d8f7f66fe63c019c0e98..866716ba42f0ea5f093b6fa28e66fd244bf17fab 100644 --- a/entity/Address_entity/entityfields/city_ws/mandatoryProcess.js +++ b/entity/Address_entity/entityfields/city_ws/mandatoryProcess.js @@ -1,5 +1,6 @@ +import("system.vars"); import("AddressEntity_lib"); import("WsValidation_lib"); import("system.result"); -result.object(WsValidationFieldUtils.wsFieldMandatoryProcess(WsValidationType.get().TYPE_CITY_NOMINATIM, AddressEntityValidation.isMandatoryField("CITY"))); \ No newline at end of file +result.object(WsValidationFieldUtils.wsFieldMandatoryProcess(WsValidationType.get().TYPE_CITY_NOMINATIM, AddressEntityValidation.isMandatoryField(vars.get("$field.COUNTRY"), "CITY"))); \ No newline at end of file diff --git a/entity/Address_entity/entityfields/country/displayValueProcess.js b/entity/Address_entity/entityfields/country/displayValueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..60deeeeaba31308ee6e40c0b3f9fe16fb7c2df5a --- /dev/null +++ b/entity/Address_entity/entityfields/country/displayValueProcess.js @@ -0,0 +1,5 @@ +import("system.vars"); +import("system.result"); +import("Context_lib"); + +result.string(ContextUtils.loadContentTitle("Countries_Entity", vars.get("$field.COUNTRY"), "ISO2Name")); \ No newline at end of file diff --git a/entity/Address_entity/entityfields/state/mandatoryProcess.js b/entity/Address_entity/entityfields/state/mandatoryProcess.js index 7c898f01828b8da4b9712687a66dac8914b3b137..132a366dcb5b5d251185bd279041ab7766e1f9eb 100644 --- a/entity/Address_entity/entityfields/state/mandatoryProcess.js +++ b/entity/Address_entity/entityfields/state/mandatoryProcess.js @@ -1,5 +1,6 @@ +import("system.vars"); import("Entity_lib"); import("system.result"); import("AddressEntity_lib"); -result.object(AddressEntityValidation.isMandatoryField()); \ No newline at end of file +result.object(AddressEntityValidation.isMandatoryField(vars.get("$field.COUNTRY"))); \ No newline at end of file diff --git a/entity/Address_entity/entityfields/zip/mandatoryProcess.js b/entity/Address_entity/entityfields/zip/mandatoryProcess.js index 981aa78bf81d1892acc2f6e3874904c0e2598de4..453956bca6527ba6d35f257f0bc3a51d62dc20b2 100644 --- a/entity/Address_entity/entityfields/zip/mandatoryProcess.js +++ b/entity/Address_entity/entityfields/zip/mandatoryProcess.js @@ -1,5 +1,6 @@ +import("system.vars"); import("AddressEntity_lib"); import("WsValidation_lib"); import("system.result"); -result.object(WsValidationFieldUtils.mainFieldMandatoryProcess(WsValidationType.get().TYPE_ZIP_NOMINATIM, AddressEntityValidation.isMandatoryField())); \ No newline at end of file +result.object(WsValidationFieldUtils.mainFieldMandatoryProcess(WsValidationType.get().TYPE_ZIP_NOMINATIM, AddressEntityValidation.isMandatoryField(vars.get("$field.COUNTRY")))); \ No newline at end of file diff --git a/entity/Address_entity/entityfields/zip_ws/mandatoryProcess.js b/entity/Address_entity/entityfields/zip_ws/mandatoryProcess.js index a2dfbb85c858c9298c53c6e6ff4f7220ea09f86b..314617135812d94c11d08131a5f3b2252cfa1c70 100644 --- a/entity/Address_entity/entityfields/zip_ws/mandatoryProcess.js +++ b/entity/Address_entity/entityfields/zip_ws/mandatoryProcess.js @@ -1,5 +1,6 @@ +import("system.vars"); import("AddressEntity_lib"); import("WsValidation_lib"); import("system.result"); -result.object(WsValidationFieldUtils.wsFieldMandatoryProcess(WsValidationType.get().TYPE_ZIP_NOMINATIM, AddressEntityValidation.isMandatoryField("ZIP"))); \ No newline at end of file +result.object(WsValidationFieldUtils.wsFieldMandatoryProcess(WsValidationType.get().TYPE_ZIP_NOMINATIM, AddressEntityValidation.isMandatoryField(vars.get("$field.COUNTRY"), "ZIP"))); \ No newline at end of file diff --git a/process/AddressEntity_lib/process.js b/process/AddressEntity_lib/process.js index 61b8e5a06fc6b1042d4363d4c7a6e1aab424ff36..ffb472671a854f7a114a3a8480380bcbaa2c4aea 100644 --- a/process/AddressEntity_lib/process.js +++ b/process/AddressEntity_lib/process.js @@ -14,10 +14,12 @@ function AddressEntityValidation(){} /** * check if the field, this function is called in is a mandatory field of the country + * + * @param {String} pCountryCode iso code of the country of the field whoes standard values should be checked * @param {String} [pField=undefined] if provided use this field else use $this.name * @return {Boolean} */ -AddressEntityValidation.isMandatoryField = function(pField) +AddressEntityValidation.isMandatoryField = function(pCountryCode, pField) { var fieldName; @@ -25,7 +27,8 @@ AddressEntityValidation.isMandatoryField = function(pField) fieldName = pField; else fieldName = vars.get("$this.name").replace(/^\$?field\./, ""); - var countryCode = vars.get("$field.COUNTRY"); + //do not use vars.get of the country-field here since the process would no be triggered on a value change, instead pass it from the invoking code + var countryCode = pCountryCode; var fieldCode = this.mapFieldToShorthand(fieldName); if (fieldCode == null) return false; diff --git a/process/Context_lib/process.js b/process/Context_lib/process.js index c652ab9089316e1c714accd56f1cf5affdb74720..7b435b4aab5a6a8dd2904bbcc71cfee625cfd399 100644 --- a/process/Context_lib/process.js +++ b/process/Context_lib/process.js @@ -95,21 +95,25 @@ ContextUtils.getContextConsumer = function(pContextId) * loads the contenttitle by using entities.getRow * @param {String} pEntity The entity name you want to load the title for * @param {String} pUid the uid for which to load the title + * @param {String} [pProvider] providername when instead of the default provider another provider shall be used * * @return the #CONTENTTITLE or "" */ -ContextUtils.loadContentTitle = function(pEntity, pUid) +ContextUtils.loadContentTitle = function(pEntity, pUid, pProvider) { if (!pUid) { return ""; } - + var conf = entities.createConfigForLoadingRows() .entity(pEntity) .uid(pUid) .fields(["#CONTENTTITLE"]); + if (pProvider) + conf.provider(pProvider); + if (entities.getRowCount(conf) > 0) { return entities.getRow(conf)["#CONTENTTITLE"]; diff --git a/process/PostalAddress_lib/process.js b/process/PostalAddress_lib/process.js index 9e2a28bb1c1b7a77ce4767255bbe741efd8f84e6..83d7bfde4ca2bb5d4ff19335064841b4e1a567a2 100644 --- a/process/PostalAddress_lib/process.js +++ b/process/PostalAddress_lib/process.js @@ -222,15 +222,15 @@ AddressValidationUtils._getRequiredFields = function(countryCode) /** * check if the requested field is a mandatory field * - * @param {String} countryCode - * @param {String} fieldCode + * @param {String} countryCode iso code of the country + * @param {String} fieldCode shortform code of the field that shalle be checked; e.g. "S" for STATE * - * @return {Boolean} + * @return {Boolean} if the given field is a mandatory field for the specified country; if there is no definition the field is NOT mandatory */ AddressValidationUtils.isMandatoryField = function(countryCode, fieldCode) { var requiredFields = this._getRequiredFields(countryCode); - return requiredFields == "" || requiredFields.search(fieldCode) != -1; + return requiredFields != "" && requiredFields.search(fieldCode) != -1; }; /**