mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
Merge pull request #987 from AppFlowy-IO/feat/fix_delete_card_bugs
fix: add new created row
This commit is contained in:
commit
dbcddc464f
@ -4,7 +4,6 @@ import 'package:app_flowy/plugins/grid/presentation/widgets/cell/cell_builder.da
|
|||||||
import 'package:flowy_infra_ui/style_widget/text.dart';
|
import 'package:flowy_infra_ui/style_widget/text.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
import 'board_cell.dart';
|
import 'board_cell.dart';
|
||||||
import 'define.dart';
|
import 'define.dart';
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ impl GridBlockManager {
|
|||||||
let editor = self.get_editor_from_row_id(&changeset.row_id).await?;
|
let editor = self.get_editor_from_row_id(&changeset.row_id).await?;
|
||||||
let _ = editor.update_row(changeset.clone()).await?;
|
let _ = editor.update_row(changeset.clone()).await?;
|
||||||
match editor.get_row_rev(&changeset.row_id).await? {
|
match editor.get_row_rev(&changeset.row_id).await? {
|
||||||
None => tracing::error!("Internal error: can't find the row with id: {}", changeset.row_id),
|
None => tracing::error!("Update row failed, can't find the row with id: {}", changeset.row_id),
|
||||||
Some(row_rev) => {
|
Some(row_rev) => {
|
||||||
let row_pb = make_row_from_row_rev(row_rev.clone());
|
let row_pb = make_row_from_row_rev(row_rev.clone());
|
||||||
let block_order_changeset = GridBlockChangesetPB::update(&editor.block_id, vec![row_pb]);
|
let block_order_changeset = GridBlockChangesetPB::update(&editor.block_id, vec![row_pb]);
|
||||||
|
@ -96,6 +96,8 @@ impl GridViewRevisionEditor {
|
|||||||
None => Some(0),
|
None => Some(0),
|
||||||
Some(_) => None,
|
Some(_) => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self.group_controller.write().await.did_create_row(row_pb, group_id);
|
||||||
let inserted_row = InsertedRowPB {
|
let inserted_row = InsertedRowPB {
|
||||||
row: row_pb.clone(),
|
row: row_pb.clone(),
|
||||||
index,
|
index,
|
||||||
|
@ -15,6 +15,7 @@ use std::sync::Arc;
|
|||||||
// a new row.
|
// a new row.
|
||||||
pub trait GroupController: GroupControllerSharedOperation + Send + Sync {
|
pub trait GroupController: GroupControllerSharedOperation + Send + Sync {
|
||||||
fn will_create_row(&mut self, row_rev: &mut RowRevision, field_rev: &FieldRevision, group_id: &str);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait GroupGenerator {
|
pub trait GroupGenerator {
|
||||||
|
@ -28,11 +28,11 @@ impl GroupAction for CheckboxGroupController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn can_group(&self, content: &str, cell_data: &Self::CellDataType) -> bool {
|
fn can_group(&self, content: &str, cell_data: &Self::CellDataType) -> bool {
|
||||||
return if cell_data.is_check() {
|
if cell_data.is_check() {
|
||||||
content == CHECK
|
content == CHECK
|
||||||
} else {
|
} else {
|
||||||
content == UNCHECK
|
content == UNCHECK
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_row_if_match(&mut self, row_rev: &RowRevision, cell_data: &Self::CellDataType) -> Vec<GroupChangesetPB> {
|
fn add_row_if_match(&mut self, row_rev: &RowRevision, cell_data: &Self::CellDataType) -> Vec<GroupChangesetPB> {
|
||||||
@ -46,12 +46,10 @@ impl GroupAction for CheckboxGroupController {
|
|||||||
changeset.inserted_rows.push(InsertedRowPB::new(row_pb.clone()));
|
changeset.inserted_rows.push(InsertedRowPB::new(row_pb.clone()));
|
||||||
group.add_row(row_pb);
|
group.add_row(row_pb);
|
||||||
}
|
}
|
||||||
} else {
|
} else if is_contained {
|
||||||
if is_contained {
|
|
||||||
changeset.deleted_rows.push(row_rev.id.clone());
|
changeset.deleted_rows.push(row_rev.id.clone());
|
||||||
group.remove_row(&row_rev.id);
|
group.remove_row(&row_rev.id);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if !changeset.is_empty() {
|
if !changeset.is_empty() {
|
||||||
changesets.push(changeset);
|
changesets.push(changeset);
|
||||||
}
|
}
|
||||||
@ -97,6 +95,12 @@ impl GroupController for CheckboxGroupController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn did_create_row(&mut self, row_pb: &RowPB, group_id: &str) {
|
||||||
|
if let Some(group) = self.group_ctx.get_mut_group(group_id) {
|
||||||
|
group.add_row(row_pb.clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct CheckboxGroupGenerator();
|
pub struct CheckboxGroupGenerator();
|
||||||
|
@ -77,4 +77,6 @@ impl GroupControllerSharedOperation for DefaultGroupController {
|
|||||||
|
|
||||||
impl GroupController for DefaultGroupController {
|
impl GroupController for DefaultGroupController {
|
||||||
fn will_create_row(&mut self, _row_rev: &mut RowRevision, _field_rev: &FieldRevision, _group_id: &str) {}
|
fn will_create_row(&mut self, _row_rev: &mut RowRevision, _field_rev: &FieldRevision, _group_id: &str) {}
|
||||||
|
|
||||||
|
fn did_create_row(&mut self, _row_rev: &RowPB, _group_id: &str) {}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use crate::entities::GroupChangesetPB;
|
use crate::entities::{GroupChangesetPB, RowPB};
|
||||||
use crate::services::cell::insert_select_option_cell;
|
use crate::services::cell::insert_select_option_cell;
|
||||||
use crate::services::field::{MultiSelectTypeOptionPB, SelectOptionCellDataPB, SelectOptionCellDataParser};
|
use crate::services::field::{MultiSelectTypeOptionPB, SelectOptionCellDataPB, SelectOptionCellDataParser};
|
||||||
use crate::services::group::action::GroupAction;
|
use crate::services::group::action::GroupAction;
|
||||||
@ -67,6 +67,12 @@ impl GroupController for MultiSelectGroupController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn did_create_row(&mut self, row_pb: &RowPB, group_id: &str) {
|
||||||
|
if let Some(group) = self.group_ctx.get_mut_group(group_id) {
|
||||||
|
group.add_row(row_pb.clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct MultiSelectGroupGenerator();
|
pub struct MultiSelectGroupGenerator();
|
||||||
|
@ -65,10 +65,14 @@ impl GroupController for SingleSelectGroupController {
|
|||||||
Some(group) => {
|
Some(group) => {
|
||||||
let cell_rev = insert_select_option_cell(group.id.clone(), field_rev);
|
let cell_rev = insert_select_option_cell(group.id.clone(), field_rev);
|
||||||
row_rev.cells.insert(field_rev.id.clone(), cell_rev);
|
row_rev.cells.insert(field_rev.id.clone(), cell_rev);
|
||||||
group.add_row(RowPB::from(row_rev));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fn did_create_row(&mut self, row_pb: &RowPB, group_id: &str) {
|
||||||
|
if let Some(group) = self.group_ctx.get_mut_group(group_id) {
|
||||||
|
group.add_row(row_pb.clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct SingleSelectGroupGenerator();
|
pub struct SingleSelectGroupGenerator();
|
||||||
|
Loading…
Reference in New Issue
Block a user