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>
|
* Antonio Esposito <a.esposito@onestein.nl>
|
||||||
|
* Meet Dholakia <meetcomputer009@gmail.com>
|
||||||
|
|
||||||
Maintainer
|
Maintainer
|
||||||
----------
|
----------
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
{
|
{
|
||||||
'name': 'List Invert Selection',
|
'name': 'List Invert Selection',
|
||||||
'summary': 'Invert current selection of list of records',
|
'summary': 'Invert current selection of list of records',
|
||||||
'version': '10.0.1.0.0',
|
'version': '11.0.1.0.0',
|
||||||
'category': 'Web',
|
'category': 'Web',
|
||||||
'author': 'Onestein,Odoo Community Association (OCA)',
|
'author': 'Onestein,Odoo Community Association (OCA)',
|
||||||
'website': 'http://www.onestein.eu',
|
'website': 'https://github.com/OCA/web',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'depends': [
|
'depends': [
|
||||||
'web',
|
'web',
|
||||||
|
@ -16,6 +16,5 @@
|
||||||
'data': [
|
'data': [
|
||||||
'templates/assets.xml'
|
'templates/assets.xml'
|
||||||
],
|
],
|
||||||
'qweb': ['static/src/xml/web_listview_invert_selection.xml'],
|
|
||||||
'installable': True,
|
'installable': True,
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,32 +3,40 @@
|
||||||
|
|
||||||
odoo.define("web_listview_invert_selection", function (require) {
|
odoo.define("web_listview_invert_selection", function (require) {
|
||||||
"use strict";
|
"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) {
|
events: _.extend({}, ListRenderer.prototype.events, {
|
||||||
var self = this;
|
'click .o_invert_selection': '_onInvertSelection',
|
||||||
var result = this._super.apply(this, arguments);
|
}),
|
||||||
|
|
||||||
this.$("span.o_invert_selection").click(function () {
|
_onInvertSelection: function (event) {
|
||||||
var checked = self.$("tbody .o_list_record_selector input:checked");
|
event.stopPropagation();
|
||||||
var unchecked = self.$("tbody .o_list_record_selector input:not(:checked)");
|
var checked = self.$("tbody .o_list_record_selector input:checked");
|
||||||
checked.prop("checked", false);
|
var unchecked = self.$("tbody .o_list_record_selector input:not(:checked)");
|
||||||
unchecked.prop("checked", true);
|
checked.prop("checked", false);
|
||||||
|
unchecked.prop("checked", true);
|
||||||
|
this._updateSelection();
|
||||||
|
},
|
||||||
|
|
||||||
var selected = [];
|
_renderHeader: function (isGrouped) {
|
||||||
checked.each(function () {
|
var $header = this._super.apply(this, arguments);
|
||||||
selected.push($(this).attr("name"));
|
if (this.hasSelectors) {
|
||||||
});
|
$header.find('th.o_list_record_selector').prepend(this._renderInvertSelection('span'));
|
||||||
if (selected.length === 0) {
|
}
|
||||||
self.$("thead .o_list_record_selector input").prop("checked", true);
|
return $header;
|
||||||
} else {
|
},
|
||||||
self.$("thead .o_list_record_selector input").prop("checked", false);
|
|
||||||
}
|
_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