Bläddra i källkod

fix: remove default group for checkbox

appflowy 2 år sedan
förälder
incheckning
0c45e3ce95

+ 1 - 0
frontend/app_flowy/lib/plugins/board/presentation/board_page.dart

@@ -83,6 +83,7 @@ class _BoardContentState extends State<BoardContent> {
         buildWhen: (previous, current) => previous.groupIds != current.groupIds,
         builder: (context, state) {
           final column = Column(
+            crossAxisAlignment: CrossAxisAlignment.start,
             children: [const _ToolbarBlocAdaptor(), _buildBoard(context)],
           );
 

+ 3 - 1
frontend/rust-lib/flowy-grid/src/services/group/action.rs

@@ -8,7 +8,9 @@ pub trait GroupAction: Send + Sync {
     fn default_cell_rev(&self) -> Option<CellRevision> {
         None
     }
-
+    fn use_default_group(&self) -> bool {
+        true
+    }
     fn can_group(&self, content: &str, cell_data: &Self::CellDataType) -> bool;
     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>;

+ 2 - 5
frontend/rust-lib/flowy-grid/src/services/group/configuration.rs

@@ -97,11 +97,8 @@ where
         self.groups_map.values().collect()
     }
 
-    /// Returns the all the groups that contain the default group.
-    pub(crate) fn clone_groups(&self) -> Vec<Group> {
-        let mut groups: Vec<Group> = self.groups_map.values().cloned().collect();
-        groups.push(self.default_group.clone());
-        groups
+    pub(crate) fn default_group(&self) -> &Group {
+        &self.default_group
     }
 
     /// Iterate mut the groups. The default group will be the last one that get mutated.

+ 7 - 1
frontend/rust-lib/flowy-grid/src/services/group/controller.rs

@@ -182,7 +182,13 @@ where
     }
 
     fn groups(&self) -> Vec<Group> {
-        self.group_ctx.clone_groups()
+        if self.use_default_group() {
+            let mut groups: Vec<Group> = self.group_ctx.concrete_groups().into_iter().cloned().collect();
+            groups.push(self.group_ctx.default_group().clone());
+            groups
+        } else {
+            self.group_ctx.concrete_groups().into_iter().cloned().collect()
+        }
     }
 
     fn get_group(&self, group_id: &str) -> Option<(usize, Group)> {

+ 4 - 0
frontend/rust-lib/flowy-grid/src/services/group/controller_impls/checkbox_controller.rs

@@ -27,6 +27,10 @@ impl GroupAction for CheckboxGroupController {
         Some(CellRevision::new(UNCHECK.to_string()))
     }
 
+    fn use_default_group(&self) -> bool {
+        false
+    }
+
     fn can_group(&self, content: &str, cell_data: &Self::CellDataType) -> bool {
         if cell_data.is_check() {
             content == CHECK