Commit 9f84a2e9 authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Xiaowu Zhang

[NOT FOR GENERIC]: erp5_web_renderjs_ui: Re-add functions to rjs_gadget_erp5_global.js

and load this gadget in the launcher

Since e1ab9098 of generic, some functions defined in rjs_gadget_erp5_global.js
were added to gadget_global.js in portal_skins.

However, this caused problem, since users might obtain cached version of file in portal_skins.
Even though we changed gadget_global.js to use must-revalidate HTTP cache,
users may still have old version and not request a new one.

So this commit:
- Re-adds functions to rjs_gadget_erp5_global.js
- Loads rjs_gadget_erp5_global.js at the site launcher, so functions are always there
even if not found in gadget_global.js version

Mark as [NOT FOR GENERIC] since it is a patch to ensure we do not upgrade issues.
I do not know though if this may impact other projects and what the solution would be
parent ddf22004
/*global window, RSVP, SimpleQuery, ComplexQuery, Query,
ensureArray */
Array, isNaN */
/*jslint indent: 2, maxerr: 3, nomen: true, unparam: true, continue: true */
(function (window, RSVP, SimpleQuery, ComplexQuery, Query,
ensureArray) {
Array, isNaN) {
"use strict";
///////////////////////////////
......@@ -151,6 +151,64 @@
};
/** Return true if the value truly represents an empty value.
Calling isEmpty(x) is more robust than expression !x.
*/
function isEmpty(value) {
return (value === undefined ||
value === null ||
value.length === 0 ||
(typeof value === "number" && isNaN(value)));
}
window.isEmpty = isEmpty;
/** Make sure that returned object is an Array instance.
*/
function ensureArray(obj) {
if (Array.isArray(obj)) {return obj; }
if (isEmpty(obj)) {return []; }
return [obj];
}
window.ensureArray = ensureArray;
/** Return first non-empty variable or the last one.
Calling getNonEmpy(a, b, "") is more robust way of writing a || b || "".
Variables coercing to false (e.g 0) do not get skipped anymore.
*/
function getFirstNonEmpty(first_argument) {
var i;
if (arguments.length === 0) {
return null;
}
for (i = 0; i < arguments.length; i += 1) {
if (!isEmpty(arguments[i])) {
return arguments[i];
}
}
if (arguments.length === 1) {
return first_argument;
}
return arguments[arguments.length - 1];
}
window.getFirstNonEmpty = getFirstNonEmpty;
/** Convert anything to boolean value correctly (even "false" will be false)*/
function asBoolean(obj) {
if (typeof obj === "boolean") {
return obj;
}
if (typeof obj === "string") {
return obj.toLowerCase() === "true" || obj === "1";
}
if (typeof obj === "number") {
return obj !== 0;
}
return Boolean(obj);
}
window.asBoolean = asBoolean;
///////////////////////////////
// Handle listbox action list
///////////////////////////////
......@@ -305,4 +363,4 @@
window.declareGadgetClassCanHandleListboxClipboardAction =
declareGadgetClassCanHandleListboxClipboardAction;
}(window, RSVP, SimpleQuery, ComplexQuery, Query, ensureArray));
\ No newline at end of file
}(window, RSVP, SimpleQuery, ComplexQuery, Query, Array, isNaN));
\ No newline at end of file
......@@ -29,6 +29,9 @@
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="erp5_launcher_nojqm.js"></script>
<script src="jiodev.js"></script>
<script src="gadget_global.js"></script>
<script src="gadget_erp5_global.js"></script>
</head>
......
......@@ -220,7 +220,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>georgios.dagkakis</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>975.34836.41174.41949</string> </value>
<value> <string>975.47541.55543.14148</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment