Revert "[IMP] web: filter when clicking on tags in Kanban"

This reverts commit b6ef149b as it seems that we don't want this
feature ultimately (was confusing for users trying to open the
record, but it filtered instead).

Note that opening the record by clicking on a tag still doesn't
work, but this is fixed by the next commit.
This commit is contained in:
Aaron Bohy
2017-09-30 15:59:24 +02:00
parent 776bac6a06
commit b53af081cb
4 changed files with 1 additions and 109 deletions
@@ -603,34 +603,6 @@ var SearchView = Widget.extend({
current_category = filter.category;
});
},
//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------
/**
* Activates a filter for a given domain.
* FIXME: the way it is done could be improved, but the actual state of the
* searchview doesn't allow to do much better. For instance, if the same
* filter is added twice, it appears twice in the facets. This should be
* improved when the searchview will be rewrote.
* @param {string} domain the domain to filter on
* @param {string} help the text to display in the facet
*/
addFilter: function (domain, help) {
var filter = {
attrs: {
domain: domain,
help: help,
},
};
var filterWidget = new search_inputs.Filter(filter);
var filterGroup = new search_inputs.FilterGroup([filterWidget], this);
var facet = filterGroup.make_facet([filterGroup.make_value(filter)]);
this.query.add([facet], {silent: true});
this.query.trigger('reset');
},
});
_.extend(SearchView, {
@@ -28,7 +28,6 @@ var ViewManager = Widget.extend(ControlPanelMixin, {
_.extend(this.env, this._process_search_data(d.domains, d.contexts, d.groupbys));
this.active_view.controller.reload(_.extend({offset: 0}, this.env));
},
add_filter: '_onAddFilter',
switch_view: function(event) {
if ('res_id' in event.data) {
this.env.currentId = event.data.res_id;
@@ -652,14 +651,6 @@ var ViewManager = Widget.extend(ControlPanelMixin, {
// Handlers
//--------------------------------------------------------------------------
/**
* @private
*/
_onAddFilter: function (event) {
if (this.searchview) {
this.searchview.addFilter(event.data.domain, event.data.help);
}
},
/**
* This handler is probably called by a sub form view when the user discards
* its value. The usual result of this is that we switch back to the
@@ -1704,10 +1704,6 @@ var FormFieldMany2ManyTags = FieldMany2ManyTags.extend({
});
var KanbanFieldMany2ManyTags = FieldMany2ManyTags.extend({
events: _.extend({}, FieldMany2ManyTags.prototype.events, {
'click .o_tag': '_onTagClicked',
}),
//--------------------------------------------------------------------------
// Private
//--------------------------------------------------------------------------
@@ -1730,29 +1726,10 @@ var KanbanFieldMany2ManyTags = FieldMany2ManyTags.extend({
class: 'o_tag o_tag_color_' + (m2m.data[self.colorField] || 0),
text: m2m.data.display_name,
})
.data('res_id', m2m.res_id)
.prepend('<span>')
.appendTo(self.$el);
});
},
//--------------------------------------------------------------------------
// Handlers
//--------------------------------------------------------------------------
/**
* @private
* @param {MouseEvent} e
*/
_onTagClicked: function (e) {
var resID = $(e.currentTarget).data('res_id');
var record = _.findWhere(this.value.data, {res_id: resID});
var displayName = record.data.display_name;
this.trigger_up('add_filter', {
domain: "[['" + this.name + "','=','" + displayName + "']]",
help: displayName,
});
}
});
var FieldMany2ManyCheckBoxes = AbstractField.extend({
+1 -49
View File
@@ -518,7 +518,7 @@ QUnit.module('Views', {
});
QUnit.test('many2many_tags in kanban views', function (assert) {
assert.expect(12);
assert.expect(11);
this.data.partner.records[0].category_ids = [6, 7];
this.data.partner.records[1].category_ids = [7, 8];
@@ -545,14 +545,6 @@ QUnit.module('Views', {
assert.step(route);
return this._super.apply(this, arguments);
},
intercepts: {
add_filter: function (event) {
assert.deepEqual(event.data, {
domain: "[['category_ids','=','gold']]",
help: 'gold',
}, "should trigger an 'add_filter' event with correct data");
},
},
});
var $first_record = kanban.$('.o_kanban_record:first()');
@@ -579,46 +571,6 @@ QUnit.module('Views', {
assert.strictEqual(kanban.$('.o_kanban_record:first()').find('.o_field_many2manytags .o_tag').length, 2,
'first record should still contain only 2 tags');
// click on a tag to trigger a search by tag
kanban.$('.o_tag:contains(gold):first').click();
kanban.destroy();
});
QUnit.test('many2many_tags with no color field and search by tag', function (assert) {
assert.expect(3);
delete this.data.category.fields.color;
this.data.partner.records[0].category_ids = [6, 7];
var kanban = createView({
View: KanbanView,
model: 'partner',
data: this.data,
arch: '<kanban><templates><t t-name="kanban-box">' +
'<div>' +
'<field name="category_ids" widget="many2many_tags"/>' +
'<field name="foo"/>' +
'</div>' +
'</t></templates></kanban>',
intercepts: {
add_filter: function (event) {
assert.deepEqual(event.data, {
domain: "[['category_ids','=','gold']]",
help: 'gold',
}, "should trigger an 'add_filter' event with correct data");
},
},
});
var $first_record = kanban.$('.o_kanban_record:first()');
assert.strictEqual($first_record.find('.o_field_many2manytags .o_tag').length, 2,
'first record should contain 2 tags');
assert.ok($first_record.find('.o_tag.o_tag_color_0').hasClass('o_tag_color_0'),
'both tags should have the default color');
// click on a tag to trigger a search by tag
kanban.$('.o_tag:contains(gold):first').click();
kanban.destroy();
});