diff --git a/addons/base_dashboard/__init__.py b/addons/base_dashboard/__init__.py index 355939a4922..4265cc3e6c1 100644 --- a/addons/base_dashboard/__init__.py +++ b/addons/base_dashboard/__init__.py @@ -1 +1 @@ -import controllers \ No newline at end of file +#!/usr/bin/env python diff --git a/addons/base_dashboard/controllers/__init__.py b/addons/base_dashboard/controllers/__init__.py deleted file mode 100644 index 039d9715fab..00000000000 --- a/addons/base_dashboard/controllers/__init__.py +++ /dev/null @@ -1 +0,0 @@ -import main \ No newline at end of file diff --git a/addons/base_dashboard/controllers/main.py b/addons/base_dashboard/controllers/main.py deleted file mode 100644 index a223deda6be..00000000000 --- a/addons/base_dashboard/controllers/main.py +++ /dev/null @@ -1,17 +0,0 @@ -from base.controllers.main import View, clean_action -import openerpweb - -class Dashboard(View): - _cp_path = "/base_dashboard/dashboard" - - @openerpweb.jsonrequest - def load(self, req, node_attrs): - - action_id = int(node_attrs['name']) - actions = req.session.model('ir.actions.actions') - result = actions.read([action_id],['type'], req.session.context) - if not result: - raise _('Action not found!') - action = req.session.model(result[0]['type']).read([action_id], False, req.session.context)[0] - clean_action(action, req.session) - return {'action': action} \ No newline at end of file diff --git a/addons/base_dashboard/static/src/css/dashboard.css b/addons/base_dashboard/static/src/css/dashboard.css index 815c06b6bcd..071a8cb8228 100644 --- a/addons/base_dashboard/static/src/css/dashboard.css +++ b/addons/base_dashboard/static/src/css/dashboard.css @@ -1,36 +1,61 @@ -.column { - float: left; +.openerp .oe-dashboard-links { + text-align: right; + margin: -2em 1em 1em 0; +} +.openerp .oe-dashboard-column { + float: left; padding-bottom: 100px; } - -.portlet { +.openerp .oe-dashboard-action { margin: 0 1em 1em 0; } - -.portlet-header { - margin: 0.3em; - padding-bottom: 4px; - padding-left: 0.2em; +.openerp .oe-dashboard-action .oe-dashboard-action-header { + margin: 0.3em; + padding-bottom: 4px; + padding-left: 0.2em } -.portlet-header:hover { +.openerp .oe-dashboard-action .oe-dashboard-action-header:hover { cursor: move; } -.portlet-header .ui-icon { +.openerp .oe-dashboard-action .oe-dashboard-action-header .ui-icon { float: right; } -.portlet-content { +.openerp .oe-dashboard-action .oe-dashboard-action-content { padding: 0.4em; } -.ui-sortable-placeholder { - border: 1px dotted black; - visibility: visible !important; +.openerp .oe-dashboard .ui-sortable-placeholder { + border: 1px dotted black; + visibility: visible !important; height: 50px !important; } -.ui-sortable-placeholder * { +.openerp .oe-dashboard .ui-sortable-placeholder * { visibility: hidden; -} \ No newline at end of file +} + +/* Layouts */ +.openerp .oe-dashboard-layout_1 .oe-dashboard-column { + width: 100%; +} +.openerp .oe-dashboard-layout_1-1 .oe-dashboard-column { + width: 50%; +} +.openerp .oe-dashboard-layout_1-1-1 .oe-dashboard-column { + width: 33%; +} +.openerp .oe-dashboard-layout_2-1 .oe-dashboard-column.index_0 { + width: 70%; +} +.openerp .oe-dashboard-layout_2-1 .oe-dashboard-column.index_1 { + width: 30%; +} +.openerp .oe-dashboard-layout_1-2 .oe-dashboard-column.index_0 { + width: 30%; +} +.openerp .oe-dashboard-layout_1-2 .oe-dashboard-column.index_1 { + width: 70%; +} diff --git a/addons/base_dashboard/static/src/js/dashboard.js b/addons/base_dashboard/static/src/js/dashboard.js index 8f09f622050..3e253194d57 100644 --- a/addons/base_dashboard/static/src/js/dashboard.js +++ b/addons/base_dashboard/static/src/js/dashboard.js @@ -1,127 +1,108 @@ -openerp.base_dashboard = function(openerp){ +openerp.base_dashboard = function(openerp) { QWeb.add_template('/base_dashboard/static/src/xml/base_dashboard.xml'); -openerp.base.form.Board = openerp.base.form.Widget.extend({ +openerp.base.form.DashBoard = openerp.base.form.Widget.extend({ init: function(view, node) { - this._super(view, node); - this.template = "Board"; + this.template = "DashBoard"; }, start: function() { + var self = this; this._super.apply(this, arguments); - - 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+'%'); - }, -}); - - -openerp.base.form.Dashbar = openerp.base.form.Widget.extend({ - init: function(view, node, dashboard) { - this._super(view, node, dashboard); - this.dashboard = dashboard; - this.template = 'Portlet' - }, - start: function() { - var $dashboard = this.dashboard; - var children = this.node.children; - $dashboard.append(QWeb.render(this.template, {widget: this, 'children': children})) - - for(var chld=0; chld < children.length;chld++) { - var child = children[chld]; - var widget = new (openerp.base.form.widgets.get_object(child.tag)) (this.view, child); - widget.start() - } - $( ".column" ).sortable({ - connectWith: ".column", + this.$element.find(".oe-dashboard-column").sortable({ + connectWith: ".oe-dashboard-column", scroll: false + }).disableSelection().bind('sortstop', self.do_save_dashboard); + this.$element.find('.oe-dashboard-link-add_widget').click(this.on_add_widget); + this.$element.find('.oe-dashboard-link-edit_layout').click(this.on_edit_layout); + + this.$element.find('.oe-dashboard-column .ui-icon-minusthick').click(function() { + $(this).toggleClass('ui-icon-minusthick').toggleClass('ui-icon-plusthick'); + $(this).parents('.oe-dashboard-action:first .oe-dashboard-action-content').toggle(); }); - $( ".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" ); - - $( ".portlet-header .ui-icon" ).click(function() { - $( this ).toggleClass( "ui-icon-minusthick" ).toggleClass( "ui-icon-plusthick" ); - $( this ).parents( ".portlet:first" ).find( ".portlet-content" ).toggle(); - }); + $('.oe-dashboard-column .ui-icon-closethick').click(function() { + $(this).parents('.oe-dashboard-action:first').remove(); + self.do_save_dashboard(); + }); - $( ".column" ).disableSelection(); - } -}) - -openerp.base.form.Action = openerp.base.form.Widget.extend({ - init: function(view, node) { - this._super(view, node); + this.actions_attrs = {}; + // Init actions + _.each(this.node.children, function(column) { + _.each(column.children, function(action) { + delete(action.attrs.width); + delete(action.attrs.height); + delete(action.attrs.colspan); + self.actions_attrs[action.attrs.name] = action.attrs; + self.rpc('/base/action/load', { + action_id: parseInt(action.attrs.name, 10) + }, self.on_load_action); + }); + }); }, - start: function() { - this._super.apply(this, arguments); - this.rpc('/base_dashboard/dashboard/load',{ - node_attrs: this.node.attrs - }, - this.on_load_action); + on_add_widget: function() { + }, + on_edit_layout: function() { + }, + do_save_dashboard: function() { + var self = this; + var board = { + style : this.$element.find('.oe-dashboard').attr('data-layout'), + columns : [] + }; + this.$element.find('.oe-dashboard-column').each(function() { + var actions = []; + $(this).find('.oe-dashboard-action').each(function() { + var action_id = $(this).attr('data-id'); + actions.push(self.actions_attrs[action_id]); + }); + board.columns.push(actions); + }); + var xml = QWeb.render('DashBoard.xml', board); }, - on_load_action: function(result) { - var action = result.action; + var action = result.result; action.flags = { search_view : false, sidebar : false, views_switcher : false, - action_buttons : false + action_buttons : false, + pager: false } - var node_attrs = this.node.attrs; - var content_id = 'portlet-content-'+node_attrs.name; - var action_manager = new openerp.base.ActionManager(this.session, content_id); - action_manager.start(); - action_manager.do_action(action); + var element_id = this.view.element_id + '_action_' + action.id; + var view = new openerp.base.ViewManagerAction(this.session, element_id, action); + view.start(); + }, + render: function() { + return QWeb.render(this.template, this); } -}) - -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 - -
-
-
- -
-
-
- - -
-
+ + +
+
+ +
+ +
+ + +
+
- - \ No newline at end of file +
+
+
+ +
+

+ Choose dashboard layout +

+
    +
  • +
  • +
  • +
  • +
  • +
+
+
+ + + + + + + +