summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabien Meghazi <fme@openerp.com>2011-10-25 18:35:31 +0200
committerFabien Meghazi <fme@openerp.com>2011-10-25 18:35:31 +0200
commit20e5cb63a43dcd135f3b3ecedb2e7d444c3dc53b (patch)
tree0ef319f4ab4bcf7e51375b32967c6f1889e3df74
parentdd514b567dbdf30e9367c827965c7c936d51453a (diff)
[FIX] json_node_to_xml: whitespaces wrongly inserted around text nodes causing bugs in kanban views.
bzr revid: fme@openerp.com-20111025163531-nxr8gb4j2f7wne2a
-rw-r--r--addons/web/static/src/js/views.js24
1 files changed, 12 insertions, 12 deletions
diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js
index 78abe6a8fdb..41be7a18286 100644
--- a/addons/web/static/src/js/views.js
+++ b/addons/web/static/src/js/views.js
@@ -953,19 +953,19 @@ session.web.View = session.web.Widget.extend(/** @lends session.web.View# */{
}
});
-session.web.json_node_to_xml = function(node, single_quote, indent) {
+session.web.json_node_to_xml = function(node, human_readable, indent) {
// For debugging purpose, this function will convert a json node back to xml
// Maybe usefull for xml view editor
+ indent = indent || 0;
+ var sindent = (human_readable ? (new Array(indent + 1).join('\t')) : ''),
+ r = sindent + '<' + node.tag,
+ cr = human_readable ? '\n' : '';
if (typeof(node) === 'string') {
- return node;
- }
- else if (typeof(node.tag) !== 'string' || !node.children instanceof Array || !node.attrs instanceof Object) {
+ return sindent + node;
+ } else if (typeof(node.tag) !== 'string' || !node.children instanceof Array || !node.attrs instanceof Object) {
throw("Node a json node");
}
- indent = indent || 0;
- var sindent = new Array(indent + 1).join('\t'),
- r = sindent + '<' + node.tag;
for (var attr in node.attrs) {
var vattr = node.attrs[attr];
if (typeof(vattr) !== 'string') {
@@ -973,19 +973,19 @@ session.web.json_node_to_xml = function(node, single_quote, indent) {
vattr = JSON.stringify(vattr);
}
vattr = vattr.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
- if (single_quote) {
+ if (human_readable) {
vattr = vattr.replace(/&quot;/g, "'");
}
r += ' ' + attr + '="' + vattr + '"';
}
if (node.children && node.children.length) {
- r += '>\n';
+ r += '>' + cr;
var childs = [];
for (var i = 0, ii = node.children.length; i < ii; i++) {
- childs.push(session.web.json_node_to_xml(node.children[i], single_quote, indent + 1));
+ childs.push(session.web.json_node_to_xml(node.children[i], human_readable, indent + 1));
}
- r += childs.join('\n');
- r += '\n' + sindent + '</' + node.tag + '>';
+ r += childs.join(cr);
+ r += cr + sindent + '</' + node.tag + '>';
return r;
} else {
return r + '/>';