diff options
| author | Fabien Meghazi <fme@openerp.com> | 2011-06-01 15:48:00 +0200 |
|---|---|---|
| committer | Fabien Meghazi <fme@openerp.com> | 2011-06-01 15:48:00 +0200 |
| commit | 82d7cefef253239ec2a4fcac4ac870e23e31ceba (patch) | |
| tree | 2af01f865784aef0c1a442694ceac68635f86dd4 /addons/base_dashboard/static/src | |
| parent | dac344cf3115e6e872809c5c03d3ff07968df6e5 (diff) | |
[ADD] Save Dashboard's custom views with "Undo" button support
bzr revid: fme@openerp.com-20110601134800-d9j48t4f287pokr6
Diffstat (limited to 'addons/base_dashboard/static/src')
| -rw-r--r-- | addons/base_dashboard/static/src/css/dashboard.css | 9 | ||||
| -rw-r--r-- | addons/base_dashboard/static/src/js/dashboard.js | 43 | ||||
| -rw-r--r-- | addons/base_dashboard/static/src/xml/base_dashboard.xml | 15 |
3 files changed, 51 insertions, 16 deletions
diff --git a/addons/base_dashboard/static/src/css/dashboard.css b/addons/base_dashboard/static/src/css/dashboard.css index 071a8cb8228..57f1ceb8f98 100644 --- a/addons/base_dashboard/static/src/css/dashboard.css +++ b/addons/base_dashboard/static/src/css/dashboard.css @@ -18,6 +18,15 @@ .openerp .oe-dashboard-action .oe-dashboard-action-header:hover { cursor: move; } +.openerp .oe-dashboard-action .ui-icon { + cursor: pointer; +} +.openerp .oe-dashboard-action .ui-icon:hover { + background-color: #ccc; + border-radius: 4px; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; +} .openerp .oe-dashboard-action .oe-dashboard-action-header .ui-icon { float: right; diff --git a/addons/base_dashboard/static/src/js/dashboard.js b/addons/base_dashboard/static/src/js/dashboard.js index 3e253194d57..8497ffc2ce5 100644 --- a/addons/base_dashboard/static/src/js/dashboard.js +++ b/addons/base_dashboard/static/src/js/dashboard.js @@ -10,22 +10,18 @@ openerp.base.form.DashBoard = openerp.base.form.Widget.extend({ start: function() { var self = this; this._super.apply(this, arguments); + this.$element.find(".oe-dashboard-column").sortable({ connectWith: ".oe-dashboard-column", scroll: false }).disableSelection().bind('sortstop', self.do_save_dashboard); + + // Events + this.$element.find('.oe-dashboard-link-undo').click(this.on_undo); 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(); - }); - - $('.oe-dashboard-column .ui-icon-closethick').click(function() { - $(this).parents('.oe-dashboard-action:first').remove(); - self.do_save_dashboard(); - }); + this.$element.find('.oe-dashboard-column .ui-icon-minusthick').click(this.on_fold_action); + this.$element.find('.oe-dashboard-column .ui-icon-closethick').click(this.on_close_action); this.actions_attrs = {}; // Init actions @@ -41,13 +37,28 @@ openerp.base.form.DashBoard = openerp.base.form.Widget.extend({ }); }); }, + on_undo: function() { + this.rpc('/base/view/undo_custom', { + view_id: this.view.fields_view.view_id + }, this.do_reload); + }, on_add_widget: function() { }, on_edit_layout: function() { }, + on_fold_action: function(e) { + var $e = $(e.currentTarget); + $e.toggleClass('ui-icon-minusthick ui-icon-plusthick'); + $e.parents('.oe-dashboard-action:first').find('.oe-dashboard-action-content').toggle(); + }, + on_close_action: function(e) { + $(e.currentTarget).parents('.oe-dashboard-action:first').remove(); + this.do_save_dashboard(); + }, do_save_dashboard: function() { var self = this; var board = { + form_title : this.view.fields_view.arch.attrs.string, style : this.$element.find('.oe-dashboard').attr('data-layout'), columns : [] }; @@ -59,7 +70,13 @@ openerp.base.form.DashBoard = openerp.base.form.Widget.extend({ }); board.columns.push(actions); }); - var xml = QWeb.render('DashBoard.xml', board); + var arch = QWeb.render('DashBoard.xml', board); + this.rpc('/base/view/add_custom', { + view_id: this.view.fields_view.view_id, + arch: arch + }, function() { + self.$element.find('.oe-dashboard-link-undo').show(); + }); }, on_load_action: function(result) { var action = result.result; @@ -76,6 +93,10 @@ openerp.base.form.DashBoard = openerp.base.form.Widget.extend({ }, render: function() { return QWeb.render(this.template, this); + }, + do_reload: function() { + this.view.view_manager.stop(); + this.view.view_manager.start(); } }); openerp.base.form.DashBoardLegacy = openerp.base.form.DashBoard.extend({ diff --git a/addons/base_dashboard/static/src/xml/base_dashboard.xml b/addons/base_dashboard/static/src/xml/base_dashboard.xml index 349823847aa..80667dec557 100644 --- a/addons/base_dashboard/static/src/xml/base_dashboard.xml +++ b/addons/base_dashboard/static/src/xml/base_dashboard.xml @@ -1,6 +1,9 @@ <template> <t t-name="DashBoard"> <div class="oe-dashboard-links"> + <button type="button" class="button oe-dashboard-link-undo" t-att-style="view.fields_view.custom_view_id ? null : 'display: none'"> + Undo + </button> <button type="button" class="button oe-dashboard-link-add_widget"> Add Widget </button> @@ -40,10 +43,12 @@ </div> </t> <t t-name="DashBoard.xml"> - <board t-att-style="style"> - <column t-foreach="columns" t-as="column"> - <action t-foreach="column" t-as="action" t-att="action"/> - </column> - </board> + <form t-att-string="form_title"> + <board t-att-style="style"> + <column t-foreach="columns" t-as="column"> + <action t-foreach="column" t-as="action" t-att="action"/> + </column> + </board> + </form> </t> </template> |
