Skip to content

Commit 739c776

Browse files
committed
[REF] web,*: ControlPanel's buttons should be direct children
This commit cleans up and simplifies the structure of the buttons provided by the views/actions and displayed in the ControlPanel (or modal's footer for the FormView). The point is to avoid unnecessary wrapper around them, reducing the DOM and also the rules necessary to handle the buttons' layout, gap... task-4277543 closes odoo#218123 Related: odoo/enterprise#89841 Signed-off-by: Adrien Dieudonné (adr) <[email protected]>
1 parent 6f8349b commit 739c776

File tree

25 files changed

+86
-153
lines changed

25 files changed

+86
-153
lines changed

addons/account/static/src/views/file_upload_kanban/file_upload_kanban_controller.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<templates>
22

33
<t t-name="account.FileuploadKanbanView.Buttons" t-inherit="web.KanbanView.Buttons" t-inherit-mode="primary">
4-
<xpath expr="//div[hasclass('o_cp_buttons')]" position="inside">
4+
<xpath expr="." position="inside">
55
<t t-call="account.DocumentViewUploadButton"/>
66
</xpath>
77
</t>

addons/account/static/src/views/file_upload_list/file_upload_list_controller.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<templates>
22

33
<t t-name="account.FileuploadListView.Buttons" t-inherit="web.ListView.Buttons" t-inherit-mode="primary">
4-
<xpath expr="//div[hasclass('o_list_buttons')]" position="inside">
4+
<xpath expr="." position="inside">
55
<t t-call="account.DocumentViewUploadButton"/>
66
</xpath>
77
</t>
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<templates>
33
<t t-name="DataRecycle.buttons" t-inherit="web.ListView.Buttons" t-inherit-mode="primary">
4-
<xpath expr="//div[hasclass('o_list_buttons')]" position="inside">
5-
<t t-if="hasSelectedRecords">
6-
<button type="button" class="btn btn-primary o_data_recycle_validate_button" t-on-click="onValidateClick">
7-
Validate
8-
</button>
9-
<button type="button" class="btn btn-secondary o_data_recycle_unselect_button" t-on-click="onUnselectClick">
10-
Unselect
11-
</button>
12-
</t>
4+
<xpath expr="." position="inside">
5+
<button t-if="hasSelectedRecords" type="button" class="btn btn-primary o_data_recycle_validate_button" t-on-click="onValidateClick">
6+
Validate
7+
</button>
8+
<button t-if="hasSelectedRecords" type="button" class="btn btn-secondary o_data_recycle_unselect_button" t-on-click="onUnselectClick">
9+
Unselect
10+
</button>
1311
</xpath>
1412
</t>
1513
</templates>

addons/hr_expense/static/src/views/kanban.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,12 @@ export class ExpenseDashboardKanbanRenderer extends ExpenseKanbanRenderer {
2525

2626
registry.category('views').add('hr_expense_kanban', {
2727
...kanbanView,
28-
buttonTemplate: 'hr_expense.KanbanButtons',
2928
Controller: ExpenseKanbanController,
3029
Renderer: ExpenseKanbanRenderer,
3130
});
3231

3332
registry.category('views').add('hr_expense_dashboard_kanban', {
3433
...kanbanView,
35-
buttonTemplate: 'hr_expense.KanbanButtons',
3634
Controller: ExpenseKanbanController,
3735
Renderer: ExpenseDashboardKanbanRenderer,
3836
});

addons/hr_expense/static/src/views/kanban.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,6 @@
1717
</xpath>
1818
</t>
1919

20-
<t t-name="hr_expense.KanbanButtons" t-inherit="web.KanbanView.Buttons" t-inherit-mode="primary">
21-
<xpath expr="//div[hasclass('o_cp_buttons')]" position="attributes">
22-
<!-- Ensure that dropdown items show vertically and not side-by-side -->
23-
<attribute name="class" remove="d-flex" separator=" "/>
24-
<attribute name="class" add="d-block d-xl-flex" separator=" "/>
25-
</xpath>
26-
</t>
27-
2820
<t t-name="hr_expense.KanbanView" t-inherit="web.KanbanView" t-inherit-mode="primary">
2921
<xpath expr="//button[hasclass('o-kanban-button-new')]" position="before">
3022
<input type="file" name="ufile" class="d-none" t-ref="fileInput" multiple="1" accept="*" t-on-change="onChangeFileInput" />

addons/hr_expense/static/src/views/list.xml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<templates xml:space="preserve">
33
<t t-name="hr_expense.ListButtons" t-inherit="web.ListView.Buttons" t-inherit-mode="primary">
4-
5-
<!-- hr.expense -->
6-
<xpath expr="//div[hasclass('o_list_buttons')]" position="attributes">
7-
<!-- Ensure that dropdown items show vertically and not side-by-side -->
8-
<attribute name="class" remove="d-flex" separator=" "/>
9-
<attribute name="class" add="d-block d-xl-flex" separator=" "/>
10-
</xpath>
11-
<xpath expr="//div[hasclass('o_list_buttons')]" position="inside">
4+
<xpath expr="." position="inside">
125
<button t-if="displaySubmit()" class="d-none d-md-block btn btn-secondary" t-on-click="() => this.onClick('action_submit')">
136
Submit
147
</button>

addons/hr_fleet/static/src/views/hr_fleet_kanban/hr_fleet_kanban_controller.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<templates>
33
<t t-name="hr_fleet.HrFleetKanbanController.Buttons" t-inherit="web.KanbanView.Buttons" t-inherit-mode="primary">
4-
<xpath expr="//div[hasclass('o_cp_buttons')]" position="inside">
4+
<xpath expr="." position="inside">
55
<input type="file" multiple="true" t-ref="uploadFileInput" class="o_input_file o_hidden" t-on-change.stop="onInputChange"/>
66
<button type="button" t-att-class="'btn ' + (!env.isSmall ? 'btn-primary' : 'btn-secondary')" t-on-click="() => this.uploadFileInput.el.click()">
77
Upload

addons/hr_holidays/static/src/views/view_dialog/form_view_dialog.xml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,13 @@
4040
t-on-click="() =>this.onClick('action_refuse')"
4141
data-hotkey="x">Refuse</button>
4242
</xpath>
43-
<xpath expr="//div" position="inside">
44-
<div class="ms-auto d-flex gap-1">
45-
<button class="btn btn-danger" t-if="canDelete" t-on-click="deleteRecord" data-hotkey="v">
46-
Delete Time Off
47-
</button>
48-
<button class="btn btn-danger" t-if="canCancel" t-on-click="cancelRecord" data-hotkey="x">
49-
Cancel Time Off
50-
</button>
51-
</div>
43+
<xpath expr="." position="inside">
44+
<button class="btn btn-danger ms-auto" t-if="canDelete" t-on-click="deleteRecord" data-hotkey="v">
45+
Delete Time Off
46+
</button>
47+
<button class="btn btn-danger" t-att-class="{'ms-auto': !canDelete}" t-if="canCancel" t-on-click="cancelRecord" data-hotkey="x">
48+
Cancel Time Off
49+
</button>
5250
</xpath>
5351
</t>
5452
</templates>

addons/loyalty/static/src/xml/loyalty_templates.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
</t>
5858

5959
<t t-name="loyalty.LoyaltyCardListView.buttons" t-inherit-mode="primary" t-inherit="web.ListView.Buttons">
60-
<xpath expr="//div[hasclass('o_list_buttons')]" position="inside">
60+
<xpath expr="." position="inside">
6161
<t t-set="supportedProgramTypes" t-value="['coupons', 'gift_card', 'ewallet']"/>
6262
<button t-if="supportedProgramTypes.includes(props.context.program_type)" type="button" class="btn btn-primary o_loyalty_card_list_button_generate" t-attf-data-tooltip="Generate {{props.context.program_item_name}}"
6363
t-on-click.stop.prevent="() => this.actionService.doAction('loyalty.loyalty_generate_wizard_action', { additionalContext: this.props.context, onClose: () => {this.model.load()} })">

addons/mrp/static/src/components/bom_overview_control_panel/mrp_bom_overview_control_panel.xml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,16 @@
33

44
<t t-name="mrp.BomOverviewControlPanel">
55
<ControlPanel display="controlPanelDisplay">
6-
<t t-if="props.showOptions.mode == 'forecast'" t-set-slot="control-panel-create-button">
7-
<button t-on-click="manufactureFromBoM" type="button" class="btn btn-primary">Manufacture</button>
6+
<t t-set-slot="control-panel-create-button">
7+
<button t-if="props.showOptions.mode == 'forecast'" t-on-click="manufactureFromBoM" type="button" class="btn btn-primary">Manufacture</button>
88
</t>
99
<t t-set-slot="control-panel-always-buttons">
10-
<div class="o_cp_buttons">
11-
<div class="o_list_buttons o_mrp_bom_report_buttons d-xl-flex gap-xl-1">
12-
<button t-on-click="() => this.props.print()" type="button" class="btn btn-secondary">Print</button>
13-
<!-- <t t-if="props.showVariants"> commented, waiting for ui update
14-
<button t-on-click="() => this.props.print(true)" type="button" class="btn btn-secondary text-nowrap">Print All Variants</button>
15-
</t>
16-
</t> -->
17-
<button t-if="props.foldable" t-on-click="clickTogglefold" type="button" class="btn btn-secondary" t-esc="foldButtonText"/>
18-
</div>
19-
</div>
10+
<button t-on-click="() => this.props.print()" type="button" class="btn btn-secondary">Print</button>
11+
<!-- <t t-if="props.showVariants"> commented, waiting for ui update
12+
<button t-on-click="() => this.props.print(true)" type="button" class="btn btn-secondary text-nowrap">Print All Variants</button>
13+
</t>
14+
</t> -->
15+
<button t-if="props.foldable" t-on-click="clickTogglefold" type="button" class="btn btn-secondary" t-esc="foldButtonText"/>
2016
</t>
2117
<t t-set-slot="layout-actions">
2218
<div t-if="props.showVariants" class="input-group align-items-center">

0 commit comments

Comments
 (0)