mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: row disappear when update the row in checkbox board (#1266)
This commit is contained in:
parent
1adf6530fe
commit
a516ec82bc
@ -12,6 +12,10 @@ impl CheckboxCellData {
|
||||
pub fn is_check(&self) -> bool {
|
||||
self.0 == CHECK
|
||||
}
|
||||
|
||||
pub fn is_uncheck(&self) -> bool {
|
||||
self.0 == UNCHECK
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<[u8]> for CheckboxCellData {
|
||||
|
@ -270,12 +270,16 @@ where
|
||||
let 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(changesets)
|
||||
} else {
|
||||
Ok(vec![])
|
||||
|
@ -43,17 +43,37 @@ impl GroupAction for CheckboxGroupController {
|
||||
let mut changesets = vec![];
|
||||
self.group_ctx.iter_mut_all_groups(|group| {
|
||||
let mut changeset = GroupChangesetPB::new(group.id.clone());
|
||||
let is_contained = group.contains_row(&row_rev.id);
|
||||
if group.id == CHECK && cell_data.is_check() {
|
||||
if !is_contained {
|
||||
let is_not_contained = !group.contains_row(&row_rev.id);
|
||||
if group.id == CHECK {
|
||||
if cell_data.is_uncheck() {
|
||||
// Remove the row if the group.id is CHECK but the cell_data is UNCHECK
|
||||
changeset.deleted_rows.push(row_rev.id.clone());
|
||||
group.remove_row(&row_rev.id);
|
||||
} else {
|
||||
// Add the row to the group if the group didn't contain the row
|
||||
if is_not_contained {
|
||||
let row_pb = RowPB::from(row_rev);
|
||||
changeset.inserted_rows.push(InsertedRowPB::new(row_pb.clone()));
|
||||
group.add_row(row_pb);
|
||||
}
|
||||
} else if is_contained {
|
||||
}
|
||||
}
|
||||
|
||||
if group.id == UNCHECK {
|
||||
if cell_data.is_check() {
|
||||
// Remove the row if the group.id is UNCHECK but the cell_data is CHECK
|
||||
changeset.deleted_rows.push(row_rev.id.clone());
|
||||
group.remove_row(&row_rev.id);
|
||||
} else {
|
||||
// Add the row to the group if the group didn't contain the row
|
||||
if is_not_contained {
|
||||
let row_pb = RowPB::from(row_rev);
|
||||
changeset.inserted_rows.push(InsertedRowPB::new(row_pb.clone()));
|
||||
group.add_row(row_pb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !changeset.is_empty() {
|
||||
changesets.push(changeset);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user