[REF] web: remove unused legacy stuff

This commit removes the legacy CustomCheckbox and the backward
compatibility layer for the systray items. Both of them are no
longer used.

closes odoo/odoo#112718

Signed-off-by: Mathieu Duckerts-Antoine <dam@odoo.com>
This commit is contained in:
Aaron Bohy
2023-02-15 13:36:51 +01:00
parent 49159d791e
commit cfc5da5b30
6 changed files with 0 additions and 195 deletions
-2
View File
@@ -236,8 +236,6 @@ This module provides the core of the Odoo Web Client.
'web/static/src/legacy/legacy_promise_error_handler.js',
'web/static/src/legacy/legacy_rpc_error_handler.js',
'web/static/src/legacy/root_widget.js',
'web/static/src/legacy/systray_menu.js',
'web/static/src/legacy/systray_menu_item.js',
'web/static/src/legacy/backend_utils.js',
'web/static/src/legacy/utils.js',
'web/static/src/legacy/web_client.js',
@@ -1,66 +0,0 @@
odoo.define('web.CustomCheckbox', function (require) {
"use strict";
const utils = require('web.utils');
const { LegacyComponent } = require("@web/legacy/legacy_component");
/**
* Custom checkbox
*
* Component that can be used in templates to render the custom checkbox of Odoo.
*
* <CustomCheckbox
* value="boolean"
* disabled="boolean"
* text="'Change the label text'"
* onChange="_onValueChange"
* />
*
* @extends Component
*/
class CustomCheckbox extends LegacyComponent {
/**
* @param {Object} [props]
* @param {string | number | null} [props.id]
* @param {boolean} [props.value=false]
* @param {boolean} [props.disabled=false]
* @param {string} [props.text]
*/
setup() {
this._id = `checkbox-comp-${utils.generateID()}`;
}
}
CustomCheckbox.defaultProps = {
onChange: () => {},
};
CustomCheckbox.props = {
id: {
type: [String, Number],
optional: 1,
},
class: {
type: String,
optional: 1,
},
disabled: {
type: Boolean,
optional: 1,
},
onChange: {
type: Function,
optional: 1,
},
value: {
type: Boolean,
optional: 1,
},
text: {
type: String,
optional: 1,
},
};
CustomCheckbox.template = 'web.CustomCheckbox';
return CustomCheckbox;
});
@@ -1,3 +0,0 @@
odoo.define("web.SystrayMenu", function () {
return { Items: [] };
});
@@ -1,56 +0,0 @@
/** @odoo-module **/
import { ComponentAdapter } from "web.OwlCompatibility";
import * as legacySystrayMenu from "web.SystrayMenu";
import { registry } from "../core/registry";
import { LegacyComponent } from "@web/legacy/legacy_component";
import { Component, xml } from "@odoo/owl";
const systrayRegistry = registry.category("systray");
class SystrayItemAdapter extends ComponentAdapter {
constructor() {
super(...arguments);
this.env = Component.env;
}
}
// registers the legacy systray menu items from the legacy systray registry
// to the wowl one, but wrapped into Owl components
const legacySystrayMenuItems = legacySystrayMenu.Items;
const convertedItems = [];
let id = 1;
const legacySystrayItemTemplate = xml`<SystrayItemAdapter Component="Widget" />`;
function addSystrayItem(Widget) {
const name = `_legacy_systray_item_${id++}`;
class SystrayItem extends LegacyComponent {
setup() {
this.Widget = Widget;
}
}
SystrayItem.template = legacySystrayItemTemplate;
SystrayItem.components = { SystrayItemAdapter };
systrayRegistry.add(name, { Component: SystrayItem }, { sequence: Widget.prototype.sequence });
convertedItems.push(Widget);
}
legacySystrayMenuItems.forEach(addSystrayItem);
const push = legacySystrayMenuItems.push.bind(legacySystrayMenuItems);
legacySystrayMenuItems.push = function (Widget) {
push(Widget);
addSystrayItem(Widget);
};
const splice = legacySystrayMenuItems.splice.bind(legacySystrayMenuItems);
legacySystrayMenuItems.splice = function () {
splice(...arguments);
legacySystrayMenuItems.forEach((Widget) => {
if (!convertedItems.includes(Widget)) {
addSystrayItem(Widget);
}
});
};
-16
View File
@@ -80,22 +80,6 @@
</div>
</t>
<t t-name="web.CustomCheckbox" owl="1">
<div t-attf-class="{{ props.text ? 'form-check' : '' }}" t-att-class="props.class">
<input
t-att-id="props.id or _id"
type="checkbox"
class="form-check-input"
t-att-disabled="props.disabled"
t-att-checked="props.value"
t-on-change="(ev) => props.onChange(ev.target.checked)"
/>
<label t-att-for="props.id or _id" class="form-check-label">
<t t-esc="props.text or '&#8203;'"/>
</label>
</div>
</t>
<t t-name="web.CustomFileInput" owl="1">
<span class="o_file_input" aria-atomic="true" t-on-uploaded="(ev) => props.onUpload(ev.detail.files)">
<span class="o_file_input_trigger" t-on-click.prevent="() => this._onTriggerClicked()">
@@ -1,52 +0,0 @@
odoo.define('web.custom_checkbox_tests', function (require) {
"use strict";
const CustomCheckbox = require('web.CustomCheckbox');
const testUtils = require('web.test_utils');
const { createComponent, dom: testUtilsDom } = testUtils;
QUnit.module('Components', {}, function () {
QUnit.module('CustomCheckbox');
QUnit.test('test checkbox: default values', async function(assert) {
assert.expect(6);
const checkbox = await createComponent(CustomCheckbox, {});
assert.containsOnce(checkbox.el, 'input');
assert.containsNone(checkbox.el, 'input:disabled');
assert.containsOnce(checkbox.el, 'label');
const input = checkbox.el.querySelector('input');
assert.notOk(input.checked, 'checkbox should be unchecked');
assert.ok(input.id.startsWith('checkbox-comp-'));
await testUtilsDom.click(checkbox.el.querySelector('label'));
assert.ok(input.checked, 'checkbox should be checked');
});
QUnit.test('test checkbox: custom values', async function(assert) {
assert.expect(6);
const checkbox = await createComponent(CustomCheckbox, {
props: {
id: 'my-form-check',
disabled: true,
value: true,
text: 'checkbox',
}
});
assert.containsOnce(checkbox.el, 'input');
assert.containsOnce(checkbox.el, 'input:disabled');
assert.containsOnce(checkbox.el, 'label');
const input = checkbox.el.querySelector('input');
assert.ok(input.checked, 'checkbox should be checked');
assert.strictEqual(input.id, 'my-form-check');
assert.ok(input.checked, 'checkbox should be checked');
});
});
});