2011-04-27 10:24:56 +00:00
|
|
|
openerp.base_dashboard = function(openerp){
|
|
|
|
|
2011-04-21 05:23:16 +00:00
|
|
|
QWeb.add_template('/base_dashboard/static/src/xml/base_dashboard.xml');
|
2011-04-27 10:24:56 +00:00
|
|
|
|
|
|
|
openerp.base.form.Board = openerp.base.form.Widget.extend({
|
|
|
|
init: function(view, node) {
|
2011-04-21 05:23:16 +00:00
|
|
|
|
|
|
|
this._super(view, node);
|
2011-04-27 10:24:56 +00:00
|
|
|
this.template = "Board";
|
2011-04-21 05:23:16 +00:00
|
|
|
},
|
|
|
|
start: function() {
|
|
|
|
this._super.apply(this, arguments);
|
2011-05-11 08:31:34 +00:00
|
|
|
|
|
|
|
this.$element.html(QWeb.render(this.template));
|
|
|
|
var $dashboard = this.$element.find('#dashboard');
|
|
|
|
var children = this.node.children;
|
|
|
|
|
|
|
|
for(var ch=0; ch < children.length; ch++) {
|
|
|
|
var node = children[ch];
|
|
|
|
|
|
|
|
var widget;
|
|
|
|
if(node.tag.indexOf('child') >= 0) {
|
|
|
|
widget = new (openerp.base.form.widgets.get_object('child')) (this.view, node, $dashboard);
|
|
|
|
} else {
|
|
|
|
//Vpaned
|
|
|
|
widget = new (openerp.base.form.widgets.get_object(node.tag)) (this.view, node, $dashboard);
|
|
|
|
}
|
|
|
|
|
|
|
|
widget.start();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
jQuery('.column').css('width', 100/children.length+'%');
|
2011-04-21 05:23:16 +00:00
|
|
|
},
|
2011-05-11 08:31:34 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
openerp.base.form.Dashbar = openerp.base.form.Widget.extend({
|
|
|
|
init: function(view, node, dashboard) {
|
|
|
|
this._super(view, node, dashboard);
|
|
|
|
this.dashboard = dashboard;
|
2011-05-17 13:17:03 +00:00
|
|
|
this.template = 'Portlet'
|
2011-05-11 08:31:34 +00:00
|
|
|
},
|
|
|
|
start: function() {
|
|
|
|
var $dashboard = this.dashboard;
|
2011-04-21 05:23:16 +00:00
|
|
|
var children = this.node.children;
|
2011-05-17 13:17:03 +00:00
|
|
|
$dashboard.append(QWeb.render(this.template, {widget: this, 'children': children}))
|
|
|
|
|
2011-05-11 08:31:34 +00:00
|
|
|
for(var chld=0; chld < children.length;chld++) {
|
|
|
|
var child = children[chld];
|
2011-05-11 09:13:42 +00:00
|
|
|
var widget = new (openerp.base.form.widgets.get_object(child.tag)) (this.view, child);
|
|
|
|
widget.start()
|
2011-04-27 10:24:56 +00:00
|
|
|
}
|
2011-05-17 13:17:03 +00:00
|
|
|
|
2011-05-11 08:31:34 +00:00
|
|
|
$( ".column" ).sortable({
|
|
|
|
connectWith: ".column"
|
|
|
|
});
|
|
|
|
|
|
|
|
$( ".portlet" ).addClass( "ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" )
|
|
|
|
.find( ".portlet-header" )
|
|
|
|
.addClass( "ui-widget-header ui-corner-all" )
|
|
|
|
.end()
|
|
|
|
.find( ".portlet-content" );
|
2011-05-17 13:17:03 +00:00
|
|
|
|
2011-05-11 08:31:34 +00:00
|
|
|
$( ".portlet-header .ui-icon" ).click(function() {
|
|
|
|
$( this ).toggleClass( "ui-icon-minusthick" ).toggleClass( "ui-icon-plusthick" );
|
|
|
|
$( this ).parents( ".portlet:first" ).find( ".portlet-content" ).toggle();
|
|
|
|
});
|
|
|
|
|
|
|
|
$( ".column" ).disableSelection();
|
2011-05-17 13:17:03 +00:00
|
|
|
}
|
2011-05-11 08:31:34 +00:00
|
|
|
})
|
2011-04-21 05:23:16 +00:00
|
|
|
|
|
|
|
openerp.base.form.Action = openerp.base.form.Widget.extend({
|
2011-05-11 09:13:42 +00:00
|
|
|
init: function(view, node) {
|
|
|
|
this._super(view, node);
|
2011-04-21 05:23:16 +00:00
|
|
|
},
|
|
|
|
start: function() {
|
|
|
|
this._super.apply(this, arguments);
|
2011-04-27 10:24:56 +00:00
|
|
|
this.rpc('/base_dashboard/dashboard/load',{
|
|
|
|
node_attrs: this.node.attrs
|
|
|
|
},
|
|
|
|
this.on_load_action);
|
2011-04-21 05:23:16 +00:00
|
|
|
},
|
|
|
|
|
2011-04-27 10:24:56 +00:00
|
|
|
on_load_action: function(result) {
|
|
|
|
var action = result.action;
|
2011-05-17 09:26:27 +00:00
|
|
|
action.flags = {
|
|
|
|
search_view : false,
|
|
|
|
sidebar : false,
|
2011-05-18 12:52:51 +00:00
|
|
|
views_switcher : false,
|
|
|
|
action_buttons : false
|
2011-05-17 09:26:27 +00:00
|
|
|
}
|
2011-04-28 03:33:00 +00:00
|
|
|
var node_attrs = this.node.attrs;
|
2011-05-17 13:17:03 +00:00
|
|
|
var content_id = 'portlet-content-'+node_attrs.name;
|
2011-05-11 09:13:42 +00:00
|
|
|
var action_manager = new openerp.base.ActionManager(this.session, content_id);
|
2011-04-27 10:24:56 +00:00
|
|
|
action_manager.start();
|
2011-05-11 09:13:42 +00:00
|
|
|
action_manager.do_action(action);
|
2011-04-21 05:23:16 +00:00
|
|
|
}
|
2011-04-27 10:24:56 +00:00
|
|
|
})
|
2011-04-21 05:23:16 +00:00
|
|
|
|
2011-04-28 10:45:21 +00:00
|
|
|
openerp.base.form.Vpaned = openerp.base.form.Widget.extend({
|
|
|
|
init: function(view, node, board, child_index) {
|
|
|
|
|
|
|
|
this._super(view, node, board, child_index);
|
|
|
|
this.board = board;
|
|
|
|
this.child_index = child_index;
|
|
|
|
},
|
|
|
|
start: function() {
|
|
|
|
this._super.apply(this, arguments);
|
|
|
|
var children = this.node.children;
|
|
|
|
for(var chld=0; chld<children.length; chld++) {
|
|
|
|
var ch_widget = children[chld].children;
|
|
|
|
for(var ch=0; ch<ch_widget.length; ch++) {
|
|
|
|
var widget_type = ch_widget[ch].tag;
|
|
|
|
var widget = new (openerp.base.form.widgets.get_object(widget_type)) (this.view, ch_widget[ch], this.board, this.child_index);
|
|
|
|
widget.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2011-04-27 10:24:56 +00:00
|
|
|
openerp.base.form.widgets.add('hpaned', 'openerp.base.form.Board');
|
2011-05-11 08:31:34 +00:00
|
|
|
openerp.base.form.widgets.add('child', 'openerp.base.form.Dashbar');
|
2011-04-28 10:45:21 +00:00
|
|
|
openerp.base.form.widgets.add('vpaned', 'openerp.base.form.Vpaned');
|
2011-04-27 10:24:56 +00:00
|
|
|
openerp.base.form.widgets.add('action', 'openerp.base.form.Action');
|
2011-05-17 09:26:27 +00:00
|
|
|
}
|