Browse Source

[MIG] web_listview_invert_selection : Migration to 11.0

pull/955/head
Meet Dholakia 6 years ago
committed by Dennis Sluijk
parent
commit
0cd8a45484
  1. 1
      web_listview_invert_selection/README.rst
  2. 5
      web_listview_invert_selection/__manifest__.py
  3. 52
      web_listview_invert_selection/static/src/js/web_listview_invert_selection.js
  4. 12
      web_listview_invert_selection/static/src/xml/web_listview_invert_selection.xml

1
web_listview_invert_selection/README.rst

@ -46,6 +46,7 @@ Contributors
------------
* Antonio Esposito <a.esposito@onestein.nl>
* Meet Dholakia <meetcomputer009@gmail.com>
Maintainer
----------

5
web_listview_invert_selection/__manifest__.py

@ -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,
}

52
web_listview_invert_selection/static/src/js/web_listview_invert_selection.js

@ -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 () {
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);
_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;
}
});
});

12
web_listview_invert_selection/static/src/xml/web_listview_invert_selection.xml

@ -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…
Cancel
Save