mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: can not delete row from no status group
This commit is contained in:
parent
2b451fa06d
commit
589acd9e2b
@ -57,6 +57,7 @@ impl GridBlockManager {
|
||||
Ok(self.get_block_editor(&block_id).await?)
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "trace", skip(self, start_row_id), err)]
|
||||
pub(crate) async fn create_row(&self, row_rev: RowRevision, start_row_id: Option<String>) -> FlowyResult<i32> {
|
||||
let block_id = row_rev.block_id.clone();
|
||||
let _ = self.persistence.insert(&row_rev.block_id, &row_rev.id)?;
|
||||
|
@ -420,6 +420,7 @@ impl GridRevisionEditor {
|
||||
|
||||
pub async fn delete_row(&self, row_id: &str) -> FlowyResult<()> {
|
||||
let row_rev = self.block_manager.delete_row(row_id).await?;
|
||||
tracing::trace!("Did delete row:{:?}", row_rev);
|
||||
if let Some(row_rev) = row_rev {
|
||||
self.view_manager.did_delete_row(row_rev).await;
|
||||
}
|
||||
|
@ -109,6 +109,7 @@ impl GridViewRevisionEditor {
|
||||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "trace", skip_all)]
|
||||
pub(crate) async fn did_delete_row(&self, row_rev: &RowRevision) {
|
||||
// Send the group notification if the current view has groups;
|
||||
let changesets = self
|
||||
@ -116,6 +117,7 @@ impl GridViewRevisionEditor {
|
||||
.await;
|
||||
|
||||
if let Some(changesets) = changesets {
|
||||
tracing::trace!("{:?}", changesets);
|
||||
for changeset in changesets {
|
||||
self.notify_did_update_group(changeset).await;
|
||||
}
|
||||
|
@ -92,17 +92,33 @@ where
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns the groups without the default group
|
||||
pub(crate) fn concrete_groups(&self) -> Vec<&Group> {
|
||||
self.groups_map.values().collect()
|
||||
}
|
||||
|
||||
pub(crate) fn default_group(&self) -> &Group {
|
||||
pub(crate) fn get_default_group(&self) -> &Group {
|
||||
&self.default_group
|
||||
}
|
||||
|
||||
pub(crate) fn get_mut_default_group(&mut self) -> &mut Group {
|
||||
&mut self.default_group
|
||||
}
|
||||
|
||||
/// Returns the groups without the default group
|
||||
pub(crate) fn groups(&self) -> Vec<&Group> {
|
||||
self.groups_map.values().collect()
|
||||
}
|
||||
|
||||
pub(crate) fn get_mut_group(&mut self, group_id: &str) -> Option<&mut Group> {
|
||||
self.groups_map.get_mut(group_id)
|
||||
}
|
||||
|
||||
// Returns the index and group specified by the group_id
|
||||
pub(crate) fn get_group(&self, group_id: &str) -> Option<(usize, &Group)> {
|
||||
match (self.groups_map.get_index_of(group_id), self.groups_map.get(group_id)) {
|
||||
(Some(index), Some(group)) => Some((index, group)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Iterate mut the groups. The default group will be the last one that get mutated.
|
||||
pub(crate) fn iter_mut_groups(&mut self, mut each: impl FnMut(&mut Group)) {
|
||||
pub(crate) fn iter_mut_all_groups(&mut self, mut each: impl FnMut(&mut Group)) {
|
||||
self.groups_map.iter_mut().for_each(|(_, group)| {
|
||||
each(group);
|
||||
});
|
||||
@ -253,22 +269,6 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn get_mut_default_group(&mut self) -> &mut Group {
|
||||
&mut self.default_group
|
||||
}
|
||||
|
||||
pub(crate) fn get_mut_group(&mut self, group_id: &str) -> Option<&mut Group> {
|
||||
self.groups_map.get_mut(group_id)
|
||||
}
|
||||
|
||||
// Returns the index and group specified by the group_id
|
||||
pub(crate) fn get_group(&self, group_id: &str) -> Option<(usize, &Group)> {
|
||||
match (self.groups_map.get_index_of(group_id), self.groups_map.get(group_id)) {
|
||||
(Some(index), Some(group)) => Some((index, group)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn save_configuration(&self) -> FlowyResult<()> {
|
||||
let configuration = (&*self.configuration).clone();
|
||||
let writer = self.writer.clone();
|
||||
|
@ -183,11 +183,11 @@ where
|
||||
|
||||
fn groups(&self) -> Vec<Group> {
|
||||
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());
|
||||
let mut groups: Vec<Group> = self.group_ctx.groups().into_iter().cloned().collect();
|
||||
groups.push(self.group_ctx.get_default_group().clone());
|
||||
groups
|
||||
} else {
|
||||
self.group_ctx.concrete_groups().into_iter().cloned().collect()
|
||||
self.group_ctx.groups().into_iter().cloned().collect()
|
||||
}
|
||||
}
|
||||
|
||||
@ -208,7 +208,7 @@ where
|
||||
let mut grouped_rows: Vec<GroupedRow> = vec![];
|
||||
let cell_bytes = decode_any_cell_data(cell_rev.data, field_rev);
|
||||
let cell_data = cell_bytes.parser::<P>()?;
|
||||
for group in self.group_ctx.concrete_groups() {
|
||||
for group in self.group_ctx.groups() {
|
||||
if self.can_group(&group.filter_content, &cell_data) {
|
||||
grouped_rows.push(GroupedRow {
|
||||
row: row_rev.into(),
|
||||
@ -264,12 +264,17 @@ where
|
||||
row_rev: &RowRevision,
|
||||
field_rev: &FieldRevision,
|
||||
) -> FlowyResult<Vec<GroupChangesetPB>> {
|
||||
// if the cell_rev is none, then the row must be crated from the default group.
|
||||
if let Some(cell_rev) = row_rev.cells.get(&self.field_id) {
|
||||
let cell_bytes = decode_any_cell_data(cell_rev.data.clone(), field_rev);
|
||||
let cell_data = cell_bytes.parser::<P>()?;
|
||||
Ok(self.remove_row_if_match(row_rev, &cell_data))
|
||||
} else {
|
||||
Ok(vec![])
|
||||
let group = self.group_ctx.get_default_group();
|
||||
Ok(vec![GroupChangesetPB::delete(
|
||||
group.id.clone(),
|
||||
vec![row_rev.id.clone()],
|
||||
)])
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ impl GroupAction for CheckboxGroupController {
|
||||
|
||||
fn add_row_if_match(&mut self, row_rev: &RowRevision, cell_data: &Self::CellDataType) -> Vec<GroupChangesetPB> {
|
||||
let mut changesets = vec![];
|
||||
self.group_ctx.iter_mut_groups(|group| {
|
||||
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() {
|
||||
@ -63,7 +63,7 @@ impl GroupAction for CheckboxGroupController {
|
||||
|
||||
fn remove_row_if_match(&mut self, row_rev: &RowRevision, _cell_data: &Self::CellDataType) -> Vec<GroupChangesetPB> {
|
||||
let mut changesets = vec![];
|
||||
self.group_ctx.iter_mut_groups(|group| {
|
||||
self.group_ctx.iter_mut_all_groups(|group| {
|
||||
let mut changeset = GroupChangesetPB::new(group.id.clone());
|
||||
if group.contains_row(&row_rev.id) {
|
||||
changeset.deleted_rows.push(row_rev.id.clone());
|
||||
@ -79,7 +79,7 @@ impl GroupAction for CheckboxGroupController {
|
||||
|
||||
fn move_row(&mut self, _cell_data: &Self::CellDataType, mut context: MoveGroupRowContext) -> Vec<GroupChangesetPB> {
|
||||
let mut group_changeset = vec![];
|
||||
self.group_ctx.iter_mut_groups(|group| {
|
||||
self.group_ctx.iter_mut_all_groups(|group| {
|
||||
if let Some(changeset) = move_group_row(group, &mut context) {
|
||||
group_changeset.push(changeset);
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ impl GroupAction for MultiSelectGroupController {
|
||||
|
||||
fn add_row_if_match(&mut self, row_rev: &RowRevision, cell_data: &Self::CellDataType) -> Vec<GroupChangesetPB> {
|
||||
let mut changesets = vec![];
|
||||
self.group_ctx.iter_mut_groups(|group| {
|
||||
self.group_ctx.iter_mut_all_groups(|group| {
|
||||
if let Some(changeset) = add_select_option_row(group, cell_data, row_rev) {
|
||||
changesets.push(changeset);
|
||||
}
|
||||
@ -38,7 +38,7 @@ impl GroupAction for MultiSelectGroupController {
|
||||
|
||||
fn remove_row_if_match(&mut self, row_rev: &RowRevision, cell_data: &Self::CellDataType) -> Vec<GroupChangesetPB> {
|
||||
let mut changesets = vec![];
|
||||
self.group_ctx.iter_mut_groups(|group| {
|
||||
self.group_ctx.iter_mut_all_groups(|group| {
|
||||
if let Some(changeset) = remove_select_option_row(group, cell_data, row_rev) {
|
||||
changesets.push(changeset);
|
||||
}
|
||||
@ -48,7 +48,7 @@ impl GroupAction for MultiSelectGroupController {
|
||||
|
||||
fn move_row(&mut self, _cell_data: &Self::CellDataType, mut context: MoveGroupRowContext) -> Vec<GroupChangesetPB> {
|
||||
let mut group_changeset = vec![];
|
||||
self.group_ctx.iter_mut_groups(|group| {
|
||||
self.group_ctx.iter_mut_all_groups(|group| {
|
||||
if let Some(changeset) = move_group_row(group, &mut context) {
|
||||
group_changeset.push(changeset);
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ impl GroupAction for SingleSelectGroupController {
|
||||
|
||||
fn add_row_if_match(&mut self, row_rev: &RowRevision, cell_data: &Self::CellDataType) -> Vec<GroupChangesetPB> {
|
||||
let mut changesets = vec![];
|
||||
self.group_ctx.iter_mut_groups(|group| {
|
||||
self.group_ctx.iter_mut_all_groups(|group| {
|
||||
if let Some(changeset) = add_select_option_row(group, cell_data, row_rev) {
|
||||
changesets.push(changeset);
|
||||
}
|
||||
@ -38,7 +38,7 @@ impl GroupAction for SingleSelectGroupController {
|
||||
|
||||
fn remove_row_if_match(&mut self, row_rev: &RowRevision, cell_data: &Self::CellDataType) -> Vec<GroupChangesetPB> {
|
||||
let mut changesets = vec![];
|
||||
self.group_ctx.iter_mut_groups(|group| {
|
||||
self.group_ctx.iter_mut_all_groups(|group| {
|
||||
if let Some(changeset) = remove_select_option_row(group, cell_data, row_rev) {
|
||||
changesets.push(changeset);
|
||||
}
|
||||
@ -48,7 +48,7 @@ impl GroupAction for SingleSelectGroupController {
|
||||
|
||||
fn move_row(&mut self, _cell_data: &Self::CellDataType, mut context: MoveGroupRowContext) -> Vec<GroupChangesetPB> {
|
||||
let mut group_changeset = vec![];
|
||||
self.group_ctx.iter_mut_groups(|group| {
|
||||
self.group_ctx.iter_mut_all_groups(|group| {
|
||||
if let Some(changeset) = move_group_row(group, &mut context) {
|
||||
group_changeset.push(changeset);
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ impl GridViewRevisionPad {
|
||||
Self { view, delta }
|
||||
}
|
||||
|
||||
|
||||
pub fn from_delta(view_id: &str, delta: Delta) -> CollaborateResult<Self> {
|
||||
if delta.is_empty() {
|
||||
return Ok(GridViewRevisionPad::new(view_id.to_owned(), view_id.to_owned()));
|
||||
@ -49,15 +48,9 @@ impl GridViewRevisionPad {
|
||||
})
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
pub fn from_revisions(_grid_id: &str, revisions: Vec<Revision>) -> CollaborateResult<Self> {
|
||||
let delta: Delta = make_text_delta_from_revisions(revisions)?;
|
||||
Self::from_delta(delta)
|
||||
=======
|
||||
pub fn from_revisions(view_id: &str, revisions: Vec<Revision>) -> CollaborateResult<Self> {
|
||||
let delta: TextDelta = make_text_delta_from_revisions(revisions)?;
|
||||
let delta: Delta = make_text_delta_from_revisions(revisions)?;
|
||||
Self::from_delta(view_id, delta)
|
||||
>>>>>>> 01dbc68d4 (chore: fix open application error when upgrade to 0.0.5.1)
|
||||
}
|
||||
|
||||
pub fn get_groups_by_field_revs(&self, field_revs: &[Arc<FieldRevision>]) -> Option<GroupConfigurationsByFieldId> {
|
||||
|
Loading…
Reference in New Issue
Block a user