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
ptsuva committed May 24, 2024
1 parent 340e3a9 commit 7b82b9e
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 34 deletions.
2 changes: 2 additions & 0 deletions web_select_all_companies/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ Authors
-------

* Camptocamp
* Alitec Pte Ltd

Contributors
------------

- Telmo Santos <[email protected]>
- Jay Patel <[email protected]>

Maintainers
-----------
Expand Down
6 changes: 3 additions & 3 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 Alitec Pte Ltd - Jay Patel
# 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.1",
"category": "Web",
"website": "https://github.com/OCA/web",
"author": "Camptocamp, Odoo Community Association (OCA)",
"author": "Camptocamp, Alitec Pte Ltd, 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
1 change: 1 addition & 0 deletions web_select_all_companies/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- Telmo Santos \<<[email protected]>\>
- Jay Patel \<<[email protected]>\>
2 changes: 2 additions & 0 deletions web_select_all_companies/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -399,12 +399,14 @@ <h1><a class="toc-backref" href="#toc-entry-2">Credits</a></h1>
<h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
<ul class="simple">
<li>Camptocamp</li>
<li>Alitec Pte Ltd</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<ul class="simple">
<li>Telmo Santos &lt;<a class="reference external" href="mailto:telmo.santos&#64;camptocamp.com">telmo.santos&#64;camptocamp.com</a>&gt;</li>
<li>Jay Patel &lt;<a class="reference external" href="mailto:jay&#64;alitec.sg">jay&#64;alitec.sg</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,44 +1,38 @@
/** @odoo-module **/
/* Copyright 2023 Camptocamp - Telmo Santos
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
/*
Copyright 2023 Camptocamp - Telmo Santos
Copyright 2024 Alitec Pte Ltd (https://www.alitec.sg) - Jay Patel
* 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();
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() {
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);
this.companySelector.switchCompany(
"loginto",
this.companyService.currentCompany.id
);
} else {
// Select all
this.state.companiesToToggle = [this.allCompanyIds];
const companiesToToggle = this.allCompanyIds;
this.isAllCompaniesSelected = true;
browser.clearTimeout(this.toggleTimer);
this.toggleTimer = browser.setTimeout(() => {
this.companyService.setCompanies(
"loginto",
...this.state.companiesToToggle
);
this.companyService.setCompanies(companiesToToggle);
}, this.constructor.toggleDelay);
}
},
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,33 @@
owl="1"
>
<xpath expr="//t[@t-key='company.id']" position="before">
<DropdownItem class="'p-0 bg-white'">
<DropdownItem class="'p-0'">
<div class="d-flex">
<div
role="menuitemcheckbox"
tabindex="0"
t-attf-class="{{isCurrent ? 'border-primary' : ''}}"
t-att-class="{ 'border-primary': isCurrent }"
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"
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.stop="() => this.toggleSelectAllCompanies()"
>
<span>All Companies</span>
<span
class="company_label pe-3 text-900 fw-bold"
>All Companies</span>
</div>
</div>
</DropdownItem>
Expand Down

0 comments on commit 7b82b9e

Please sign in to comment.