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 | |
| 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')
| -rw-r--r-- | addons/base_dashboard/static/src/dashboard_template.html | 85 | ||||
| -rw-r--r-- | addons/base_dashboard/static/src/js/dashboard.js | 104 | ||||
| -rw-r--r-- | addons/base_dashboard/static/src/xml/base_dashboard.xml | 12 |
3 files changed, 201 insertions, 0 deletions
diff --git a/addons/base_dashboard/static/src/dashboard_template.html b/addons/base_dashboard/static/src/dashboard_template.html new file mode 100644 index 00000000000..f78f8b861a8 --- /dev/null +++ b/addons/base_dashboard/static/src/dashboard_template.html @@ -0,0 +1,85 @@ +<script type="text/html" id="categorytemplate"> + <li id="<%= id %>" class="selectcategory"><button><%= title %> (<%= amount %>)</button></li> +</script> + + +<script type="text/html" id="widgettemplate"> + <div class="ui-widget ui-corner-all ui-widget-content widget" id="<%= id %>" title="<%= title %>"> + <div class="ui-widget-header ui-corner-all widgetheader"> + <span class="widgettitle"><%= title %></span> + <span class="right icons hidden"> + <span class="ui-icon ui-icon-newwin widgetopenfullscreen"></span> + <span class="ui-icon ui-icon-arrowthickstop-1-s menutrigger"></span> + <span class="hiddenmenu"> + <ul style="top: 13px;" class="hidden controls ui-widget-header"> + <li class="widgetClose"> + <span class="ui-icon ui-icon-minus"></span> + <a class="minimization" href="#">Minimize</a> + </li> + <li class="widgetOpen"> + <span class="ui-icon ui-icon-extlink"></span> + <a class="minimization" href="#">Maximize</a> + </li> + <li class="widgetDelete"> + <span class="ui-icon ui-icon-close"></span> + <a class="delete" href="#">Delete</a> + </li> + <!-- This could be implemented --> + <!-- + <li class="widgetEdit"> + <span class="ui-icon ui-icon-tag"></span> + <a class="no_target" href="#">Edit</a> + </li> + --> + <li class="widgetRefresh"> + <span class="ui-icon ui-icon-arrowrefresh-1-w"></span> + <a class="no_target" href="#">Refresh</a> + </li> + </ul> + </span> + </span> + </div> + <div class="widgetcontent"> + </div> + </div> +</script> + +<script type="text/html" id="selectlayouttemplate"> + <li class="layoutchoice" id="<%= id %>" style="background-image: url('<%= image %>')"></li> +</script> + +<script type="text/html" id="addwidgettemplate"> + + <li class="widgetitem"> + <img src="<%= image %>" alt="" height="60" width="120"> + <div class="add-button"> + <input class="macro-button-add addwidget" id="addwidget<%= id %>" value="Add it Now" type="button"><br> + <input class="macro-hidden-uri" value="<%= url %>" type="hidden"> + </div> + <!-- // .add-button --> + <h3><a href=""><%= title %></a></h3> + + <p>By <%= creator %></p> + <p><%= description %></p> + </li> + +</script> + +<div class="dialog" id="addwidgetdialog" title="Widget Directory"> + <ul class="categories"> + </ul> + + <div class="panel-body"> + <ol id="category-all" class="widgets"> + </ol> + </div> +</div> + + +<div class="dialog" id="editLayout" title="Edit layout"> + <div class="panel-body" id="layout-dialog"> + <p><strong>Choose dashboard layout</strong></p> + <ul class="layoutselection"> + </ul> + </div> +</div>
\ No newline at end of file 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 diff --git a/addons/base_dashboard/static/src/xml/base_dashboard.xml b/addons/base_dashboard/static/src/xml/base_dashboard.xml new file mode 100644 index 00000000000..efe0a92c4dc --- /dev/null +++ b/addons/base_dashboard/static/src/xml/base_dashboard.xml @@ -0,0 +1,12 @@ +<template> + <t t-name="Board"> + <div id="dashboard" class="dashboard"> + <!-- this HTML covers all layouts. The 5 different layouts are handled by setting another layout classname --> + <div class="layout"> + <div id="column-first" class="column first column-first"></div> + <div id="column-second" class="column second column-second"></div> + <div id="column-third" class="column third column-third"></div> + </div> + </div> + </t> +</template>
\ No newline at end of file |
