[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) <xbo@odoo.com>
This commit is contained in:
Kartik Chavda (kcv)
2024-02-27 17:40:54 +00:00
committed by Xavier Bol (xbo)
parent aa87b65dc8
commit a9ebd07b80
4 changed files with 7 additions and 3 deletions
@@ -44,4 +44,5 @@ PivotController.props = {
Model: Function,
modelParams: Object,
Renderer: Function,
buttonTemplate: { type: String, optional: true },
};
@@ -42,7 +42,7 @@
</t>
<t t-else="" t-call="web.NoContentHelper"/>
</t>
<t t-component="props.Renderer" model="model"/>
<t t-component="props.Renderer" model="model" buttonTemplate="props.buttonTemplate"/>
</Layout>
</div>
</t>
@@ -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",
};
@@ -2,7 +2,7 @@
<templates xml:space="preserve">
<t t-name="web.PivotRenderer">
<t t-call="web.PivotView.Buttons"/>
<t t-call="{{ props.buttonTemplate }}"/>
<div t-if="model.hasData() and model.metaData.activeMeasures.length" class="o_pivot table-responsive mx-3">
<table
class="table-hover table table-sm table-bordered table-borderless"