summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/view_form.js
diff options
context:
space:
mode:
authorFabien Meghazi <fme@openerp.com>2012-11-14 17:44:13 +0100
committerFabien Meghazi <fme@openerp.com>2012-11-14 17:44:13 +0100
commit4fb15efb59afe8ce98bb962b54163d3d7cb35a39 (patch)
tree08f5ed4274c49a76a1925431cc9552f868b4664d /addons/web/static/src/js/view_form.js
parent303b6108a46030f0d52f39e3b304429a8e26fb2c (diff)
[FIX] IE does not accept custom button@type attribute
Added one more step in views serialization historic hell bzr revid: fme@openerp.com-20121114164413-wrnxlbuh9zj924yk
Diffstat (limited to 'addons/web/static/src/js/view_form.js')
-rw-r--r--addons/web/static/src/js/view_form.js31
1 files changed, 27 insertions, 4 deletions
diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js
index 014a67157bb..8f5bb86e6b9 100644
--- a/addons/web/static/src/js/view_form.js
+++ b/addons/web/static/src/js/view_form.js
@@ -1191,14 +1191,36 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt
});
}
},
+ view_arch_to_dom_node: function(arch) {
+ // Historic mess for views arch
+ //
+ // server:
+ // -> got xml as string
+ // -> parse to xml and manipulate domains and contexts
+ // -> convert to json
+ // client:
+ // -> got view as json
+ // -> convert back to xml as string
+ // -> parse it as xml doc (manipulate button@type for IE)
+ // -> convert back to string
+ // -> parse it as dom element with jquery
+ // -> for each widget, convert node to json
+ //
+ // Wow !!!
+ var xml = instance.web.json_node_to_xml(arch);
+
+ var doc = $.parseXML('<div class="oe_form">' + xml + '</div>');
+ $('button', doc).each(function() {
+ $(this).attr('data-button-type', $(this).attr('type'));
+ });
+ xml = instance.web.xml_to_str(doc);
+ return $(xml);
+ },
render_to: function($target) {
var self = this;
this.$target = $target;
- // TODO: I know this will save the world and all the kitten for a moment,
- // but one day, we will have to get rid of xml2json
- var xml = instance.web.json_node_to_xml(this.fvg.arch);
- this.$form = $('<div class="oe_form">' + xml + '</div>');
+ this.$form = this.view_arch_to_dom_node(this.fvg.arch);
this.process_version();
@@ -1867,6 +1889,7 @@ instance.web.form.FormWidget = instance.web.Widget.extend(instance.web.form.Invi
instance.web.form.WidgetButton = instance.web.form.FormWidget.extend({
template: 'WidgetButton',
init: function(field_manager, node) {
+ node.attrs.type = node.attrs['data-button-type'];
this._super(field_manager, node);
this.force_disabled = false;
this.string = (this.node.attrs.string || '').replace(/_/g, '');