[FIX] disable sorting (column-click) in an editable listview being edited
To do so, extract sort handling to its own method (bound using the events hash) and override-and-disable in editable. bzr revid: xmo@openerp.com-20121127094109-mojnq50mzsrcj3q0
This commit is contained in:
parent
e6d033755f
commit
ef5be74caa
|
@ -25,6 +25,9 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
|
||||||
'disable_editable_mode': false,
|
'disable_editable_mode': false,
|
||||||
},
|
},
|
||||||
view_type: 'tree',
|
view_type: 'tree',
|
||||||
|
events: {
|
||||||
|
'click thead th.oe_sortable[data-id]': 'sort_by_column'
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Core class for list-type displays.
|
* Core class for list-type displays.
|
||||||
*
|
*
|
||||||
|
@ -264,21 +267,6 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
|
||||||
'selected', [selection.ids, selection.records]);
|
'selected', [selection.ids, selection.records]);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Sorting columns
|
|
||||||
this.$el.find('thead').delegate('th.oe_sortable[data-id]', 'click', function (e) {
|
|
||||||
e.stopPropagation();
|
|
||||||
var $this = $(this);
|
|
||||||
self.dataset.sort($this.data('id'));
|
|
||||||
if($this.hasClass("sortdown") || $this.hasClass("sortup")) {
|
|
||||||
$this.toggleClass("sortdown").toggleClass("sortup");
|
|
||||||
} else {
|
|
||||||
$this.toggleClass("sortdown");
|
|
||||||
}
|
|
||||||
$this.siblings('.oe_sortable').removeClass("sortup sortdown");
|
|
||||||
|
|
||||||
self.reload_content();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Add button
|
// Add button
|
||||||
if (!this.$buttons) {
|
if (!this.$buttons) {
|
||||||
this.$buttons = $(QWeb.render("ListView.buttons", {'widget':self}));
|
this.$buttons = $(QWeb.render("ListView.buttons", {'widget':self}));
|
||||||
|
@ -360,6 +348,19 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
|
||||||
}
|
}
|
||||||
this.trigger('list_view_loaded', data, this.grouped);
|
this.trigger('list_view_loaded', data, this.grouped);
|
||||||
},
|
},
|
||||||
|
sort_by_column: function (e) {
|
||||||
|
e.stopPropagation();
|
||||||
|
var $column = $(e.currentTarget);
|
||||||
|
this.dataset.sort($column.data('id'));
|
||||||
|
if($column.hasClass("sortdown") || $column.hasClass("sortup")) {
|
||||||
|
$column.toggleClass("sortup sortdown");
|
||||||
|
} else {
|
||||||
|
$column.addClass("sortdown");
|
||||||
|
}
|
||||||
|
$column.siblings('.oe_sortable').removeClass("sortup sortdown");
|
||||||
|
|
||||||
|
this.reload_content();
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Configures the ListView pager based on the provided dataset's information
|
* Configures the ListView pager based on the provided dataset's information
|
||||||
*
|
*
|
||||||
|
|
|
@ -63,6 +63,12 @@ openerp.web.list_editable = function (instance) {
|
||||||
}
|
}
|
||||||
this._super();
|
this._super();
|
||||||
},
|
},
|
||||||
|
sort_by_column: function (e) {
|
||||||
|
e.stopPropagation();
|
||||||
|
if (!this.editor.is_editing()) {
|
||||||
|
this._super.apply(this, arguments);
|
||||||
|
}
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Handles the activation of a record in editable mode (making a record
|
* Handles the activation of a record in editable mode (making a record
|
||||||
* editable), called *after* the record has become editable.
|
* editable), called *after* the record has become editable.
|
||||||
|
|
Loading…
Reference in New Issue