From a4c2e1cd1b302ba5f4dc4f0c2d12157e62ea733c Mon Sep 17 00:00:00 2001 From: Johannes Hoermann <j.hoermann@adito.de> Date: Tue, 17 Sep 2019 13:18:59 +0200 Subject: [PATCH] loadRow for display value for Language in person / organisation --- .../recordcontainers/jdito/contentProcess.js | 2 -- .../Organisation_entity.aod | 1 + .../language/displayValueProcess.js | 18 ++---------- .../entityfields/language/valueProcess.js | 6 ++++ .../language/displayValueProcess.js | 11 ++----- .../entityfields/language/valueProcess.js | 3 +- process/Context_lib/process.js | 29 +++++++++++++++++++ 7 files changed, 43 insertions(+), 27 deletions(-) create mode 100644 entity/Organisation_entity/entityfields/language/valueProcess.js diff --git a/entity/Appointment_entity/recordcontainers/jdito/contentProcess.js b/entity/Appointment_entity/recordcontainers/jdito/contentProcess.js index 8f77a056440..ad79e4da1a4 100644 --- a/entity/Appointment_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/Appointment_entity/recordcontainers/jdito/contentProcess.js @@ -9,8 +9,6 @@ import("system.datetime"); import("system.eMath"); import("system.util"); import("system.neon"); -import("system.entities") - var cond = SqlCondition.begin(); var appointmentUids; diff --git a/entity/Organisation_entity/Organisation_entity.aod b/entity/Organisation_entity/Organisation_entity.aod index bc2cdf9d11c..8a2491b00cc 100644 --- a/entity/Organisation_entity/Organisation_entity.aod +++ b/entity/Organisation_entity/Organisation_entity.aod @@ -39,6 +39,7 @@ <title>Language</title> <consumer>Languages</consumer> <selectionMode>SINGLE</selectionMode> + <valueProcess>%aditoprj%/entity/Organisation_entity/entityfields/language/valueProcess.js</valueProcess> <displayValueProcess>%aditoprj%/entity/Organisation_entity/entityfields/language/displayValueProcess.js</displayValueProcess> </entityField> <entityField> diff --git a/entity/Organisation_entity/entityfields/language/displayValueProcess.js b/entity/Organisation_entity/entityfields/language/displayValueProcess.js index c90f80c5a01..fbcdba886ae 100644 --- a/entity/Organisation_entity/entityfields/language/displayValueProcess.js +++ b/entity/Organisation_entity/entityfields/language/displayValueProcess.js @@ -1,17 +1,5 @@ -import("system.result"); import("system.vars"); -import("system.entities"); +import("system.result"); +import("Context_lib"); -if (vars.get("$field.LANGUAGE")) -{ - var conf = entities.createConfigForLoadingRows() - conf.entity("Language_entity") - .uid(vars.get("$field.LANGUAGE")) - .fields(["NAME_LATIN"]) - - result.string(entities.getRow(conf).NAME_LATIN) -} -else -{ - result.string("") -} \ No newline at end of file +result.string(ContextUtils.loadContentTitle("Language_entity", vars.get("$field.LANGUAGE"))); \ No newline at end of file diff --git a/entity/Organisation_entity/entityfields/language/valueProcess.js b/entity/Organisation_entity/entityfields/language/valueProcess.js new file mode 100644 index 00000000000..2bb039c219e --- /dev/null +++ b/entity/Organisation_entity/entityfields/language/valueProcess.js @@ -0,0 +1,6 @@ +import("system.result"); +import("system.neon"); +import("system.vars"); + +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.getString("$this.value") == null) + result.string("deu"); \ No newline at end of file diff --git a/entity/Person_entity/entityfields/language/displayValueProcess.js b/entity/Person_entity/entityfields/language/displayValueProcess.js index dae44e029af..fbcdba886ae 100644 --- a/entity/Person_entity/entityfields/language/displayValueProcess.js +++ b/entity/Person_entity/entityfields/language/displayValueProcess.js @@ -1,10 +1,5 @@ -import("system.result"); import("system.vars"); -import("Keyword_lib"); +import("system.result"); +import("Context_lib"); -var key = vars.get("$field.LANGUAGE"); -if (key) -{ - var res = LanguageKeywordUtils.getViewValue(key); - result.string(res); -} +result.string(ContextUtils.loadContentTitle("Language_entity", vars.get("$field.LANGUAGE"))); \ No newline at end of file diff --git a/entity/Person_entity/entityfields/language/valueProcess.js b/entity/Person_entity/entityfields/language/valueProcess.js index 8be4c28401d..2bb039c219e 100644 --- a/entity/Person_entity/entityfields/language/valueProcess.js +++ b/entity/Person_entity/entityfields/language/valueProcess.js @@ -1,7 +1,6 @@ +import("system.result"); import("system.neon"); import("system.vars"); -import("system.db"); -import("system.result"); if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.getString("$this.value") == null) result.string("deu"); \ No newline at end of file diff --git a/process/Context_lib/process.js b/process/Context_lib/process.js index aa417543da8..f2d989230a8 100644 --- a/process/Context_lib/process.js +++ b/process/Context_lib/process.js @@ -1,3 +1,5 @@ +import("system.logging"); +import("system.entities"); import("system.tools"); import("system.neon"); import("system.db"); @@ -85,6 +87,33 @@ 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 + * + * @return the #CONTENTTITLE or "" + */ +ContextUtils.loadContentTitle = function(pEntity, pUid) +{ + if (!pUid) + { + return ""; + } + + var conf = entities.createConfigForLoadingRows() + .entity(pEntity) + .uid(pUid) + .fields(["#CONTENTTITLE"]); + + if (entities.getRowCount(conf) > 0) + { + return entities.getRow(conf)["#CONTENTTITLE"]; + } + + return ""; +} + /** * * @param {Boolean} [pFilter=false] filter only for contexts which have a mapping in ContextUtils.getSelectMap -- GitLab