[imp] refactoring to allow passing objects instead of normal views declaration to view manager to allow passing additional options + small fix in form view about actions
bzr revid: nicolas.vanhoren@openerp.com-20110616142530-vbzf3z7atncf508y
This commit is contained in:
parent
34ea3495b9
commit
571771a879
|
@ -32,7 +32,7 @@ openerp.base.FormView = openerp.base.View.extend( /** @lends openerp.base.FormV
|
||||||
this.ready = false;
|
this.ready = false;
|
||||||
this.show_invalid = true;
|
this.show_invalid = true;
|
||||||
this.touched = false;
|
this.touched = false;
|
||||||
this.flags = this.view_manager.action.flags || {};
|
this.flags = this.view_manager.flags || {};
|
||||||
this.registry = openerp.base.form.widgets;
|
this.registry = openerp.base.form.widgets;
|
||||||
},
|
},
|
||||||
start: function() {
|
start: function() {
|
||||||
|
@ -1242,9 +1242,14 @@ openerp.base.form.FieldOne2Many = openerp.base.form.Field.extend({
|
||||||
modes = !!modes ? modes.split(",") : ["tree", "form"];
|
modes = !!modes ? modes.split(",") : ["tree", "form"];
|
||||||
var views = [];
|
var views = [];
|
||||||
_.each(modes, function(mode) {
|
_.each(modes, function(mode) {
|
||||||
var view = [false, mode == "tree" ? "list" : mode];
|
var view = {view_id: false, view_type: mode == "tree" ? "list" : mode};
|
||||||
if (self.field.views && self.field.views[mode]) {
|
if (self.field.views && self.field.views[mode]) {
|
||||||
view.push(self.field.views[mode]);
|
view.embedded_view = self.field.views[mode];
|
||||||
|
}
|
||||||
|
if(view.view_type === "list") {
|
||||||
|
view.options = {
|
||||||
|
"selectable": false
|
||||||
|
};
|
||||||
}
|
}
|
||||||
views.push(view);
|
views.push(view);
|
||||||
});
|
});
|
||||||
|
|
|
@ -78,7 +78,8 @@ openerp.base.ViewManager = openerp.base.Controller.extend({
|
||||||
this.dataset = dataset;
|
this.dataset = dataset;
|
||||||
this.searchview = null;
|
this.searchview = null;
|
||||||
this.active_view = null;
|
this.active_view = null;
|
||||||
this.views_src = views;
|
this.views_src = _.map(views, function(x)
|
||||||
|
{return x instanceof Array? {view_id: x[0], view_type: x[1]} : x;});
|
||||||
this.views = {};
|
this.views = {};
|
||||||
this.flags = this.flags || {};
|
this.flags = this.flags || {};
|
||||||
this.sidebar = new openerp.base.NullSidebar();
|
this.sidebar = new openerp.base.NullSidebar();
|
||||||
|
@ -94,14 +95,13 @@ openerp.base.ViewManager = openerp.base.Controller.extend({
|
||||||
self.on_mode_switch($(this).data('view-type'));
|
self.on_mode_switch($(this).data('view-type'));
|
||||||
});
|
});
|
||||||
_.each(this.views_src, function(view) {
|
_.each(this.views_src, function(view) {
|
||||||
self.views[view[1]] = { view_id: view[0], controller: null,
|
self.views[view.view_type] = $.extend({}, view, {controller: null});
|
||||||
embedded_view: view[2]};
|
|
||||||
});
|
});
|
||||||
if (this.flags.views_switcher === false) {
|
if (this.flags.views_switcher === false) {
|
||||||
this.$element.find('.oe_vm_switch').hide();
|
this.$element.find('.oe_vm_switch').hide();
|
||||||
}
|
}
|
||||||
// switch to the first one in sequence
|
// switch to the first one in sequence
|
||||||
return this.on_mode_switch(this.views_src[0][1]);
|
return this.on_mode_switch(this.views_src[0].view_type);
|
||||||
},
|
},
|
||||||
stop: function() {
|
stop: function() {
|
||||||
},
|
},
|
||||||
|
@ -118,7 +118,8 @@ openerp.base.ViewManager = openerp.base.Controller.extend({
|
||||||
if (!view.controller) {
|
if (!view.controller) {
|
||||||
// Lazy loading of views
|
// Lazy loading of views
|
||||||
var controllerclass = openerp.base.views.get_object(view_type);
|
var controllerclass = openerp.base.views.get_object(view_type);
|
||||||
var controller = new controllerclass( this, this.session, this.element_id + "_view_" + view_type, this.dataset, view.view_id);
|
var controller = new controllerclass( this, this.session, this.element_id + "_view_" + view_type,
|
||||||
|
this.dataset, view.view_id, view.options);
|
||||||
if (view.embedded_view) {
|
if (view.embedded_view) {
|
||||||
controller.set_embedded_view(view.embedded_view);
|
controller.set_embedded_view(view.embedded_view);
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,14 +232,14 @@
|
||||||
<!-- TODO prefix id with the element_id of the controller t-attf-id="#{prefix}_localid" -->
|
<!-- TODO prefix id with the element_id of the controller t-attf-id="#{prefix}_localid" -->
|
||||||
<div class="oe_vm_switch">
|
<div class="oe_vm_switch">
|
||||||
<t t-if="views.length != 1" t-foreach="views" t-as="view">
|
<t t-if="views.length != 1" t-foreach="views" t-as="view">
|
||||||
<button type="button" t-att-data-view-type="view[1]">
|
<button type="button" t-att-data-view-type="view.view_type">
|
||||||
<t t-esc="view[1]"/>
|
<t t-esc="view.view_type"/>
|
||||||
</button>
|
</button>
|
||||||
</t>
|
</t>
|
||||||
</div>
|
</div>
|
||||||
<div t-attf-id="#{prefix}_search" t-opentag="true"/>
|
<div t-attf-id="#{prefix}_search" t-opentag="true"/>
|
||||||
<t t-foreach="views" t-as="view">
|
<t t-foreach="views" t-as="view">
|
||||||
<div t-attf-id="#{prefix}_view_#{view[1]}"/>
|
<div t-attf-id="#{prefix}_view_#{view.view_type}"/>
|
||||||
</t>
|
</t>
|
||||||
</td>
|
</td>
|
||||||
<td class="view-manager-main-sidebar" height="100%">
|
<td class="view-manager-main-sidebar" height="100%">
|
||||||
|
|
Loading…
Reference in New Issue