[PR #5039] [MERGED] refactor: cell data transform logic #6598

Closed
opened 2026-03-23 23:15:39 +00:00 by mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/AppFlowy-IO/AppFlowy/pull/5039
Author: @richardshiue
Created: 4/2/2024
Status: Merged
Merged: 4/11/2024
Merged by: @LucasXu0

Base: mainHead: refactor/cell-data-transform


📝 Commits (4)

  • b6a1c9f refactor: cell data transform logic
  • 46e9b98 chore: remove redundant select option event
  • d7405fd chore: adapt tests to changes
  • 14d1de9 chore: merge remote-tracking branch 'upstream/main' into refactor/cell-data-transform

📊 Changes

37 files changed (+459 additions, -797 deletions)

View changed files

📝 frontend/appflowy_flutter/lib/plugins/database/application/cell/bloc/select_option_cell_editor_bloc.dart (+33 -32)
📝 frontend/appflowy_flutter/lib/plugins/database/domain/select_option_cell_service.dart (+0 -9)
📝 frontend/appflowy_flutter/test/bloc_test/grid_test/cell/select_option_cell_test.dart (+8 -1)
📝 frontend/rust-lib/flowy-database2/src/event_handler.rs (+0 -14)
📝 frontend/rust-lib/flowy-database2/src/event_map.rs (+2 -9)
📝 frontend/rust-lib/flowy-database2/src/services/calculations/service.rs (+34 -50)
📝 frontend/rust-lib/flowy-database2/src/services/cell/cell_operation.rs (+29 -52)
📝 frontend/rust-lib/flowy-database2/src/services/database/database_editor.rs (+9 -33)
📝 frontend/rust-lib/flowy-database2/src/services/database_view/view_group.rs (+4 -4)
📝 frontend/rust-lib/flowy-database2/src/services/database_view/view_operation.rs (+0 -1)
📝 frontend/rust-lib/flowy-database2/src/services/field/field_operation.rs (+3 -5)
📝 frontend/rust-lib/flowy-database2/src/services/field/type_options/checkbox_type_option/checkbox_tests.rs (+3 -7)
📝 frontend/rust-lib/flowy-database2/src/services/field/type_options/checkbox_type_option/checkbox_type_option.rs (+12 -35)
📝 frontend/rust-lib/flowy-database2/src/services/field/type_options/checklist_type_option/checklist.rs (+8 -20)
📝 frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_tests.rs (+2 -4)
📝 frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_type_option.rs (+3 -21)
📝 frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_tests.rs (+31 -65)
📝 frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_type_option.rs (+2 -19)
📝 frontend/rust-lib/flowy-database2/src/services/field/type_options/relation_type_option/relation.rs (+4 -38)
📝 frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/select_type_option.rs (+17 -34)

...and 17 more files

📄 Description

resolves #5003

Also resolves another bug where after changing the field type of a checkbox to single/multi-select, clicking on a is_some cell will not show the "Yes" or "No" option as selected.

This is the behavior on main:

https://github.com/AppFlowy-IO/AppFlowy/assets/71320345/1ae3604d-aae4-42bc-ae59-f78a8c9e9aea

This PR simplifies the logic of getting cell data for all kinds of purposes: filtering, sorting, convert to protobuf, handle to string, handle is empty, etc.

I achieve this by getting the TypeOption::CellData correctly, in one central location, and NOT passing the field type to all the handlers.

  • if the field type of the Cell matches the field type of the field, decode it directly and return
  • if not, see if the field type of the Cell allows for a transformation to the field type of the field. Afterwards, decode and transform the Cell into the field type of the field.
  • otherwise, return None, Err, or Default::default depending on the requirements.

After getting the cell data, continue with whatever business logic that is required.

Feature Preview


PR Checklist

  • My code adheres to AppFlowy's Conventions
  • I've listed at least one issue that this PR fixes in the description above.
  • I've added a test(s) to validate changes in this PR, or this PR only contains semantic changes.
  • All existing tests are passing.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/AppFlowy-IO/AppFlowy/pull/5039 **Author:** [@richardshiue](https://github.com/richardshiue) **Created:** 4/2/2024 **Status:** ✅ Merged **Merged:** 4/11/2024 **Merged by:** [@LucasXu0](https://github.com/LucasXu0) **Base:** `main` ← **Head:** `refactor/cell-data-transform` --- ### 📝 Commits (4) - [`b6a1c9f`](https://github.com/AppFlowy-IO/AppFlowy/commit/b6a1c9fb5142ffb12af04bd85110fd8e0461e473) refactor: cell data transform logic - [`46e9b98`](https://github.com/AppFlowy-IO/AppFlowy/commit/46e9b981db8d6407b8d90c454f2c26629a5aca62) chore: remove redundant select option event - [`d7405fd`](https://github.com/AppFlowy-IO/AppFlowy/commit/d7405fd12e726ce4942c3f7897550f52e933720a) chore: adapt tests to changes - [`14d1de9`](https://github.com/AppFlowy-IO/AppFlowy/commit/14d1de9f163ebeab072066fa04c94858942b7217) chore: merge remote-tracking branch 'upstream/main' into refactor/cell-data-transform ### 📊 Changes **37 files changed** (+459 additions, -797 deletions) <details> <summary>View changed files</summary> 📝 `frontend/appflowy_flutter/lib/plugins/database/application/cell/bloc/select_option_cell_editor_bloc.dart` (+33 -32) 📝 `frontend/appflowy_flutter/lib/plugins/database/domain/select_option_cell_service.dart` (+0 -9) 📝 `frontend/appflowy_flutter/test/bloc_test/grid_test/cell/select_option_cell_test.dart` (+8 -1) 📝 `frontend/rust-lib/flowy-database2/src/event_handler.rs` (+0 -14) 📝 `frontend/rust-lib/flowy-database2/src/event_map.rs` (+2 -9) 📝 `frontend/rust-lib/flowy-database2/src/services/calculations/service.rs` (+34 -50) 📝 `frontend/rust-lib/flowy-database2/src/services/cell/cell_operation.rs` (+29 -52) 📝 `frontend/rust-lib/flowy-database2/src/services/database/database_editor.rs` (+9 -33) 📝 `frontend/rust-lib/flowy-database2/src/services/database_view/view_group.rs` (+4 -4) 📝 `frontend/rust-lib/flowy-database2/src/services/database_view/view_operation.rs` (+0 -1) 📝 `frontend/rust-lib/flowy-database2/src/services/field/field_operation.rs` (+3 -5) 📝 `frontend/rust-lib/flowy-database2/src/services/field/type_options/checkbox_type_option/checkbox_tests.rs` (+3 -7) 📝 `frontend/rust-lib/flowy-database2/src/services/field/type_options/checkbox_type_option/checkbox_type_option.rs` (+12 -35) 📝 `frontend/rust-lib/flowy-database2/src/services/field/type_options/checklist_type_option/checklist.rs` (+8 -20) 📝 `frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_tests.rs` (+2 -4) 📝 `frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_type_option.rs` (+3 -21) 📝 `frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_tests.rs` (+31 -65) 📝 `frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_type_option.rs` (+2 -19) 📝 `frontend/rust-lib/flowy-database2/src/services/field/type_options/relation_type_option/relation.rs` (+4 -38) 📝 `frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/select_type_option.rs` (+17 -34) _...and 17 more files_ </details> ### 📄 Description resolves #5003 Also resolves another bug where after changing the field type of a checkbox to single/multi-select, clicking on a is_some cell will not show the "Yes" or "No" option as selected. This is the behavior on `main`: https://github.com/AppFlowy-IO/AppFlowy/assets/71320345/1ae3604d-aae4-42bc-ae59-f78a8c9e9aea This PR simplifies the logic of getting cell data for all kinds of purposes: filtering, sorting, convert to protobuf, handle to string, handle is empty, etc. I achieve this by getting the `TypeOption::CellData` correctly, in one central location, and NOT passing the field type to all the handlers. - if the field type of the `Cell` matches the field type of the field, decode it directly and return - if not, see if the field type of the `Cell` allows for a transformation to the field type of the field. Afterwards, decode and transform the `Cell` into the field type of the field. - otherwise, return `None`, `Err`, or `Default::default` depending on the requirements. After getting the cell data, continue with whatever business logic that is required. ### Feature Preview <!--- List at least one issue here that this PR addresses. If it fixes the issue, please use the [fixes](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests) keyword to close the issue. For example: fixes https://github.com/AppFlowy-IO/AppFlowy/pull/2106 --> --- <!--- Before you mark this PR ready for review, run through this checklist! --> #### PR Checklist - [ ] My code adheres to [AppFlowy's Conventions](https://docs.appflowy.io/docs/documentation/software-contributions/conventions) - [ ] I've listed at least one issue that this PR fixes in the description above. - [ ] I've added a test(s) to validate changes in this PR, or this PR only contains semantic changes. - [ ] All existing tests are passing. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
mirror 2026-03-23 23:15:39 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
AppFlowy-IO/AppFlowy#6598
No description provided.