From 49da361032152f0b3d98be81f31bb704abd18bb6 Mon Sep 17 00:00:00 2001 From: "S.Listl" <s.listl@adito.de> Date: Tue, 25 Aug 2020 10:56:21 +0200 Subject: [PATCH] Util_lib changes --- .../recordcontainers/db/conditionProcess.js | 3 ++- .../is_standard_icon/contentTypeProcess.js | 10 +++------- .../entityfields/is_standard_icon/valueProcess.js | 10 +++------- process/Util_lib/process.js | 7 ++++--- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/entity/Activity_entity/recordcontainers/db/conditionProcess.js b/entity/Activity_entity/recordcontainers/db/conditionProcess.js index e090677518..2abb513731 100644 --- a/entity/Activity_entity/recordcontainers/db/conditionProcess.js +++ b/entity/Activity_entity/recordcontainers/db/conditionProcess.js @@ -1,3 +1,4 @@ +import("Util_lib"); import("Employee_lib"); import("system.vars"); import("system.db"); @@ -46,7 +47,7 @@ if (vars.exists("$param.ActivityIDs_param") && vars.get("$param.ActivityIDs_para condition.and("ACTIVITY.ACTIVITYID", acticityIds, SqlBuilder.IN()); } -if (vars.getString("$param.OnlyInnate_param") == "true") +if (Utils.toBoolean(vars.get("$param.OnlyInnate_param"))) { var ownContactId = EmployeeUtils.getCurrentContactId(); if (ownContactId) diff --git a/entity/Address_entity/entityfields/is_standard_icon/contentTypeProcess.js b/entity/Address_entity/entityfields/is_standard_icon/contentTypeProcess.js index 2c348afa93..bd8a972530 100644 --- a/entity/Address_entity/entityfields/is_standard_icon/contentTypeProcess.js +++ b/entity/Address_entity/entityfields/is_standard_icon/contentTypeProcess.js @@ -1,10 +1,6 @@ import("system.vars"); import("system.result"); +import("Util_lib"); -var isStandard = vars.getString("$field.IS_STANDARD") == "true"; -var res; -if (isStandard) - res = "IMAGE"; -else - res = "TEXT"; -result.string(res); \ No newline at end of file +var isStandard = Utils.toBoolean(vars.get("$field.IS_STANDARD")); +result.string(isStandard ? "IMAGE" : "TEXT"); \ No newline at end of file diff --git a/entity/Address_entity/entityfields/is_standard_icon/valueProcess.js b/entity/Address_entity/entityfields/is_standard_icon/valueProcess.js index 7420487f08..e755ca5103 100644 --- a/entity/Address_entity/entityfields/is_standard_icon/valueProcess.js +++ b/entity/Address_entity/entityfields/is_standard_icon/valueProcess.js @@ -1,10 +1,6 @@ import("system.result"); import("system.vars"); +import("Util_lib"); -var isStandard = vars.getString("$field.IS_STANDARD") == "true"; -var res; -if (isStandard) - res = "VAADIN:MAP_MARKER"; -else - res = ""; -result.string(res); \ No newline at end of file +var isStandard = Utils.toBoolean(vars.getString("$field.IS_STANDARD")); +result.string(isStandard ? "VAADIN:MAP_MARKER" : ""); \ No newline at end of file diff --git a/process/Util_lib/process.js b/process/Util_lib/process.js index f7f70a01f2..d5ea4793bd 100644 --- a/process/Util_lib/process.js +++ b/process/Util_lib/process.js @@ -189,7 +189,8 @@ Utils.isBoolean = function (pValue) /** * Parses the given value to Boolean, this can be used to check for stringified Booleans. These rules apply: * <ul> - * <li>If the value is either falsy, the string "false" or the string "0", false is returned</li> + * <li>If the value is falsy, false is returned</li> + * <li>The strings "0", "false", "null" and "undefined" will result in false</li> * <li>If the valueOf method of the value returns a falsy value, false is returned * (this is to make sure the function returns false for weird stuff like 'new Boolean(false)')</li> * <li>Every other value results in true</li> @@ -197,9 +198,9 @@ Utils.isBoolean = function (pValue) * @param {String|Object} pValue the value to parse * @return {Boolean} a real boolean */ -Utils.parseBoolean = function (pValue) +Utils.toBoolean = function (pValue) { - return !(!pValue || pValue === "0" || pValue === "false" || !(pValue.valueOf())); + return !(!pValue || pValue === "0" || pValue === "false" || pValue === "null" || pValue === "undefined" || !(pValue.valueOf())); } /** -- GitLab