[ADD] Kanban card are clickable
bzr revid: fme@openerp.com-20120524155837-5j6zflr5rldun98e
This commit is contained in:
parent
3dc215b157
commit
b70dd5534f
|
@ -39,29 +39,16 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
|
|||
var self = this;
|
||||
this._super.apply(this, arguments);
|
||||
// Bind kanban cards dropdown menus
|
||||
this.$element.on('click', '.oe_kanban_menuaction', function() {
|
||||
var $menu = $(this).next('.oe_kanban_menu');
|
||||
var show = !$menu.is(':visible');
|
||||
self.$element.find('.oe_kanban_menu').hide();
|
||||
var doc_width = $(document).width();
|
||||
$menu.toggle(show);
|
||||
if (show) {
|
||||
var offset = $menu.offset();
|
||||
var menu_width = $menu.width();
|
||||
var x = doc_width - offset.left - menu_width - 15;
|
||||
if (x < 0) {
|
||||
$menu.offset({ left: offset.left + x }).width(menu_width);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
$('html').on('click.kanban', function() {
|
||||
self.trigger('hide_menus');
|
||||
});
|
||||
$('html').on('click', function() {
|
||||
this.on('hide_menus', this, function() {
|
||||
self.$element.find('.oe_kanban_menu').hide();
|
||||
});
|
||||
},
|
||||
destroy: function() {
|
||||
this._super.apply(this, arguments);
|
||||
$('html').off('click');
|
||||
$('html').off('click.kanban');
|
||||
},
|
||||
on_loaded: function(data) {
|
||||
this.fields_view = data;
|
||||
|
@ -599,8 +586,8 @@ instance.web_kanban.KanbanRecord = instance.web.OldWidget.extend({
|
|||
this.$element.children(':first').addClass('oe_kanban_draghandle');
|
||||
}
|
||||
|
||||
this.$element.find('.oe_kanban_action').click(function(ev) {
|
||||
ev.preventDefault();
|
||||
this.$element.find('.oe_kanban_action').click(function() {
|
||||
self.view.trigger('hide_menus');
|
||||
var $action = $(this),
|
||||
type = $action.data('type') || 'button',
|
||||
method = 'do_action_' + (type === 'action' ? 'object' : type);
|
||||
|
@ -611,14 +598,31 @@ instance.web_kanban.KanbanRecord = instance.web.OldWidget.extend({
|
|||
} else {
|
||||
self.do_warn("Kanban: no action for type : " + type);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
this.$element.on('click', function(ev) {
|
||||
var tag = ev.target.tagName.toLowerCase();
|
||||
if (!$(ev.target).data('events')) {
|
||||
console.log(tag);
|
||||
this.$element.on('click', '.oe_kanban_menuaction', function() {
|
||||
var $menu = $(this).next('.oe_kanban_menu');
|
||||
var show = !$menu.is(':visible');
|
||||
self.view.trigger('hide_menus');
|
||||
var doc_width = $(document).width();
|
||||
$menu.toggle(show);
|
||||
if (show) {
|
||||
var offset = $menu.offset();
|
||||
var menu_width = $menu.width();
|
||||
var x = doc_width - offset.left - menu_width - 15;
|
||||
if (x < 0) {
|
||||
$menu.offset({ left: offset.left + x }).width(menu_width);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
this.$element.on('click', this.on_card_clicked);
|
||||
},
|
||||
on_card_clicked: function() {
|
||||
this.view.trigger('hide_menus');
|
||||
this.view.open_record(this.id);
|
||||
},
|
||||
setup_color_picker: function() {
|
||||
var self = this;
|
||||
|
@ -627,8 +631,8 @@ instance.web_kanban.KanbanRecord = instance.web.OldWidget.extend({
|
|||
$el.html(QWeb.render('KanbanColorPicker', {
|
||||
widget: this
|
||||
}));
|
||||
$el.on('click', 'a', function(ev) {
|
||||
ev.preventDefault();
|
||||
$el.on('click', 'a', function() {
|
||||
self.view.trigger('hide_menus');
|
||||
var color_field = $(this).parents('.oe_kanban_colorpicker').first().data('field') || 'color';
|
||||
var data = {};
|
||||
data[color_field] = $(this).data('color');
|
||||
|
@ -636,6 +640,7 @@ instance.web_kanban.KanbanRecord = instance.web.OldWidget.extend({
|
|||
self.record[color_field] = $(this).data('color');
|
||||
self.do_reload();
|
||||
});
|
||||
return false;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue