-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] web_select_all_companies: Migration to 17.0
- Loading branch information
Yannick Olivier
committed
Apr 17, 2024
1 parent
6eed757
commit bf8e3c8
Showing
5 changed files
with
59 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
36 changes: 9 additions & 27 deletions
36
web_select_all_companies/static/src/js/switch_all_company_menu.esm.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}, | ||
}); |
4 changes: 0 additions & 4 deletions
4
web_select_all_companies/static/src/scss/switch_all_company_menu.scss
This file was deleted.
Oops, something went wrong.
29 changes: 16 additions & 13 deletions
29
web_select_all_companies/static/src/xml/switch_all_company_menu.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |