-
-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] mis-builder: preserve the filters when navigating back from dri…
…ll-down Prior to this commit the state of the searchModel was lost when navigating back from a drill down. This commit uses the globalState in order to store and restore the state of the searchModlel.
- Loading branch information
Laurent Stukkens
committed
Dec 27, 2023
1 parent
9a8add9
commit ae2428d
Showing
9 changed files
with
153 additions
and
8 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
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,23 @@ | ||
/** @odoo-module **/ | ||
|
||
import {Field} from "@web/views/fields/field"; | ||
import {misReportWidgetClassName} from "@mis_builder/components/mis_report_widget.esm"; | ||
|
||
export class MisReportField extends Field { | ||
/** | ||
* @override | ||
*/ | ||
get fieldComponentProps() { | ||
const fieldComponentProps = super.fieldComponentProps; | ||
// Ensures that misReportSearchModelState is passed to the props of the | ||
// `mis_report_widget` widget that is mounted on the field. | ||
if ( | ||
this.props.fieldInfo.widget && | ||
this.props.fieldInfo.widget === misReportWidgetClassName | ||
) { | ||
fieldComponentProps.misReportSearchModelState = | ||
this.props.misReportSearchModelState; | ||
} | ||
return fieldComponentProps; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
mis_builder/static/src/views/form/mis_report_form_compiler.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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** @odoo-module **/ | ||
|
||
import {FormCompiler} from "@web/views/form/form_compiler"; | ||
import {misReportWidgetClassName} from "@mis_builder/components/mis_report_widget.esm"; | ||
|
||
export class MisReportFormCompiler extends FormCompiler { | ||
/** | ||
* @override | ||
*/ | ||
compileField(el) { | ||
// Passes misReportSearchModelState to the Field that is compiled in the | ||
// view when the field has the `mis_report_widget` widget set. | ||
const field = super.compileField(el); | ||
if ( | ||
el.hasAttribute("widget") && | ||
el.getAttribute("widget") === misReportWidgetClassName | ||
) { | ||
field.setAttribute( | ||
"misReportSearchModelState", | ||
"props.globalState && props.globalState.misReportSearchModelState" | ||
); | ||
} | ||
return field; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
mis_builder/static/src/views/form/mis_report_form_controller.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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** @odoo-module */ | ||
|
||
import {FormController} from "@web/views/form/form_controller"; | ||
|
||
export class MisReportFormController extends FormController {} | ||
|
||
// Ensures that globalState is passed to the renderer. | ||
MisReportFormController.template = "mis_builder.FormView"; |
21 changes: 21 additions & 0 deletions
21
mis_builder/static/src/views/form/mis_report_form_controller.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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<templates xml:space="preserve"> | ||
|
||
<t | ||
t-name="mis_builder.FormView" | ||
t-inherit="web.FormView" | ||
t-inherit-mode="primary" | ||
owl="1" | ||
> | ||
<xpath expr="//Layout/t[@t-component='props.Renderer']" position="attributes"> | ||
<attribute name="globalState">props.globalState</attribute> | ||
</xpath> | ||
<xpath | ||
expr="//Layout/t[@t-set-slot='layout-buttons']//t[@t-component='props.Renderer']" | ||
position="attributes" | ||
> | ||
<attribute name="globalState">props.globalState</attribute> | ||
</xpath> | ||
</t> | ||
|
||
</templates> |
19 changes: 19 additions & 0 deletions
19
mis_builder/static/src/views/form/mis_report_form_renderer.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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** @odoo-module */ | ||
|
||
import {FormRenderer} from "@web/views/form/form_renderer"; | ||
import {MisReportField} from "@mis_builder/views/field/field.esm"; | ||
|
||
export class MisReportFormRenderer extends FormRenderer {} | ||
|
||
// Gets the global state from the attributes that have been passed by the controller. | ||
MisReportFormRenderer.extractProps = ({attrs}) => { | ||
return { | ||
...FormRenderer.extractProps({attrs}), | ||
globalState: attrs.globalState || {}, | ||
}; | ||
}; | ||
|
||
MisReportFormRenderer.components = { | ||
...FormRenderer.components, | ||
Field: MisReportField, | ||
}; |
18 changes: 18 additions & 0 deletions
18
mis_builder/static/src/views/form/mis_report_form_view.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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** @odoo-module **/ | ||
|
||
import {MisReportFormCompiler} from "@mis_builder/views/form/mis_report_form_compiler.esm"; | ||
import {MisReportFormController} from "@mis_builder/views/form/mis_report_form_controller.esm"; | ||
import {MisReportFormRenderer} from "@mis_builder/views/form/mis_report_form_renderer.esm"; | ||
import {formView} from "@web/views/form/form_view"; | ||
import {registry} from "@web/core/registry"; | ||
|
||
// The view to use when mounting `mis_report_widget` widget in order to preserve the | ||
// filters when returning from the drill-down views. | ||
export const misReportFormView = { | ||
...formView, | ||
Compiler: MisReportFormCompiler, | ||
Controller: MisReportFormController, | ||
Renderer: MisReportFormRenderer, | ||
}; | ||
|
||
registry.category("views").add("mis_report_form_view", misReportFormView); |
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