fix: remove default group for checkbox

This commit is contained in:
appflowy 2022-09-07 12:29:26 +08:00
parent 29e7e01146
commit 0c45e3ce95
5 changed files with 17 additions and 7 deletions

View File

@ -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)],
);

View File

@ -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>;

View File

@ -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.

View File

@ -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)> {

View File

@ -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