mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[10.0][ADD] Module web_listview_invert_selection (#538)
* [10.0][ADD] Module web_listview_invert_selection * [FIX] Multiple code reviews * [FIX] Changed single-quotes to double-quotes for improving codacy tests;
This commit is contained in:
committed by
Dave Lasley
parent
21f50a61f1
commit
2b33af50de
@@ -0,0 +1,34 @@
|
||||
/* Copyright 2017 Onestein
|
||||
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
|
||||
|
||||
odoo.define("web_listview_invert_selection", function (require) {
|
||||
"use strict";
|
||||
var ListView = require("web.ListView");
|
||||
|
||||
ListView.include(/** @lends instance.web.ListView# */{
|
||||
|
||||
load_list: function (data, grouped) {
|
||||
var self = this;
|
||||
var result = this._super.apply(this, arguments);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
.o_list_view {
|
||||
.o_invert_selection {
|
||||
padding-left: 2px;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?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>
|
||||
Reference in New Issue
Block a user