From a9ebd07b8028aa019e142d6809ec3aeba518a965 Mon Sep 17 00:00:00 2001 From: "Kartik Chavda (kcv)" Date: Thu, 21 Dec 2023 06:12:04 +0000 Subject: [PATCH] [IMP] web: validate button is missing in pivot view Steps: - Open Timesheets - Go to To Validate > All Timesheets - Pivot View is rendered Issue: The validate button is not rendered when the pivot view is loaded Solution: The changes introduced in these files are aimed at enhancing the customization and flexibility of the Pivot component in the web application. By adding the buttonTemplate prop to the PivotController and utilizing it in the PivotRenderer template, developers can dynamically choose the template for rendering buttons within the pivot view. This change is particularly beneficial for scenarios where different button layouts or styles are required based on specific use cases or user preferences. Additionally, the introduction of a default value for buttonTemplate in the PivotView configuration ensures a smooth fallback mechanism if a custom template is not explicitly provided. Overall, these adjustments contribute to a more adaptable and extensible Pivot component, catering to diverse application requirements. Task-3623493 closes odoo/odoo#155547 X-original-commit: f7fa6d66758b7ccbb0ae44e9f977177e6b29da6e Related: odoo/enterprise#57591 Signed-off-by: Xavier Bol (xbo) --- addons/web/static/src/views/pivot/pivot_controller.js | 1 + addons/web/static/src/views/pivot/pivot_controller.xml | 2 +- addons/web/static/src/views/pivot/pivot_renderer.js | 5 ++++- addons/web/static/src/views/pivot/pivot_renderer.xml | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/views/pivot/pivot_controller.js b/addons/web/static/src/views/pivot/pivot_controller.js index 86a63dddc0a..5f6b519d03e 100644 --- a/addons/web/static/src/views/pivot/pivot_controller.js +++ b/addons/web/static/src/views/pivot/pivot_controller.js @@ -44,4 +44,5 @@ PivotController.props = { Model: Function, modelParams: Object, Renderer: Function, + buttonTemplate: { type: String, optional: true }, }; diff --git a/addons/web/static/src/views/pivot/pivot_controller.xml b/addons/web/static/src/views/pivot/pivot_controller.xml index c29d7862a14..52ddb41a788 100644 --- a/addons/web/static/src/views/pivot/pivot_controller.xml +++ b/addons/web/static/src/views/pivot/pivot_controller.xml @@ -42,7 +42,7 @@ - + diff --git a/addons/web/static/src/views/pivot/pivot_renderer.js b/addons/web/static/src/views/pivot/pivot_renderer.js index ee398c716c2..8f961dcf2b0 100644 --- a/addons/web/static/src/views/pivot/pivot_renderer.js +++ b/addons/web/static/src/views/pivot/pivot_renderer.js @@ -241,4 +241,7 @@ export class PivotRenderer extends Component { } PivotRenderer.template = "web.PivotRenderer"; PivotRenderer.components = { Dropdown, DropdownItem, CheckBox, PivotGroupByMenu }; -PivotRenderer.props = ["model"]; +PivotRenderer.props = ["model", "buttonTemplate?"]; +PivotRenderer.defaultProps = { + buttonTemplate: "web.PivotView.Buttons", +}; diff --git a/addons/web/static/src/views/pivot/pivot_renderer.xml b/addons/web/static/src/views/pivot/pivot_renderer.xml index 573e49bc281..d46f787369c 100644 --- a/addons/web/static/src/views/pivot/pivot_renderer.xml +++ b/addons/web/static/src/views/pivot/pivot_renderer.xml @@ -2,7 +2,7 @@ - +