summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2015-08-24 09:31:52 +0200
committerAaron Bohy <aab@odoo.com>2015-09-01 20:05:09 +0200
commit0fe349def22d5832046ab89c7c629c73dc66d1c0 (patch)
treea32084b5c74570281402cd649fa5a60ac9ede6df /addons/web/static/src
parent5bd8e02dc854d6cb367817697c5446132f957302 (diff)
[IMP] web: sidebar: generalize it for client actions
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/views/form_view.js2
-rw-r--r--addons/web/static/src/js/views/list_view.js2
-rw-r--r--addons/web/static/src/js/views/pivot_view.js2
-rw-r--r--addons/web/static/src/js/widgets/sidebar.js18
-rw-r--r--addons/web/static/src/xml/base.xml4
5 files changed, 15 insertions, 13 deletions
diff --git a/addons/web/static/src/js/views/form_view.js b/addons/web/static/src/js/views/form_view.js
index 21d8659a7e9..c729e397b65 100644
--- a/addons/web/static/src/js/views/form_view.js
+++ b/addons/web/static/src/js/views/form_view.js
@@ -202,7 +202,7 @@ var FormView = View.extend(common.FieldManagerMixin, {
**/
render_sidebar: function($node) {
if (!this.sidebar && this.options.sidebar) {
- this.sidebar = new Sidebar(this);
+ this.sidebar = new Sidebar(this, {editable: this.is_action_enabled('edit')});
if (this.fields_view.toolbar) {
this.sidebar.add_toolbar(this.fields_view.toolbar);
}
diff --git a/addons/web/static/src/js/views/list_view.js b/addons/web/static/src/js/views/list_view.js
index 2fdab99f781..219a9308547 100644
--- a/addons/web/static/src/js/views/list_view.js
+++ b/addons/web/static/src/js/views/list_view.js
@@ -299,7 +299,7 @@ var ListView = View.extend( /** @lends instance.web.ListView# */ {
**/
render_sidebar: function($node) {
if (!this.sidebar && this.options.sidebar) {
- this.sidebar = new Sidebar(this);
+ this.sidebar = new Sidebar(this, {editable: this.is_action_enabled('edit')});
if (this.fields_view.toolbar) {
this.sidebar.add_toolbar(this.fields_view.toolbar);
}
diff --git a/addons/web/static/src/js/views/pivot_view.js b/addons/web/static/src/js/views/pivot_view.js
index c916749c0d5..1357f8ab278 100644
--- a/addons/web/static/src/js/views/pivot_view.js
+++ b/addons/web/static/src/js/views/pivot_view.js
@@ -118,7 +118,7 @@ var PivotView = View.extend({
**/
render_sidebar: function($node) {
if (this.xlwt_installed && $node && this.options.sidebar) {
- this.sidebar = new Sidebar(this);
+ this.sidebar = new Sidebar(this, {editable: this.is_action_enabled('edit')});
this.sidebar.add_items('other', [{
label: _t("Download xls"),
callback: this.download_table.bind(this),
diff --git a/addons/web/static/src/js/widgets/sidebar.js b/addons/web/static/src/js/widgets/sidebar.js
index 18f488cdfec..90ec1024d7c 100644
--- a/addons/web/static/src/js/widgets/sidebar.js
+++ b/addons/web/static/src/js/widgets/sidebar.js
@@ -13,17 +13,19 @@ var QWeb = core.qweb;
var _t = core._t;
var Sidebar = Widget.extend({
- init: function(parent) {
+ init: function(parent, options) {
var self = this;
this._super(parent);
- this.view = this.getParent();
- this.sections = [
- { 'name' : 'print', 'label' : _t('Print'), },
- { 'name' : 'other', 'label' : _t('More'), }
+ this.options = _.defaults(options || {}, {
+ 'editable': true
+ });
+ this.sections = options.sections || [
+ {name: 'print', label: _t('Print')},
+ {name: 'other', label: _t('More')},
];
- this.items = {
- 'print' : [],
- 'other' : []
+ this.items = options.items || {
+ print: [],
+ other: [],
};
this.fileupload_id = _.uniqueId('oe_fileupload');
$(window).on(this.fileupload_id, function() {
diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml
index 428a12db511..15b47d29a68 100644
--- a/addons/web/static/src/xml/base.xml
+++ b/addons/web/static/src/xml/base.xml
@@ -268,12 +268,12 @@
</t>
<a class="oe_file_attachment" t-att-title="item.title or ''" t-att-data-section="section.name" t-att-data-index="item_index" t-att-href="item.url">
<t t-raw="item.label"/>
- <span t-if="widget.view.is_action_enabled('edit') &amp;&amp; section.name == 'files' and !item.callback" class="oe_sidebar_delete_item" t-att-data-id="item.id" title="Delete this attachment">
+ <span t-if="section.name == 'files' and widget.options.editable and !item.callback" class="oe_sidebar_delete_item" t-att-data-id="item.id" title="Delete this attachment">
<i class="fa fa-trash-o"/>
</span>
</a>
</li>
- <li t-if="widget.view.is_action_enabled('edit') &amp;&amp; section.name == 'files'" class="oe_sidebar_add_attachment">
+ <li t-if="section.name == 'files' and widget.options.editable" class="oe_sidebar_add_attachment">
<t t-call="HiddenInputFile">
<t t-set="fileupload_id" t-value="widget.fileupload_id"/>
<t t-set="fileupload_action" t-translation="off">/web/binary/upload_attachment</t>