Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
chore: add documentation
appflowyd2933bdb04f8
diff --git a/frontend/rust-lib/flowy-grid/src/services/grid_editor.rs b/frontend/rust-lib/flowy-grid/src/services/grid_editor.rsindex bc689fda52..1cd31bb697 100644--- a/frontend/rust-lib/flowy-grid/src/services/grid_editor.rs+++ b/frontend/rust-lib/flowy-grid/src/services/grid_editor.rs@@ -410,7 +410,7 @@ impl GridRevisionEditor {pub async fn update_row(&self, changeset: RowChangeset) -> FlowyResult<()> {let row_id = changeset.row_id.clone();let _ = self.block_manager.update_row(changeset).await?;- self.view_manager.did_update_row(&row_id).await;+ self.view_manager.did_update_cell(&row_id).await;Ok(())}@@ -504,7 +504,7 @@ impl GridRevisionEditor {content,};let _ = self.block_manager.update_cell(cell_changeset).await?;- self.view_manager.did_update_cell(&row_id, &field_id).await;+ self.view_manager.did_update_cell(&row_id).await;Ok(())}}diff --git a/frontend/rust-lib/flowy-grid/src/services/grid_view_editor.rs b/frontend/rust-lib/flowy-grid/src/services/grid_view_editor.rsindex 4b52f928d9..8b19904879 100644--- a/frontend/rust-lib/flowy-grid/src/services/grid_view_editor.rs+++ b/frontend/rust-lib/flowy-grid/src/services/grid_view_editor.rs@@ -131,7 +131,7 @@ impl GridViewRevisionEditor {}}- pub(crate) async fn did_update_view_row(&self, row_rev: &RowRevision) {+ pub(crate) async fn did_update_view_cell(&self, row_rev: &RowRevision) {let changesets = self.mut_group_controller(|group_controller, field_rev| {group_controller.did_update_group_row(row_rev, &field_rev)diff --git a/frontend/rust-lib/flowy-grid/src/services/grid_view_manager.rs b/frontend/rust-lib/flowy-grid/src/services/grid_view_manager.rsindex 0aa503ce83..b74419dab0 100644--- a/frontend/rust-lib/flowy-grid/src/services/grid_view_manager.rs+++ b/frontend/rust-lib/flowy-grid/src/services/grid_view_manager.rs@@ -77,15 +77,15 @@ impl GridViewManager {}}- /// Insert/Delete the group's row if the corresponding data was changed.- pub(crate) async fn did_update_row(&self, row_id: &str) {+ /// Insert/Delete the group's row if the corresponding cell data was changed.+ pub(crate) async fn did_update_cell(&self, row_id: &str) {match self.row_delegate.gv_get_row_rev(row_id).await {None => {tracing::warn!("Can not find the row in grid view");}Some(row_rev) => {for view_editor in self.view_editors.iter() {- view_editor.did_update_view_row(&row_rev).await;+ view_editor.did_update_view_cell(&row_rev).await;}}}@@ -97,10 +97,6 @@ impl GridViewManager {Ok(())}- pub(crate) async fn did_update_cell(&self, row_id: &str, _field_id: &str) {- self.did_update_row(row_id).await- }-pub(crate) async fn did_delete_row(&self, row_rev: Arc<RowRevision>) {for view_editor in self.view_editors.iter() {view_editor.did_delete_view_row(&row_rev).await;diff --git a/frontend/rust-lib/flowy-grid/src/services/group/action.rs b/frontend/rust-lib/flowy-grid/src/services/group/action.rsindex fd9adcb8b5..271b2f4603 100644--- a/frontend/rust-lib/flowy-grid/src/services/group/action.rs+++ b/frontend/rust-lib/flowy-grid/src/services/group/action.rs@@ -1,19 +1,80 @@-use crate::entities::GroupChangesetPB;-+use crate::entities::{GroupChangesetPB, GroupViewChangesetPB};use crate::services::group::controller::MoveGroupRowContext;-use flowy_grid_data_model::revision::{CellRevision, RowRevision};+use crate::services::group::Group;+use flowy_error::FlowyResult;+use flowy_grid_data_model::revision::{CellRevision, FieldRevision, RowRevision};+use std::sync::Arc;-pub trait GroupAction: Send + Sync {+/// Using polymorphism to provides the customs action for different group controller.+///+/// For example, the `CheckboxGroupController` implements this trait to provide custom behavior.+///+pub trait GroupControllerCustomActions: Send + Sync {type CellDataType;+ /// Returns the a value of the cell, default value is None+ ///+ /// Determine which group the row is placed in based on the data of the cell. If the cell data+ /// is None. The row will be put in to the `No status` group+ ///fn default_cell_rev(&self) -> Option<CellRevision> {None}- fn use_default_group(&self) -> bool {++ /// Returns a bool value to determine the `No status` group should show or hide.+ ///+ fn use_no_status_group(&self) -> bool {true}++ /// Returns a bool value to determine whether the group should contain this cell or not.fn can_group(&self, content: &str, cell_data: &Self::CellDataType) -> bool;++ /// Adding a new row to the group if the cell data match the group filter.+ /// It gets called after editing the cell or row+ ///fn add_row_if_match(&mut self, row_rev: &RowRevision, cell_data: &Self::CellDataType) -> Vec<GroupChangesetPB>;++ ///fn remove_row_if_match(&mut self, row_rev: &RowRevision, cell_data: &Self::CellDataType) -> Vec<GroupChangesetPB>;- // Move row from one group to another++ /// Move row from one group to anotherfn move_row(&mut self, cell_data: &Self::CellDataType, context: MoveGroupRowContext) -> Vec<GroupChangesetPB>;}++/// Defines the shared actions any group controller can perform.+pub trait GroupControllerSharedActions: Send + Sync {+ /// The field that is used for grouping the rows+ fn field_id(&self) -> &str;++ /// Returns number of groups the current field has+ fn groups(&self) -> Vec<Group>;++ /// Returns the index and the group data with group_id+ fn get_group(&self, group_id: &str) -> Option<(usize, Group)>;++ /// Separates the rows into different groups+ fn fill_groups(&mut self, row_revs: &[Arc<RowRevision>], field_rev: &FieldRevision) -> FlowyResult<()>;++ /// Remove the group with from_group_id and insert it to the index with to_group_id+ fn move_group(&mut self, from_group_id: &str, to_group_id: &str) -> FlowyResult<()>;++ /// Insert/Remove the row to the group if the corresponding cell data is changed+ fn did_update_group_row(+ &mut self,+ row_rev: &RowRevision,+ field_rev: &FieldRevision,+ ) -> FlowyResult<Vec<GroupChangesetPB>>;++ /// Remove the row from the group if the row gets deleted+ fn did_delete_delete_row(+ &mut self,+ row_rev: &RowRevision,+ field_rev: &FieldRevision,+ ) -> FlowyResult<Vec<GroupChangesetPB>>;++ /// Move the row from one group to another group+ fn move_group_row(&mut self, context: MoveGroupRowContext) -> FlowyResult<Vec<GroupChangesetPB>>;++ /// Update the group if the corresponding field is changed+ fn did_update_group_field(&mut self, field_rev: &FieldRevision) -> FlowyResult<Option<GroupViewChangesetPB>>;+}diff --git a/frontend/rust-lib/flowy-grid/src/services/group/controller.rs b/frontend/rust-lib/flowy-grid/src/services/group/controller.rsindex 7826ce50c6..cb442070cb 100644--- a/frontend/rust-lib/flowy-grid/src/services/group/controller.rs+++ b/frontend/rust-lib/flowy-grid/src/services/group/controller.rs@@ -1,6 +1,6 @@use crate::entities::{GroupChangesetPB, GroupViewChangesetPB, InsertedRowPB, RowPB};use crate::services::cell::{decode_any_cell_data, CellBytesParser};-use crate::services::group::action::GroupAction;+use crate::services::group::action::{GroupControllerCustomActions, GroupControllerSharedActions};use crate::services::group::configuration::GroupContext;use crate::services::group::entities::Group;use flowy_error::FlowyResult;@@ -18,7 +18,7 @@ use std::sync::Arc;/// If the [FieldType] doesn't implement its group controller, then the [DefaultGroupController] will/// be used.///-pub trait GroupController: GroupControllerActions + Send + Sync {+pub trait GroupController: GroupControllerSharedActions + Send + Sync {fn will_create_row(&mut self, row_rev: &mut RowRevision, field_rev: &FieldRevision, group_id: &str);fn did_create_row(&mut self, row_pb: &RowPB, group_id: &str);}@@ -47,45 +47,6 @@ pub struct MoveGroupRowContext<'a> {pub to_group_id: &'a str,pub to_row_id: Option<String>,}--/// Defines the shared actions each group controller can perform.-pub trait GroupControllerActions: Send + Sync {- /// The field that is used for grouping the rows- fn field_id(&self) -> &str;-- /// Returns number of groups the current field has- fn groups(&self) -> Vec<Group>;-- /// Returns the index and the group data with group_id- fn get_group(&self, group_id: &str) -> Option<(usize, Group)>;-- /// Separates the rows into different groups- fn fill_groups(&mut self, row_revs: &[Arc<RowRevision>], field_rev: &FieldRevision) -> FlowyResult<()>;-- /// Remove the group with from_group_id and insert it to the index with to_group_id- fn move_group(&mut self, from_group_id: &str, to_group_id: &str) -> FlowyResult<()>;-- /// Insert the row to the group if the corresponding cell data is changed- fn did_update_group_row(- &mut self,- row_rev: &RowRevision,- field_rev: &FieldRevision,- ) -> FlowyResult<Vec<GroupChangesetPB>>;-- /// Remove the row from the group if the corresponding cell data is changed- fn did_delete_delete_row(- &mut self,- row_rev: &RowRevision,- field_rev: &FieldRevision,- ) -> FlowyResult<Vec<GroupChangesetPB>>;-- /// Move the row from one group to another group- fn move_group_row(&mut self, context: MoveGroupRowContext) -> FlowyResult<Vec<GroupChangesetPB>>;-- /// Update the group if the corresponding field is changed- fn did_update_group_field(&mut self, field_rev: &FieldRevision) -> FlowyResult<Option<GroupViewChangesetPB>>;-}-/// C: represents the group configuration that impl [GroupConfigurationSerde]/// T: the type-option data deserializer that impl [TypeOptionDataDeserializer]/// G: the group generator, [GroupGenerator]@@ -186,21 +147,21 @@ where}}-impl<C, T, G, P> GroupControllerActions for GenericGroupController<C, T, G, P>+impl<C, T, G, P> GroupControllerSharedActions for GenericGroupController<C, T, G, P>whereP: CellBytesParser,C: GroupConfigurationContentSerde,T: TypeOptionDataDeserializer,G: GroupGenerator<Context = GroupContext<C>, TypeOptionType = T>,- Self: GroupAction<CellDataType = P::Object>,+ Self: GroupControllerCustomActions<CellDataType = P::Object>,{fn field_id(&self) -> &str {&self.field_id}fn groups(&self) -> Vec<Group> {- if self.use_default_group() {+ if self.use_no_status_group() {self.group_ctx.groups().into_iter().cloned().collect()} else {self.group_ctx@@ -270,16 +231,12 @@ wherelet cell_bytes = decode_any_cell_data(cell_rev.data.clone(), field_rev).1;let cell_data = cell_bytes.parser::<P>()?;let mut changesets = self.add_row_if_match(row_rev, &cell_data);-- if self.use_default_group() {- if let Some(default_group_changeset) = self.update_default_group(row_rev, &changesets) {- tracing::trace!("default_group_changeset: {}", default_group_changeset);- if !default_group_changeset.is_empty() {- changesets.push(default_group_changeset);- }- }- }-+ // if let Some(default_group_changeset) = self.update_default_group(row_rev, &changesets) {+ // tracing::trace!("default_group_changeset: {}", default_group_changeset);+ // if !default_group_changeset.is_empty() {+ // changesets.push(default_group_changeset);+ // }+ // }Ok(changesets)} else {Ok(vec![])diff --git a/frontend/rust-lib/flowy-grid/src/services/group/controller_impls/checkbox_controller.rs b/frontend/rust-lib/flowy-grid/src/services/group/controller_impls/checkbox_controller.rsindex 7d41ccefc0..f64f96a194 100644--- a/frontend/rust-lib/flowy-grid/src/services/group/controller_impls/checkbox_controller.rs+++ b/frontend/rust-lib/flowy-grid/src/services/group/controller_impls/checkbox_controller.rs@@ -1,6 +1,6 @@use crate::entities::{GroupChangesetPB, InsertedRowPB, RowPB};use crate::services::field::{CheckboxCellData, CheckboxCellDataParser, CheckboxTypeOptionPB, CHECK, UNCHECK};-use crate::services::group::action::GroupAction;+use crate::services::group::action::GroupControllerCustomActions;use crate::services::group::configuration::GroupContext;use crate::services::group::controller::{GenericGroupController, GroupController, GroupGenerator, MoveGroupRowContext,@@ -21,13 +21,13 @@ pub type CheckboxGroupController = GenericGroupController<pub type CheckboxGroupContext = GroupContext<CheckboxGroupConfigurationRevision>;-impl GroupAction for CheckboxGroupController {+impl GroupControllerCustomActions for CheckboxGroupController {type CellDataType = CheckboxCellData;fn default_cell_rev(&self) -> Option<CellRevision> {Some(CellRevision::new(UNCHECK.to_string()))}- fn use_default_group(&self) -> bool {+ fn use_no_status_group(&self) -> bool {false}diff --git a/frontend/rust-lib/flowy-grid/src/services/group/controller_impls/default_controller.rs b/frontend/rust-lib/flowy-grid/src/services/group/controller_impls/default_controller.rsindex 02bd1a6fb8..122a2848b7 100644--- a/frontend/rust-lib/flowy-grid/src/services/group/controller_impls/default_controller.rs+++ b/frontend/rust-lib/flowy-grid/src/services/group/controller_impls/default_controller.rs@@ -1,5 +1,5 @@use crate::entities::{GroupChangesetPB, GroupViewChangesetPB, RowPB};-use crate::services::group::{Group, GroupController, GroupControllerActions, MoveGroupRowContext};+use crate::services::group::{Group, GroupController, GroupControllerSharedActions, MoveGroupRowContext};use flowy_error::FlowyResult;use flowy_grid_data_model::revision::{FieldRevision, RowRevision};use std::sync::Arc;@@ -30,7 +30,7 @@ impl DefaultGroupController {}}-impl GroupControllerActions for DefaultGroupController {+impl GroupControllerSharedActions for DefaultGroupController {fn field_id(&self) -> &str {&self.field_id}diff --git a/frontend/rust-lib/flowy-grid/src/services/group/controller_impls/select_option_controller/multi_select_controller.rs b/frontend/rust-lib/flowy-grid/src/services/group/controller_impls/select_option_controller/multi_select_controller.rsindex 502c0be350..5529f0a13f 100644--- a/frontend/rust-lib/flowy-grid/src/services/group/controller_impls/select_option_controller/multi_select_controller.rs+++ b/frontend/rust-lib/flowy-grid/src/services/group/controller_impls/select_option_controller/multi_select_controller.rs@@ -1,7 +1,7 @@use crate::entities::{GroupChangesetPB, RowPB};use crate::services::cell::insert_select_option_cell;use crate::services::field::{MultiSelectTypeOptionPB, SelectOptionCellDataPB, SelectOptionCellDataParser};-use crate::services::group::action::GroupAction;+use crate::services::group::action::GroupControllerCustomActions;use crate::services::group::controller::{GenericGroupController, GroupController, GroupGenerator, MoveGroupRowContext,@@ -19,7 +19,7 @@ pub type MultiSelectGroupController = GenericGroupController<SelectOptionCellDataParser,>;-impl GroupAction for MultiSelectGroupController {+impl GroupControllerCustomActions for MultiSelectGroupController {type CellDataType = SelectOptionCellDataPB;fn can_group(&self, content: &str, cell_data: &SelectOptionCellDataPB) -> bool {diff --git a/frontend/rust-lib/flowy-grid/src/services/group/controller_impls/select_option_controller/single_select_controller.rs b/frontend/rust-lib/flowy-grid/src/services/group/controller_impls/select_option_controller/single_select_controller.rsindex b7c7f5fd3a..0d53e0dee6 100644--- a/frontend/rust-lib/flowy-grid/src/services/group/controller_impls/select_option_controller/single_select_controller.rs+++ b/frontend/rust-lib/flowy-grid/src/services/group/controller_impls/select_option_controller/single_select_controller.rs@@ -1,7 +1,7 @@use crate::entities::{GroupChangesetPB, RowPB};use crate::services::cell::insert_select_option_cell;use crate::services::field::{SelectOptionCellDataPB, SelectOptionCellDataParser, SingleSelectTypeOptionPB};-use crate::services::group::action::GroupAction;+use crate::services::group::action::GroupControllerCustomActions;use crate::services::group::controller::{GenericGroupController, GroupController, GroupGenerator, MoveGroupRowContext,@@ -20,7 +20,7 @@ pub type SingleSelectGroupController = GenericGroupController<SelectOptionCellDataParser,>;-impl GroupAction for SingleSelectGroupController {+impl GroupControllerCustomActions for SingleSelectGroupController {type CellDataType = SelectOptionCellDataPB;fn can_group(&self, content: &str, cell_data: &SelectOptionCellDataPB) -> bool {cell_data.select_options.iter().any(|option| option.id == content)