Skip to content

Commit

Permalink
[MIG] web_select_all_companies: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Yannick Olivier committed Apr 17, 2024
1 parent 6eed757 commit bf8e3c8
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 46 deletions.
4 changes: 2 additions & 2 deletions web_select_all_companies/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Copyright 2023 Camptocamp SA - Telmo Santos
# Copyright 2024 GumbysBE - Yannick Olivier
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

{
"name": "Web Select All Companies",
"summary": "Allows you to select all companies in one click.",
"version": "16.0.1.0.1",
"version": "17.0.1.0.0",
"category": "Web",
"website": "https://github.com/OCA/web",
"author": "Camptocamp, Odoo Community Association (OCA)",
"license": "LGPL-3",
"depends": ["web"],
"assets": {
"web.assets_backend": [
"web_select_all_companies/static/src/scss/switch_all_company_menu.scss",
"web_select_all_companies/static/src/xml/switch_all_company_menu.xml",
"web_select_all_companies/static/src/js/switch_all_company_menu.esm.js",
],
Expand Down
32 changes: 32 additions & 0 deletions web_select_all_companies/i18n/nl_BE.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_select_all_companies
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-04-15 14:44+0000\n"
"PO-Revision-Date: 2024-04-15 14:44+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: web_select_all_companies
#. odoo-javascript
#: code:addons/web_select_all_companies/static/src/xml/switch_all_company_menu.xml:0
#, python-format
msgid "All Companies"
msgstr "Alle bedrijven"

#. module: web_select_all_companies
#. odoo-javascript
#: code:addons/web_select_all_companies/static/src/xml/switch_all_company_menu.xml:0
#: code:addons/web_select_all_companies/static/src/xml/switch_all_company_menu.xml:0
#: code:addons/web_select_all_companies/static/src/xml/switch_all_company_menu.xml:0
#, python-format
msgid "Select All Companies"
msgstr "Selecteer Alle Bedrijven"
Original file line number Diff line number Diff line change
@@ -1,45 +1,27 @@
/** @odoo-module **/
/* Copyright 2023 Camptocamp - Telmo Santos
* Copyright 2024 Gumbys - Yannick Olivier
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
import {SwitchCompanyMenu} from "@web/webclient/switch_company_menu/switch_company_menu";
import {browser} from "@web/core/browser/browser";
import {patch} from "@web/core/utils/patch";

patch(SwitchCompanyMenu.prototype, "SwitchAllCompanyMenu", {
patch(SwitchCompanyMenu.prototype, {
setup() {
this._super(...arguments);
this.allCompanyIds = Object.values(this.companyService.availableCompanies).map(
super.setup(...arguments);
this.allCompanyIds = Object.values(this.companyService.allowedCompanies).map(
(x) => x.id
);
this.isAllCompaniesSelected = this.allCompanyIds.every((elem) =>
this.selectedCompanies.includes(elem)
this.companySelector.selectedCompaniesIds.includes(elem)
);
},

toggleSelectAllCompanies() {
var allCompanyIds = this.allCompanyIds;
if (this.isAllCompaniesSelected) {
// Deselect all
this.state.companiesToToggle = this.allCompanyIds;
this.toggleCompany(this.currentCompany.id);
this.isAllCompaniesSelected = false;
browser.clearTimeout(this.toggleTimer);
this.toggleTimer = browser.setTimeout(() => {
this.companyService.setCompanies(
"toggle",
...this.state.companiesToToggle
);
}, this.constructor.toggleDelay);
} else {
// Select all
this.state.companiesToToggle = [this.allCompanyIds];
this.isAllCompaniesSelected = true;
browser.clearTimeout(this.toggleTimer);
this.toggleTimer = browser.setTimeout(() => {
this.companyService.setCompanies(
"loginto",
...this.state.companiesToToggle
);
}, this.constructor.toggleDelay);
// Deselect
allCompanyIds = this.companyService.currentCompany.id;
}
this.companyService.setCompanies(allCompanyIds, false);
},
});

This file was deleted.

29 changes: 16 additions & 13 deletions web_select_all_companies/static/src/xml/switch_all_company_menu.xml
Original file line number Diff line number Diff line change
@@ -1,39 +1,42 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t
t-name="web_select_all_companies.SwitchAllCompanyMenu"
t-inherit="web.SwitchCompanyMenu"
t-inherit-mode="extension"
owl="1"
>

<t t-inherit="web.SwitchCompanyMenu" t-inherit-mode="extension">
<xpath expr="//t[@t-key='company.id']" position="before">
<DropdownItem class="'p-0 bg-white'">
<DropdownItem
class="'p-0'"
parentClosingMode="!isCompanyAllowed ? 'none' : 'all'"
>
<div class="d-flex">
<div
role="menuitemcheckbox"
t-att-aria-checked="isAllCompaniesSelected ? 'true' : 'false'"
aria-label="Select All Companies"
t-att-title="(isAllCompaniesSelected ? 'Unselect ' : 'Select ') + 'All Companies'"
tabindex="0"
t-attf-class="{{isCurrent ? 'border-primary' : ''}}"
class="border-end toggle_company"
t-on-click.stop="() => this.toggleSelectAllCompanies()"
>
<span class="btn btn-light border-0 p-2">
<span class="btn border-0 p-2">
<i
class="fa fa-fw py-2 text-primary"
class="fa fa-fw py-2"
t-att-class="isAllCompaniesSelected ? 'fa-check-square text-primary' : 'fa-square-o'"
/>
</span>
</div>
<div
role="button"
tabindex="0"
class="d-flex flex-grow-1 align-items-center py-0 ps-2 ms-1 me-2 all-companies-item"
t-att-aria-pressed="isAllCompaniesSelected ? 'true' : 'false'"
aria-label="Select All Companies"
class="d-flex flex-grow-1 align-items-center py-0 log_into ps-2"
title="Select All Companies"
name="select_all_companies"
t-on-click="() => this.toggleSelectAllCompanies()"
>
<span>All Companies</span>
</div>
</div>
</DropdownItem>
</xpath>
</t>

</templates>

0 comments on commit bf8e3c8

Please sign in to comment.