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] tables: introduce dynamic tables #3624

Closed
wants to merge 2 commits into from

Conversation

hokolomopo
Copy link
Contributor

[IMP] tables: introduce dynamic tables

This commit introduces the concept of dynamic table. A dynamic table
is a table that is bound to a array formula, instead of a static range.
The table will grow and shrink along the results of the array formula.

The notion is transparent to the user: if the users defines a table on
a single cell that contains an array formula, or all the cells of the
array formula, the table will be dynamic.

This means that the table zones are now an UI concept. The core plugin
now manages InternalTable objects, that can be either static or
dynamic (in which case they don't have a zone, but a single cell position).
The UI plugin DynamicTablesPlugin transform those InternalTable into
Table objects that every other plugin and component can easily use.

As the core plugin doesn't have access to the evaluation results, and
can't know if a cell contains an array formula, it's the responsability
of the components that create a table to determine if it's dynamic or not.

[IMP] array formula: getSpreadPositionsOf now returns root position

Before this the getter getSpreadPositionsOf only returned the
position of the cells an array formula was spread to, minus the
cell the array formula was in. This made it impossible to differentiate
between a cell with a normal formula, and a cell with an array formula
returning a 1x1 matrix.

Now the getter returns the root position of the array formula as well.

There was also a bug where the spread relation weren't properly cleaned.

Task: 3707037

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

@hokolomopo hokolomopo changed the title Master dynamic table style adrm ## [IMP] tables: introduce dynamic tables Feb 6, 2024
@hokolomopo hokolomopo changed the base branch from master to master-table-style-adrm February 6, 2024 13:51
@robodoo
Copy link
Collaborator

robodoo commented Feb 6, 2024

@hokolomopo hokolomopo changed the title ## [IMP] tables: introduce dynamic tables [IMP] tables: introduce dynamic tables Feb 6, 2024
@hokolomopo hokolomopo force-pushed the master-table-style-adrm branch 5 times, most recently from 7ac2d90 to 891baa3 Compare February 21, 2024 10:09
@hokolomopo hokolomopo force-pushed the master-table-style-adrm branch 3 times, most recently from ebeac35 to 6f04814 Compare February 27, 2024 13:09
@hokolomopo hokolomopo changed the base branch from master-table-style-adrm to master February 28, 2024 07:42
@robodoo
Copy link
Collaborator

robodoo commented Feb 28, 2024

@hokolomopo hokolomopo force-pushed the master-dynamic-table-style-adrm branch 2 times, most recently from e97c439 to 7d12eeb Compare February 28, 2024 11:37
Copy link
Contributor

@anhe-odoo anhe-odoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments :)

src/actions/menu_items_actions.ts Outdated Show resolved Hide resolved
src/clipboard_handlers/tables_clipboard.ts Outdated Show resolved Hide resolved
src/clipboard_handlers/tables_clipboard.ts Outdated Show resolved Hide resolved
src/helpers/ui/table_interactive.ts Show resolved Hide resolved
src/plugins/core/tables.ts Outdated Show resolved Hide resolved
src/plugins/core/tables.ts Outdated Show resolved Hide resolved
src/plugins/core/tables.ts Show resolved Hide resolved
src/plugins/ui_core_views/cell_evaluation/evaluator.ts Outdated Show resolved Hide resolved
src/plugins/ui_core_views/dynamic_tables.ts Outdated Show resolved Hide resolved
src/plugins/ui_core_views/dynamic_tables.ts Outdated Show resolved Hide resolved
@hokolomopo hokolomopo force-pushed the master-dynamic-table-style-adrm branch 2 times, most recently from f6b299d to 4e3b7a4 Compare March 4, 2024 13:50
@rrahir
Copy link
Collaborator

rrahir commented Mar 5, 2024

THe first commit definitely deserves to be backported

