Skip to content
Snippets Groups Projects
Commit 49da3610 authored by Sebastian Listl's avatar Sebastian Listl :speech_balloon:
Browse files

Util_lib changes

parent c21887e5
No related branches found
No related tags found
No related merge requests found
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)
......
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
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
......@@ -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()));
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment