Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] gauge chart: allow formulas in gauge config #5181

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

hokolomopo
Copy link
Contributor

Description:

[MOV] gauge: move gauge-specific panel tests

This commit moves the gauge-specific panel tests to a separate file
gauge_panel_component.test.ts.

A lot of gauge chart were also kinda duplicated: a test would test that
the input was marked as invalid when entering a wrong value, and another
test would test would test what the error message was when entering an
invalid value. Both can be done in the same test.

[IMP] gauge: allow to have swap rangeMin and rangeMax

Currently, we have an allowDispatch checking that rangeMin is lower
than rangeMax. This is fine for literal values, but with the next
commit that allow formulas values for rangeMin and rangeMax, it is
harder to check.

This commit make the runtime swap rangeMin and rangeMax if rangeMin
is greater than rangeMax. It's simpler, more powerful, and in line
with what we do for the gauge thresholds that are swapped if needed.

[REM] gauge: remove unused command result

There was a command result GaugeLowerBiggerThanUpper that was defined,
and checked in the gauge side panel. This command result was never
returned by the allowDispatch of the gauge charts. If the lower value
is bigger than the upper value, the gauge chart swap them.

[IMP] gauge: prettify gauge chart plugin tests

This commit prettifies and improves the readability of the
gauge_chart_plugin.test.ts file:

  • remove unused model creation data
  • remove describe with only one test
  • rename ids "1" or "2" to a more descriptive name
  • prettify the code in one line when it doesn't affect the readability

[IMP] gauge chart: allow formulas in gauge config

This commit adds the possibility to use formulas to configure the gauge
chart min/max ranges and the threshold values.

This make it so we cannot rely on allowDispatch now to check that the
values are number, because the only implemented allowDispatch of charts
is core (so no evaluation). The panel will try to filter the non-number
values, but they could change to non-number afterwards. In that case:

  • the non-number thresholds will be dropped
  • the chart will display an error if the range min/max is not a number

Task: 4236214

review checklist

  • feature is organized in plugin, or UI components
  • support of duplicate sheet (deep copy)
  • in model/core: ranges are Range object, and can be adapted (adaptRanges)
  • in model/UI: ranges are strings (to show the user)
  • undo-able commands (uses this.history.update)
  • multiuser-able commands (has inverse commands and transformations where needed)
  • new/updated/removed commands are documented
  • exportable in excel
  • translations (_t("qmsdf %s", abc))
  • unit tested
  • clean commented code
  • track breaking changes
  • doc is rebuild (npm run doc)
  • status is correct in Odoo

@robodoo
Copy link
Collaborator

robodoo commented Nov 8, 2024

Pull request status dashboard

@hokolomopo hokolomopo changed the title Master gauge chart reference treshold adrm [IMP] gauge chart: allow formulas in gauge config Nov 8, 2024
@hokolomopo hokolomopo force-pushed the master-gauge-chart-reference-treshold-adrm branch from 8578a2b to f76c9cb Compare November 8, 2024 12:57
This commit moves the gauge-specific panel tests to a separate file
`gauge_panel_component.test.ts`.

A lot of gauge chart were also kinda duplicated: a test would test that
the input was marked as invalid when entering a wrong value, and another
test would test would test what the error message was when entering an
invalid value. Both can be done in the same test.

Task: 4236214
Currently, we have an allowDispatch checking that rangeMin is lower
than rangeMax. This is fine for literal values, but with the next
commit that allow formulas values for rangeMin and rangeMax, it is
harder to check.

This commit make the runtime swap rangeMin and rangeMax if rangeMin
is greater than rangeMax. It's simpler, more powerful, and in line
with what we do for the gauge thresholds that are swapped if needed.

Task: 4236214
There was a command result `GaugeLowerBiggerThanUpper` that was defined,
and checked in the gauge side panel. This command result was never
returned by the allowDispatch of the gauge charts. If the lower value
is bigger than the upper value, the gauge chart swap them.

Task: 4236214
This commit prettifies and improves the readability of the
`gauge_chart_plugin.test.ts` file:

- remove unused model creation data
- remove describe with only one test
- rename ids "1" or "2" to a more descriptive name
- prettify the code in one line when it doesn't affect the readability

Task: 4236214
This commit adds the possibility to use formulas to configure the gauge
chart min/max ranges and the threshold values.

This make it so we cannot rely on allowDispatch now to check that the
values are number, because the only implemented allowDispatch of charts
is core (so no evaluation). The panel will try to filter the non-number
values, but they could change to non-number afterwards. In that case:

- the non-number thresholds will be dropped
- the chart will display an error if the range min/max is not a number

Task: 4236214
@hokolomopo hokolomopo force-pushed the master-gauge-chart-reference-treshold-adrm branch from f76c9cb to 128f201 Compare November 14, 2024 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants