Merge lp:~openerp-dev/openerp-web/7.0-fix-xml-chm into lp:openerp-web/7.0

Proposed by Christophe Matthieu (OpenERP)
Status: Work in progress
Proposed branch: lp:~openerp-dev/openerp-web/7.0-fix-xml-chm
Merge into: lp:openerp-web/7.0
Diff against target: 80 lines (+14/-8)
2 files modified
addons/web/static/src/js/view_form.js (+10/-7)
addons/web/static/src/js/views.js (+4/-1)
To merge this branch: bzr merge lp:~openerp-dev/openerp-web/7.0-fix-xml-chm
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+141335@code.launchpad.net
To post a comment you must log in.
3666. By Christophe Matthieu (OpenERP)

[FIX] web form: get iterator with dom for load the good json attribute

Revision history for this message
Christophe Matthieu (OpenERP) (chm-openerp) wrote :

[FIX] web view & web form:
Fix the loader of xml attributes for IE (set json value before add to the dom)
Now all attributes are allowed (style, color...)

Unmerged revisions

3666. By Christophe Matthieu (OpenERP)

[FIX] web form: get iterator with dom for load the good json attribute

3665. By Christophe Matthieu (OpenERP)

[FIX] web view & web form: fix the load of the xml attributes for IE; now all attributes are allowed (like style, color...)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/web/static/src/js/view_form.js'
2--- addons/web/static/src/js/view_form.js 2012-12-26 16:13:07 +0000
3+++ addons/web/static/src/js/view_form.js 2012-12-27 13:44:23 +0000
4@@ -1191,19 +1191,19 @@
5 });
6 }
7 },
8- get_arch_fragment: function() {
9+ set_arch_fragment: function() {
10 var doc = $.parseXML(instance.web.json_node_to_xml(this.fvg.arch)).documentElement;
11+ this.json = instance.web.xml_to_json(doc);
12 // IE won't allow custom button@type and will revert it to spec default : 'submit'
13 $('button', doc).each(function() {
14 $(this).attr('data-button-type', $(this).attr('type')).attr('type', 'button');
15 });
16- return $('<div class="oe_form"/>').append(instance.web.xml_to_str(doc));
17+ this.$form = $('<div class="oe_form"/>').append(instance.web.xml_to_str(doc));
18 },
19 render_to: function($target) {
20 var self = this;
21 this.$target = $target;
22-
23- this.$form = this.get_arch_fragment();
24+ this.set_arch_fragment();
25
26 this.process_version();
27
28@@ -1218,6 +1218,7 @@
29 this.to_replace = [];
30
31 _.each(this.fields_to_init, function($elem) {
32+ var iterator =self.$form.find($elem).index();
33 var name = $elem.attr("name");
34 if (!self.fvg.fields[name]) {
35 throw new Error(_.str.sprintf(_t("Field '%s' specified in view could not be found."), name));
36@@ -1226,7 +1227,7 @@
37 if (!obj) {
38 throw new Error(_.str.sprintf(_t("Widget type '%s' is not implemented"), $elem.attr('widget')));
39 }
40- var w = new (obj)(self.view, instance.web.xml_to_json($elem[0]));
41+ var w = new (obj)(self.view, self.json.children[iterator]);
42 var $label = self.labels[$elem.attr("name")];
43 if ($label) {
44 w.set_input_id($label.attr("for"));
45@@ -1236,15 +1237,17 @@
46 self.to_replace.push([w, $elem]);
47 });
48 _.each(this.tags_to_init, function($elem) {
49+ var iterator =self.$form.find($elem).index();
50 var tag_name = $elem[0].tagName.toLowerCase();
51 var obj = self.tags_registry.get_object(tag_name);
52- var w = new (obj)(self.view, instance.web.xml_to_json($elem[0]));
53+ var w = new (obj)(self.view, self.json.children[iterator]);
54 self.to_replace.push([w, $elem]);
55 });
56 _.each(this.widgets_to_init, function($elem) {
57+ var iterator =self.$form.find($elem).index();
58 var widget_type = $elem.attr("type");
59 var obj = self.widgets_registry.get_object(widget_type);
60- var w = new (obj)(self.view, instance.web.xml_to_json($elem[0]));
61+ var w = new (obj)(self.view, self.json.children[iterator]);
62 self.to_replace.push([w, $elem]);
63 });
64 },
65
66=== modified file 'addons/web/static/src/js/views.js'
67--- addons/web/static/src/js/views.js 2012-12-21 11:36:57 +0000
68+++ addons/web/static/src/js/views.js 2012-12-27 13:44:23 +0000
69@@ -1435,7 +1435,10 @@
70 case 4:
71 return (strip_whitespace && node.data.trim() === '') ? undefined : node.data;
72 case 1:
73- var attrs = $(node).getAttributes();
74+ var attrs = {};
75+ _.each(node.attributes, function(attr) {
76+ attrs[attr.name] = attr.value;
77+ });
78 _.each(['domain', 'filter_domain', 'context', 'default_get'], function(key) {
79 if (attrs[key]) {
80 try {