[IMP] RenderingEngine registry compliant. Also allows use of <any/> tag
bzr revid: fme@openerp.com-20120320143516-dxaj53nu6k8v6kxo
This commit is contained in:
parent
e2c7d8094a
commit
985d448f7c
|
@ -739,7 +739,7 @@ openerp.web.FormRenderingEngine = openerp.web.Widget.extend({
|
||||||
var xml = openerp.web.json_node_to_xml(fvg.arch);
|
var xml = openerp.web.json_node_to_xml(fvg.arch);
|
||||||
this.$form = $(xml);
|
this.$form = $(xml);
|
||||||
|
|
||||||
this.process_any(this.$form);
|
this.process(this.$form);
|
||||||
},
|
},
|
||||||
start: function() {
|
start: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -770,32 +770,23 @@ openerp.web.FormRenderingEngine = openerp.web.Widget.extend({
|
||||||
this.$element.toggleClass('oe_layout_debugging');
|
this.$element.toggleClass('oe_layout_debugging');
|
||||||
|
|
||||||
},
|
},
|
||||||
process_any: function($tag) {
|
process: function($tag) {
|
||||||
var self = this;
|
var self = this;
|
||||||
// TODO: extract embeded views before preprocessing
|
|
||||||
var tagname = $tag[0].nodeName.toLowerCase();
|
var tagname = $tag[0].nodeName.toLowerCase();
|
||||||
var fn = self['process_' + tagname];
|
var fn = self['process_' + tagname];
|
||||||
if (this.registry && this.registry.contains(tagname)) {
|
if (this.registry && this.registry.contains(tagname)) {
|
||||||
fn = this.registry.get_object(tagname);
|
fn = this.registry.get_object(tagname);
|
||||||
}
|
}
|
||||||
if (fn)
|
if (fn) {
|
||||||
fn.call(self, $tag);
|
var args = [].slice.call(arguments);
|
||||||
else { // generic tag handling, just process children
|
args[0] = $tag;
|
||||||
_.each($tag.children(), function(el) {
|
fn.apply(self, args);
|
||||||
self.process_any($(el));
|
} else {
|
||||||
|
// generic tag handling, just process children
|
||||||
|
$tag.children().each(function() {
|
||||||
|
self.process($(this));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
_.each(['field', 'group', 'notebook', 'separator', 'label'], function(tag) {
|
|
||||||
var fn = self['process_' + tag];
|
|
||||||
if (this.registry && this.registry.contains(tag)) {
|
|
||||||
fn = this.registry.get_object(tag);
|
|
||||||
}
|
|
||||||
$form.find(tag).each(function() {
|
|
||||||
fn.call(self, $(this), $form);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
},
|
},
|
||||||
process_field: function($field, no_process_label) {
|
process_field: function($field, no_process_label) {
|
||||||
var name = $field.attr('name'),
|
var name = $field.attr('name'),
|
||||||
|
@ -813,14 +804,15 @@ openerp.web.FormRenderingEngine = openerp.web.Widget.extend({
|
||||||
if (!$label.length) {
|
if (!$label.length) {
|
||||||
field_string = $label.attr('string') || $label.text() || field_string;
|
field_string = $label.attr('string') || $label.text() || field_string;
|
||||||
field_help = $label.attr('help') || field_help;
|
field_help = $label.attr('help') || field_help;
|
||||||
var label = $('<label/>').attr({
|
var $label = $('<label/>').attr({
|
||||||
'for' : name,
|
'for' : name,
|
||||||
'string' : field_string,
|
'string' : field_string,
|
||||||
'help' : field_help
|
'help' : field_help
|
||||||
});
|
});
|
||||||
label.insertBefore($field);
|
$label.insertBefore($field);
|
||||||
if (!no_process_label)
|
if (!no_process_label) {
|
||||||
this.process_label(label);
|
this.process($label);
|
||||||
|
}
|
||||||
if (field_colspan > 1) {
|
if (field_colspan > 1) {
|
||||||
$field.attr('colspan', field_colspan - 1);
|
$field.attr('colspan', field_colspan - 1);
|
||||||
}
|
}
|
||||||
|
@ -835,12 +827,8 @@ openerp.web.FormRenderingEngine = openerp.web.Widget.extend({
|
||||||
process_group: function($group) {
|
process_group: function($group) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var fields = [];
|
var fields = [];
|
||||||
_.each($group.children(), function(el) {
|
$group.children('field').each(function() {
|
||||||
var tagname = el.nodeName.toLowerCase();
|
self.process($(this), true);
|
||||||
if (tagname === "field") {
|
|
||||||
self.process_field($(el), true);
|
|
||||||
fields.push(el);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
var $new_group = $(QWeb.render('FormRenderingGroup', $group.getAttributes())),
|
var $new_group = $(QWeb.render('FormRenderingGroup', $group.getAttributes())),
|
||||||
$table;
|
$table;
|
||||||
|
@ -909,14 +897,15 @@ openerp.web.FormRenderingEngine = openerp.web.Widget.extend({
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
_.each(children, function(el) {
|
_.each(children, function(el) {
|
||||||
if (!_.include(fields, el))
|
if (!_.include(fields, el)) {
|
||||||
self.process_any($(el));
|
self.process($(el));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
process_notebook: function($notebook) {
|
process_notebook: function($notebook) {
|
||||||
var self = this;
|
var self = this;
|
||||||
_.each($notebook.children(), function(el) {
|
$notebook.children().each(function() {
|
||||||
self.process_any($(el));
|
self.process($(this));
|
||||||
});
|
});
|
||||||
var pages = [];
|
var pages = [];
|
||||||
$notebook.find('> page').each(function() {
|
$notebook.find('> page').each(function() {
|
||||||
|
|
Loading…
Reference in New Issue