From b987405134e09aeacabbeeeb3edbdf3fe64ce065 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 18 Mar 2014 10:29:55 +0100 Subject: [PATCH 01/10] [IMP] Sidebar: added a new section for the sidebar, the buttons section. When having actions to display in the 'more' menu and if the action id is present in the context, get the action out of the menu to display a specific red button. This is used to highlight some specific action to do in a given flow. For example when going to a list view from a button, with an action that should be the next one to perform, it allows to display the button once at least one record is selected. bzr revid: tde@openerp.com-20140318092955-vym3d7xkl3mmf62i --- addons/web/static/src/js/views.js | 43 +++++++++++++++++++----------- addons/web/static/src/xml/base.xml | 8 +++++- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index c9229c3c70a..829a6251404 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -1117,10 +1117,12 @@ instance.web.Sidebar = instance.web.Widget.extend({ this._super(parent); var view = this.getParent(); this.sections = [ + { 'name': 'buttons', 'label': _t('Button'), }, { 'name' : 'print', 'label' : _t('Print'), }, { 'name' : 'other', 'label' : _t('More'), } ]; this.items = { + 'buttons': [], 'print' : [], 'other' : [] }; @@ -1132,22 +1134,24 @@ instance.web.Sidebar = instance.web.Widget.extend({ }); }, start: function() { - var self = this; this._super(this); this.redraw(); - this.$el.on('click','.oe_dropdown_menu li a', function(event) { - var section = $(this).data('section'); - var index = $(this).data('index'); - var item = self.items[section][index]; - if (item.callback) { - item.callback.apply(self, [item]); - } else if (item.action) { - self.on_item_action_clicked(item); - } else if (item.url) { - return true; - } - event.preventDefault(); - }); + this.$el.on('click', 'button.oe_sidebar_button', this.on_item_click); + this.$el.on('click','.oe_dropdown_menu li a', this.on_item_click); + }, + on_item_click: function (event) { + var self = this; + var section = $(event.currentTarget).data('section'); + var index = $(event.currentTarget).data('index'); + var item = self.items[section][index]; + if (item.callback) { + item.callback.apply(self, [item]); + } else if (item.action) { + self.on_item_action_clicked(item); + } else if (item.url) { + return true; + } + event.preventDefault(); }, redraw: function() { var self = this; @@ -1197,17 +1201,26 @@ instance.web.Sidebar = instance.web.Widget.extend({ }, add_toolbar: function(toolbar) { var self = this; + var context = self.getParent().dataset.context; // not sure this is the correct way to find the context + var highlighted_act_ids = context['view_manager_highlight'] || []; _.each(['print','action','relate'], function(type) { var items = toolbar[type]; if (items) { for (var i = 0; i < items.length; i++) { + var section_code = 'other'; + if (highlighted_act_ids && _.indexOf(highlighted_act_ids, items[i]['id']) != -1) { + section_code = 'buttons'; + } + else if (type == 'print') { + section_code = 'print'; + } items[i] = { label: items[i]['name'], action: items[i], classname: 'oe_sidebar_' + type }; + self.add_items(section_code, [items[i]]); } - self.add_items(type=='print' ? 'print' : 'other', items); } }); }, diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 7ba06b69095..6f1c98cdda2 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -599,10 +599,16 @@
- + + +
  • From 1a086bca821df7fa95fb00d6a6474061cd444926 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 18 Mar 2014 11:25:01 +0100 Subject: [PATCH 02/10] [IMP] sidebar in list view: context should be the one of the dataset, allowing context propagation, not void default context. bzr revid: tde@openerp.com-20140318102501-pi6qcaz1zbu71tsh --- addons/web/static/src/js/views.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 829a6251404..e24de77ea4f 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -1531,7 +1531,7 @@ instance.web.View = instance.web.Widget.extend({ new instance.web.DataExport(this, this.dataset).open(); }, sidebar_eval_context: function () { - return $.when({}); + return $.when(new instance.web.CompoundContext(this.dataset.get_context())); }, /** * Asks the view to reload itself, if the reloading is asynchronous should From 2f0b59be37c2878aa3efcaa075a972eb80300469 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 20 Mar 2014 18:39:07 +0100 Subject: [PATCH 03/10] [IMP] list_view: allow displaying string-based buttons in list view and not only img-based buttons. bzr revid: tde@openerp.com-20140320173907-5b02atnispbznqmj --- addons/web/static/src/css/base.css | 2 +- addons/web/static/src/css/base.sass | 2 +- addons/web/static/src/js/view_list.js | 4 ++-- addons/web/static/src/xml/base.xml | 12 +++++++++--- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 6a20442ed41..3996579e02a 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -2877,7 +2877,7 @@ padding: 3px 6px; white-space: pre-line; } -.openerp .oe_list_content > tbody > tr > td > button, .openerp .oe_list_content > tbody > tr > th > button { +.openerp .oe_list_content > tbody > tr > td > button.btn_img, .openerp .oe_list_content > tbody > tr > th > button.btn_img { border: none; background: transparent; padding: 0; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index 38a47eed1c5..b08427e0832 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -2312,7 +2312,7 @@ $sheet-padding: 16px padding: 3px 6px white-space: pre-line > td, > th - > button + > button.btn_img border: none background: transparent padding: 0 diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 7426c70838c..d9a44fb991d 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -2260,8 +2260,8 @@ instance.web.list.Button = instance.web.list.Column.extend({ attrs = this.modifiers_for(row_data); } if (attrs.invisible) { return ''; } - - return QWeb.render('ListView.row.button', { + var template = this.icon && 'ListView.row.button' || 'ListView.row.text_button'; + return QWeb.render(template, { widget: this, prefix: instance.session.prefix, disabled: attrs.readonly diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 6f1c98cdda2..ded573f2af3 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -785,11 +785,17 @@ + + t-att-class="disabled ? 'oe_list_button_disabled btn_img' : 'btn_img'"> + +