for (const table of this.getTables(cmd.sheetId)) {
if (cmd.target.every((zone) => !intersection(zone, table.range.zone))) {
const tables: Record<UID, InternalTable> = {};
for (const table of this.getInternalTables(cmd.sheetId)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was already present before but this command can technically delete several tables at a time. should the command have been targeting the exact table zone definition all along?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably could have been a good way to do it, but at the time it would have required a bit more logic in the menu items for no real reason.

Now I'm stuck with it, I don't see how I would migrate the revisions correctly in python.

@hokolomopo hokolomopo force-pushed the master-dynamic-table-style-adrm branch 2 times, most recently from bb40f87 to 9030d22 Compare March 12, 2024 14:47
Copy link
Collaborator

@LucasLefevre LucasLefevre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few comments/suggestions :)

src/components/translations_terms.ts Outdated Show resolved Hide resolved
src/types/table.ts Outdated Show resolved Hide resolved
src/types/table.ts Outdated Show resolved Hide resolved
src/helpers/zones.ts Outdated Show resolved Hide resolved
src/helpers/zones.ts Outdated Show resolved Hide resolved
src/plugins/core/tables.ts Outdated Show resolved Hide resolved
src/plugins/core/tables.ts Outdated Show resolved Hide resolved
@hokolomopo hokolomopo force-pushed the master-dynamic-table-style-adrm branch 2 times, most recently from 6f94bb1 to 68f43b1 Compare March 18, 2024 09:29
@hokolomopo hokolomopo force-pushed the master-dynamic-table-style-adrm branch 2 times, most recently from 7952c80 to 52e8b03 Compare March 18, 2024 09:53
Copy link
Collaborator

@LucasLefevre LucasLefevre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few more comments. I think we're good after :)

src/plugins/ui_core_views/cell_evaluation/evaluator.ts Outdated Show resolved Hide resolved
src/components/side_panel/table_panel/table_panel.xml Outdated Show resolved Hide resolved
src/plugins/ui_core_views/dynamic_tables.ts Outdated Show resolved Hide resolved
src/plugins/ui_core_views/dynamic_tables.ts Outdated Show resolved Hide resolved
src/plugins/ui_core_views/dynamic_tables.ts Outdated Show resolved Hide resolved
tests/table/dynamic_table_plugin.test.ts Show resolved Hide resolved
@hokolomopo hokolomopo force-pushed the master-dynamic-table-style-adrm branch from 52e8b03 to ba972c9 Compare March 25, 2024 07:57
Before this the getter `getSpreadPositionsOf` only returned the
position of the cells an array formula was spread to, minus the
cell the array formula was in. This made it impossible to differentiate
between a cell with a normal formula, and a cell with an array formula
returning a 1x1 matrix.

Now the getter returns the root position of the array formula as well.

The getter `getArrayFormulaSpreadingOn` was also modified to work when
calling it on the root position of an array formula.

There was also a bug where the spread relation weren't properly cleaned.

Task: 3707037
@hokolomopo hokolomopo force-pushed the master-dynamic-table-style-adrm branch from ba972c9 to 1e9a5d1 Compare March 25, 2024 08:02
This commit introduces the concept of dynamic table. A dynamic table
is a table that is bound to a array formula, instead of a static range.
The table will grow and shrink along the results of the array formula.

This means that the table zones are now an UI concept. The core plugin
now manages `CoreTable` objects, that can be either static or
dynamic (in which case they don't have a zone, but a single cell position).
The UI plugin `DynamicTablesPlugin` transform those `CoreTable` into
`Table` objects that every other plugin and component can easily use.

As the core plugin doesn't have access to the evaluation results, and
can't know if a cell contains an array formula, it's the responsibility
of the components that create a table to determine if it's dynamic or not.

It is now not possible to keep the same filtered values in a copied
table, since an UPDATE_CELL will invalidate the tables of the
`DynamicTablesPlugin` until the next finalize, and thus `UPDATE_FILTER`
won't work in the clipboard.

Task: 3707037
@hokolomopo hokolomopo force-pushed the master-dynamic-table-style-adrm branch from 1e9a5d1 to 891e892 Compare March 25, 2024 08:53
Copy link
Collaborator

@LucasLefevre LucasLefevre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

robodoo r+ rebase-ff
:)

@robodoo
Copy link
Collaborator

robodoo commented Mar 25, 2024

Merge method set to rebase and fast-forward.

@VincentSchippefilt
Copy link
Collaborator

robodoo r+ rebase-ff

@robodoo
Copy link
Collaborator

robodoo commented Mar 25, 2024

Merge method set to rebase and fast-forward.

@robodoo
Copy link
Collaborator

robodoo commented Mar 25, 2024

I'm sorry, @VincentSchippefilt: this PR is already reviewed, reviewing it again is useless.

robodoo pushed a commit that referenced this pull request Mar 25, 2024
Before this the getter `getSpreadPositionsOf` only returned the
position of the cells an array formula was spread to, minus the
cell the array formula was in. This made it impossible to differentiate
between a cell with a normal formula, and a cell with an array formula
returning a 1x1 matrix.

Now the getter returns the root position of the array formula as well.

The getter `getArrayFormulaSpreadingOn` was also modified to work when
calling it on the root position of an array formula.

There was also a bug where the spread relation weren't properly cleaned.

Task: 3707037
Part-of: #3624
robodoo pushed a commit that referenced this pull request Mar 25, 2024
This commit introduces the concept of dynamic table. A dynamic table
is a table that is bound to a array formula, instead of a static range.
The table will grow and shrink along the results of the array formula.

This means that the table zones are now an UI concept. The core plugin
now manages `CoreTable` objects, that can be either static or
dynamic (in which case they don't have a zone, but a single cell position).
The UI plugin `DynamicTablesPlugin` transform those `CoreTable` into
`Table` objects that every other plugin and component can easily use.

As the core plugin doesn't have access to the evaluation results, and
can't know if a cell contains an array formula, it's the responsibility
of the components that create a table to determine if it's dynamic or not.

It is now not possible to keep the same filtered values in a copied
table, since an UPDATE_CELL will invalidate the tables of the
`DynamicTablesPlugin` until the next finalize, and thus `UPDATE_FILTER`
won't work in the clipboard.

closes #3624

Task: 3707037
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
@robodoo robodoo closed this Mar 25, 2024
@robodoo robodoo added the 17.3 label Mar 25, 2024
@fw-bot fw-bot deleted the master-dynamic-table-style-adrm branch April 8, 2024 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants