summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/widgets/sidebar.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/src/js/widgets/sidebar.js')
-rw-r--r--addons/web/static/src/js/widgets/sidebar.js37
1 files changed, 21 insertions, 16 deletions
diff --git a/addons/web/static/src/js/widgets/sidebar.js b/addons/web/static/src/js/widgets/sidebar.js
index 9ea15be128b..e2222526320 100644
--- a/addons/web/static/src/js/widgets/sidebar.js
+++ b/addons/web/static/src/js/widgets/sidebar.js
@@ -6,7 +6,6 @@ var data = require('web.data');
var Dialog = require('web.Dialog');
var framework = require('web.framework');
var pyeval = require('web.pyeval');
-var session = require('web.session');
var Widget = require('web.Widget');
var QWeb = core.qweb;
@@ -37,6 +36,7 @@ var Sidebar = Widget.extend({
start: function() {
var self = this;
this._super(this);
+ this.$el.addClass('btn-group');
this.redraw();
this.$el.on('click','.dropdown-menu li a', function(event) {
var section = $(this).data('section');
@@ -53,16 +53,19 @@ var Sidebar = Widget.extend({
});
},
redraw: function() {
- var self = this;
- self.$el.html(QWeb.render('Sidebar', {widget: self}));
+ this.$el.html(QWeb.render('Sidebar', {widget: this}));
// Hides Sidebar sections when item list is empty
- this.$('.oe_form_dropdown_section').each(function() {
- $(this).toggle(!!$(this).find('li').length);
+ this.$('.o_dropdown').each(function() {
+ if (!$(this).find('li').length) {
+ $(this).hide();
+ }
});
- self.$("[title]").tooltip({
+ this.$("[title]").tooltip({
delay: { show: 500, hide: 0}
});
+ this.$('.o_sidebar_add_attachment .o_form_binary_form').change(this.on_attachment_changed);
+ this.$('.o_sidebar_delete_attachment').click(this.on_attachment_delete);
},
/**
* For each item added to the section:
@@ -104,7 +107,6 @@ var Sidebar = Widget.extend({
items[i] = {
label: items[i]['name'],
action: items[i],
- classname: 'oe_sidebar_' + type
};
}
self.add_items(type=='print' ? 'print' : 'other', items);
@@ -184,16 +186,14 @@ var Sidebar = Widget.extend({
});
this.items.files = attachments;
this.redraw();
- this.$('.oe_sidebar_add_attachment .o_form_input_file').change(this.on_attachment_changed);
- this.$el.find('.oe_sidebar_delete_item').click(this.on_attachment_delete);
},
on_attachment_changed: function(e) {
var $e = $(e.target);
if ($e.val() !== '') {
- this.$el.find('form.o_form_binary_form').submit();
+ this.$('form.o_form_binary_form').submit();
$e.parent().find('input[type=file]').prop('disabled', true);
$e.parent().find('button').prop('disabled', true).find('img, span').toggle();
- this.$('.oe_sidebar_add_attachment a').text(_t('Uploading...'));
+ this.$('.o_sidebar_add_attachment a').text(_t('Uploading...'));
framework.blockUI();
}
},
@@ -202,11 +202,16 @@ var Sidebar = Widget.extend({
e.stopPropagation();
var self = this;
var $e = $(e.currentTarget);
- if (confirm(_t("Do you really want to delete this attachment ?"))) {
- (new data.DataSet(this, 'ir.attachment')).unlink([parseInt($e.attr('data-id'), 10)]).done(function() {
- self.do_attachement_update(self.dataset, self.model_id);
- });
- }
+ var options = {
+ confirm_callback: function () {
+ new data.DataSet(this, 'ir.attachment')
+ .unlink([parseInt($e.attr('data-id'), 10)])
+ .done(function() {
+ self.do_attachement_update(self.dataset, self.model_id);
+ });
+ }
+ };
+ Dialog.confirm(this, _t("Do you really want to delete this attachment ?"), options);
}
});