diff options
| author | niv-openerp <nicolas.vanhoren@openerp.com> | 2011-05-02 16:39:52 +0200 |
|---|---|---|
| committer | niv-openerp <nicolas.vanhoren@openerp.com> | 2011-05-02 16:39:52 +0200 |
| commit | 9f62f30f144d4e9b6a0dca16782b54ac44e2b8fc (patch) | |
| tree | b91abfea585287071042807f703b5f017ddc1a08 /addons/base_dashboard/static/src/js/dashboard.js | |
| parent | bbb6ed05ef5a70ac4b8e8fde1426f0271bce761c (diff) | |
| parent | d31fb15a73ab2e07a3fd84a9b3468dd969736a51 (diff) | |
[MERGE] Dashboard branch.
bzr revid: nicolas.vanhoren@openerp.com-20110502143952-rgmw9v84rnjqxq23
Diffstat (limited to 'addons/base_dashboard/static/src/js/dashboard.js')
| -rw-r--r-- | addons/base_dashboard/static/src/js/dashboard.js | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/addons/base_dashboard/static/src/js/dashboard.js b/addons/base_dashboard/static/src/js/dashboard.js new file mode 100644 index 00000000000..34d09f80e62 --- /dev/null +++ b/addons/base_dashboard/static/src/js/dashboard.js @@ -0,0 +1,104 @@ +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({ + init: function(view, node) { + + this._super(view, node); + this.template = "Board"; + }, + start: function() { + this._super.apply(this, arguments); + this.$element.html(QWeb.render(this.template)); + }, + + render: function() { + var self = this; + jQuery('body').append( + jQuery('<div>', {'id': 'dashboard_template'}).load('/base_dashboard/static/src/dashboard_template.html',self.on_loaded).hide() + ) + }, + + on_loaded: function() { + var children = this.node.children; + var board = jQuery('#dashboard').dashboard({ + layoutClass:'layout' + }); + board.init(); + for(var ch = 0; ch < children.length; ch++) { + var ch_widgets = children[ch].children; + for(var chld = 0; chld < ch_widgets.length; chld++) { + var widget_type = ch_widgets[chld].tag; + var child_index = widget_type == 'action' ? chld : ch; + var widget = new (openerp.base.form.widgets.get_object(widget_type)) (this.view, ch_widgets[chld], board, child_index); + widget.start(); + } + } + } +}); + +openerp.base.form.Action = 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); + this.rpc('/base_dashboard/dashboard/load',{ + node_attrs: this.node.attrs + }, + this.on_load_action); + }, + + on_load_action: function(result) { + var action = result.action; + + action.search_view = false; + action.no_sidebar = true; + action.search_view_id = false; + + var node_attrs = this.node.attrs; + var get_column = ['first', 'second', 'third']; + var board_element = this.board.element.find('[id=column-'+get_column[this.child_index]+']'); + + this.board.addWidget({ + 'id': node_attrs.name, + 'title': node_attrs.string, + }, board_element); + + var content_id = node_attrs.name+'-widgetcontent'; + this.board.getWidget(node_attrs.name).element.find('.widgetcontent').attr('id',content_id) + + action_manager = new openerp.base.ActionManager(this.session, content_id); + action_manager.start(); + this.board.getWidget(node_attrs.name).url = action_manager.do_action(action); + } +}) + +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(); + } + } + }, +}) + +openerp.base.form.widgets.add('hpaned', 'openerp.base.form.Board'); +openerp.base.form.widgets.add('vpaned', 'openerp.base.form.Vpaned'); +openerp.base.form.widgets.add('action', 'openerp.base.form.Action'); +}
\ No newline at end of file |
