mirror of https://github.com/OCA/web.git
[MIG] web_listview_invert_selection : Migration to 11.0
parent
d1dfc9c088
commit
0cd8a45484
|
@ -46,6 +46,7 @@ Contributors
|
|||
------------
|
||||
|
||||
* Antonio Esposito <a.esposito@onestein.nl>
|
||||
* Meet Dholakia <meetcomputer009@gmail.com>
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
{
|
||||
'name': 'List Invert Selection',
|
||||
'summary': 'Invert current selection of list of records',
|
||||
'version': '10.0.1.0.0',
|
||||
'version': '11.0.1.0.0',
|
||||
'category': 'Web',
|
||||
'author': 'Onestein,Odoo Community Association (OCA)',
|
||||
'website': 'http://www.onestein.eu',
|
||||
'website': 'https://github.com/OCA/web',
|
||||
'license': 'AGPL-3',
|
||||
'depends': [
|
||||
'web',
|
||||
|
@ -16,6 +16,5 @@
|
|||
'data': [
|
||||
'templates/assets.xml'
|
||||
],
|
||||
'qweb': ['static/src/xml/web_listview_invert_selection.xml'],
|
||||
'installable': True,
|
||||
}
|
||||
|
|
|
@ -3,32 +3,40 @@
|
|||
|
||||
odoo.define("web_listview_invert_selection", function (require) {
|
||||
"use strict";
|
||||
var ListView = require("web.ListView");
|
||||
var core = require('web.core');
|
||||
var _t = core._t;
|
||||
var ListRenderer = require('web.ListRenderer');
|
||||
|
||||
ListView.include(/** @lends instance.web.ListView# */{
|
||||
ListRenderer.include(/** @lends instance.web.ListView# */{
|
||||
|
||||
load_list: function (data, grouped) {
|
||||
var self = this;
|
||||
var result = this._super.apply(this, arguments);
|
||||
events: _.extend({}, ListRenderer.prototype.events, {
|
||||
'click .o_invert_selection': '_onInvertSelection',
|
||||
}),
|
||||
|
||||
this.$("span.o_invert_selection").click(function () {
|
||||
_onInvertSelection: function (event) {
|
||||
event.stopPropagation();
|
||||
var checked = self.$("tbody .o_list_record_selector input:checked");
|
||||
var unchecked = self.$("tbody .o_list_record_selector input:not(:checked)");
|
||||
checked.prop("checked", false);
|
||||
unchecked.prop("checked", true);
|
||||
this._updateSelection();
|
||||
},
|
||||
|
||||
var selected = [];
|
||||
checked.each(function () {
|
||||
selected.push($(this).attr("name"));
|
||||
});
|
||||
if (selected.length === 0) {
|
||||
self.$("thead .o_list_record_selector input").prop("checked", true);
|
||||
} else {
|
||||
self.$("thead .o_list_record_selector input").prop("checked", false);
|
||||
_renderHeader: function (isGrouped) {
|
||||
var $header = this._super.apply(this, arguments);
|
||||
if (this.hasSelectors) {
|
||||
$header.find('th.o_list_record_selector').prepend(this._renderInvertSelection('span'));
|
||||
}
|
||||
});
|
||||
return $header;
|
||||
},
|
||||
|
||||
_renderInvertSelection: function (tag) {
|
||||
var $icon = $('<button>', {class: 'fa fa-refresh o_invert_selection_btn', name: 'Invert Selection',
|
||||
'aria-label': _t('Invert Selection')});
|
||||
return $('<' + tag + '>')
|
||||
.addClass('o_invert_selection')
|
||||
.append($icon);
|
||||
},
|
||||
|
||||
return result;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<t t-extend="ListView">
|
||||
<t t-jquery="th.o_list_record_selector" t-operation="prepend">
|
||||
<div>
|
||||
<span class="o_invert_selection" title="Invert Selection"><i class="fa fa-refresh" aria-hidden="true"></i></span>
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
</templates>
|
Loading…
Reference in New Issue