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
=== modified file 'addons/web/static/src/js/view_form.js'
--- addons/web/static/src/js/view_form.js 2012-12-26 16:13:07 +0000
+++ addons/web/static/src/js/view_form.js 2012-12-27 13:44:23 +0000
@@ -1191,19 +1191,19 @@
1191 });1191 });
1192 }1192 }
1193 },1193 },
1194 get_arch_fragment: function() {1194 set_arch_fragment: function() {
1195 var doc = $.parseXML(instance.web.json_node_to_xml(this.fvg.arch)).documentElement;1195 var doc = $.parseXML(instance.web.json_node_to_xml(this.fvg.arch)).documentElement;
1196 this.json = instance.web.xml_to_json(doc);
1196 // IE won't allow custom button@type and will revert it to spec default : 'submit'1197 // IE won't allow custom button@type and will revert it to spec default : 'submit'
1197 $('button', doc).each(function() {1198 $('button', doc).each(function() {
1198 $(this).attr('data-button-type', $(this).attr('type')).attr('type', 'button');1199 $(this).attr('data-button-type', $(this).attr('type')).attr('type', 'button');
1199 });1200 });
1200 return $('<div class="oe_form"/>').append(instance.web.xml_to_str(doc));1201 this.$form = $('<div class="oe_form"/>').append(instance.web.xml_to_str(doc));
1201 },1202 },
1202 render_to: function($target) {1203 render_to: function($target) {
1203 var self = this;1204 var self = this;
1204 this.$target = $target;1205 this.$target = $target;
12051206 this.set_arch_fragment();
1206 this.$form = this.get_arch_fragment();
12071207
1208 this.process_version();1208 this.process_version();
12091209
@@ -1218,6 +1218,7 @@
1218 this.to_replace = [];1218 this.to_replace = [];
12191219
1220 _.each(this.fields_to_init, function($elem) {1220 _.each(this.fields_to_init, function($elem) {
1221 var iterator =self.$form.find($elem).index();
1221 var name = $elem.attr("name");1222 var name = $elem.attr("name");
1222 if (!self.fvg.fields[name]) {1223 if (!self.fvg.fields[name]) {
1223 throw new Error(_.str.sprintf(_t("Field '%s' specified in view could not be found."), name));1224 throw new Error(_.str.sprintf(_t("Field '%s' specified in view could not be found."), name));
@@ -1226,7 +1227,7 @@
1226 if (!obj) {1227 if (!obj) {
1227 throw new Error(_.str.sprintf(_t("Widget type '%s' is not implemented"), $elem.attr('widget')));1228 throw new Error(_.str.sprintf(_t("Widget type '%s' is not implemented"), $elem.attr('widget')));
1228 }1229 }
1229 var w = new (obj)(self.view, instance.web.xml_to_json($elem[0]));1230 var w = new (obj)(self.view, self.json.children[iterator]);
1230 var $label = self.labels[$elem.attr("name")];1231 var $label = self.labels[$elem.attr("name")];
1231 if ($label) {1232 if ($label) {
1232 w.set_input_id($label.attr("for"));1233 w.set_input_id($label.attr("for"));
@@ -1236,15 +1237,17 @@
1236 self.to_replace.push([w, $elem]);1237 self.to_replace.push([w, $elem]);
1237 });1238 });
1238 _.each(this.tags_to_init, function($elem) {1239 _.each(this.tags_to_init, function($elem) {
1240 var iterator =self.$form.find($elem).index();
1239 var tag_name = $elem[0].tagName.toLowerCase();1241 var tag_name = $elem[0].tagName.toLowerCase();
1240 var obj = self.tags_registry.get_object(tag_name);1242 var obj = self.tags_registry.get_object(tag_name);
1241 var w = new (obj)(self.view, instance.web.xml_to_json($elem[0]));1243 var w = new (obj)(self.view, self.json.children[iterator]);
1242 self.to_replace.push([w, $elem]);1244 self.to_replace.push([w, $elem]);
1243 });1245 });
1244 _.each(this.widgets_to_init, function($elem) {1246 _.each(this.widgets_to_init, function($elem) {
1247 var iterator =self.$form.find($elem).index();
1245 var widget_type = $elem.attr("type");1248 var widget_type = $elem.attr("type");
1246 var obj = self.widgets_registry.get_object(widget_type);1249 var obj = self.widgets_registry.get_object(widget_type);
1247 var w = new (obj)(self.view, instance.web.xml_to_json($elem[0]));1250 var w = new (obj)(self.view, self.json.children[iterator]);
1248 self.to_replace.push([w, $elem]);1251 self.to_replace.push([w, $elem]);
1249 });1252 });
1250 },1253 },
12511254
=== modified file 'addons/web/static/src/js/views.js'
--- addons/web/static/src/js/views.js 2012-12-21 11:36:57 +0000
+++ addons/web/static/src/js/views.js 2012-12-27 13:44:23 +0000
@@ -1435,7 +1435,10 @@
1435 case 4:1435 case 4:
1436 return (strip_whitespace && node.data.trim() === '') ? undefined : node.data;1436 return (strip_whitespace && node.data.trim() === '') ? undefined : node.data;
1437 case 1:1437 case 1:
1438 var attrs = $(node).getAttributes();1438 var attrs = {};
1439 _.each(node.attributes, function(attr) {
1440 attrs[attr.name] = attr.value;
1441 });
1439 _.each(['domain', 'filter_domain', 'context', 'default_get'], function(key) {1442 _.each(['domain', 'filter_domain', 'context', 'default_get'], function(key) {
1440 if (attrs[key]) {1443 if (attrs[key]) {
1441 try {1444 try {