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] dashboard: automatically reorganize a sheet #4182

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

Conversation

hokolomopo
Copy link
Contributor

[IMP] dashboard: automatically reorganize a sheet

This commit aims to simplify the process of creation of a dashboard
with two new features:

  1. A context menu item to send figures and ranges to another sheet
  2. A context menu to reorganize a sheet in a "dashboard-y" way.

Both features are implemented in the ReorganizeSheetPlugin. Sending
a figure/range to a sheet works by finding the bottom-most used cell
in the sheet and placing the figure/range below it. "Used" cells are
cells that contains some content/a merge/a table/overlap a figure.

Reorganizing a sheet works by:

  • put the scorecards at the top of the sheet
  • put the figures below the scorecards
  • put the cell "clusters" (zones of contiguous cells) below them

Technically the reorganization is done by creating new rows at the
bottom of the sheet, cut/paste the clusters correctly ordered in
these rows, and then delete the original rows. See Odoo task's pad
for why we do it this way.

[IMP] mergeContiguousZones: add test & fix diagonal

This commit moves the tests of mergeContiguousZones from Odoo
to o-spreadsheet.

It also fixes a bug where the algorithm was merging zones that were
diagonal to each other.

[REF] clipboard: decouple clipboards and active sheet

This commit make the clipboards handlers independent from the active
sheet, thus allowing to use them to copy/paste things in any sheet.

[IMP] clipboard: insert new rows when pasting charts

Currently, when pasting a chart at the edges of a sheet, the pasted
chart is shifted so that it doesn't go out of the sheet.

This commit changes the behaviour so that now the chart is always
pasted with its top-left corner at the top-left corner of the selection,
and insert new rows/columns if needed so that the chart fits in the
sheet.

Also take the occasion to factorize the code in common between the
chart clipboard and the image clipboard into the figure clipboard.

[IMP] clipboard: instanciate clipboards only once

This commit make the different clipboards instance attributes of the
Clipboard plugin, instead of being created each time a paste or copy
action is done.

This:

  • is a bit faster and less wasteful
  • allows the clipboard instances to be exposed to other plugins
  • will be necessary for a future refactoring of the clipboard plugin
    where each clipboard will have its own copied data, instead of
    having a big copied data object shared between all clipboards.

[REF] clipboard: expose paste logic

This commit extract the logic of the paste operation of the
clipboard plugin into a new getter (getPasteTarget) and a new command
(EXPAND_SHEET_FOR_ZONE) so that it can be reused in other parts of the
code.

[FIX] evaluation: getEvaluatedCells with spreading cells

The getter getEvaluatedCells does't return spreaded cells. It
also returns empty evaluated cells that have some style.

This is not the expected behaviour. getEvaluatedCells should return
all the non-empty evaluated cells of a sheet.

Task: : 3869372

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

The getter `getEvaluatedCells` does't return spreaded cells. It
also returns empty evaluated cells that have some style.

This is not the expected behaviour. `getEvaluatedCells` should return
all the non-empty evaluated cells of a sheet.

Task: 3869372
This commit extract the logic of the paste operation of the
clipboard plugin into a new getter (`getPasteTarget`) and a new command
(`EXPAND_SHEET_FOR_ZONE`) so that it can be reused in other parts of the
code.

Task: 3869372
This commit make the different clipboards instance attributes of the
Clipboard plugin, instead of being created each time a paste or copy
action is done.

This:
- is a bit faster and less wasteful
- allows the clipboard instances to be exposed to other plugins
- will be necessary for a future refactoring of the clipboard plugin
where each clipboard will have its own copied data, instead of
having a big copied data object shared between all clipboards.

Task: 3869372
Currently, when pasting a chart at the edges of a sheet, the pasted
chart is shifted so that it doesn't go out of the sheet.

This commit changes the behaviour so that now the chart is always
pasted with its top-left corner at the top-left corner of the selection,
and insert new rows/columns if needed so that the chart fits in the
sheet.

Also take the occasion to factorize the code in common between the
chart clipboard and the image clipboard into the figure clipboard.

Task: 3869372
This commit make the clipboards handlers independent from the active
sheet, thus allowing to use them to copy/paste things in any sheet.

Task: 3869372
This commit moves the tests of mergeContiguousZones from Odoo
to o-spreadsheet.

It also fixes a bug where the algorithm was merging zones that were
diagonal to each other.

Task: 3869372
This commit aims to simplify the process of creation of a dashboard
with two new features:

1) A context menu item to send figures and ranges to another sheet
2) A context menu to reorganize a sheet in a "dashboard-y" way.

Both features are implemented in the `ReorganizeSheetPlugin`. Sending
a figure/range to a sheet works by finding the bottom-most used cell
in the sheet and placing the figure/range below it. "Used" cells are
cells that contains some content/a merge/a table/overlap a figure.

Reorganizing a sheet works by:
- put the scorecards at the top of the sheet
- put the figures below the scorecards
- put the cell "clusters" (zones of contiguous cells) below them

Technically the reorganization is done by creating new rows at the
bottom of the sheet, cut/paste the clusters correctly ordered in
these rows, and then delete the original rows. See Odoo task's pad
for why we do it this way.

Task: 3869372
@robodoo
Copy link
Collaborator

robodoo commented May 7, 2024

src/actions/data_actions.ts Show resolved Hide resolved
src/actions/menu_items_actions.ts Show resolved Hide resolved
src/plugins/ui_feature/reorganize_sheet.ts Show resolved Hide resolved
sequence: 15,
id: "send_to_sheet",
name: _t("Send to sheet"),
icon: "o-spreadsheet-Icon.CUT", // ADRM TODO: icon
Copy link
Collaborator

Choose a reason for hiding this comment

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

I kinda like the cut icon for this

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.

None yet

3 participants