mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: send group notification
This commit is contained in:
parent
0b26ad0541
commit
b7d71428be
@ -18,14 +18,13 @@ class FieldService {
|
||||
FieldService({required this.gridId, required this.fieldId});
|
||||
|
||||
Future<Either<Unit, FlowyError>> moveField(int fromIndex, int toIndex) {
|
||||
final payload = MoveItemPayloadPB.create()
|
||||
final payload = MoveFieldPayloadPB.create()
|
||||
..gridId = gridId
|
||||
..itemId = fieldId
|
||||
..ty = MoveItemTypePB.MoveField
|
||||
..fieldId = fieldId
|
||||
..fromIndex = fromIndex
|
||||
..toIndex = toIndex;
|
||||
|
||||
return GridEventMoveItem(payload).send();
|
||||
return GridEventMoveField(payload).send();
|
||||
}
|
||||
|
||||
Future<Either<Unit, FlowyError>> updateField({
|
||||
|
@ -4,6 +4,7 @@ import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-grid/block_entities.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-grid/grid_entities.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-grid/row_entities.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-grid/setting_entities.pb.dart';
|
||||
|
||||
class RowFFIService {
|
||||
final String gridId;
|
||||
@ -21,16 +22,25 @@ class RowFFIService {
|
||||
return GridEventCreateRow(payload).send();
|
||||
}
|
||||
|
||||
Future<Either<Unit, FlowyError>> moveRow(
|
||||
String rowId, int fromIndex, int toIndex) {
|
||||
final payload = MoveItemPayloadPB.create()
|
||||
..gridId = gridId
|
||||
..itemId = rowId
|
||||
..ty = MoveItemTypePB.MoveRow
|
||||
Future<Either<Unit, FlowyError>> moveRow({
|
||||
required String rowId,
|
||||
required int fromIndex,
|
||||
required int toIndex,
|
||||
required GridLayout layout,
|
||||
String? upperRowId,
|
||||
}) {
|
||||
var payload = MoveRowPayloadPB.create()
|
||||
..viewId = gridId
|
||||
..rowId = rowId
|
||||
..layout = layout
|
||||
..fromIndex = fromIndex
|
||||
..toIndex = toIndex;
|
||||
|
||||
return GridEventMoveItem(payload).send();
|
||||
if (upperRowId != null) {
|
||||
payload.upperRowId = upperRowId;
|
||||
}
|
||||
|
||||
return GridEventMoveRow(payload).send();
|
||||
}
|
||||
|
||||
Future<Either<OptionalRowPB, FlowyError>> getRow() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::entities::{BlockPB, FieldIdPB};
|
||||
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
|
||||
use crate::entities::{BlockPB, FieldIdPB, GridLayout};
|
||||
use flowy_derive::ProtoBuf;
|
||||
use flowy_error::ErrorCode;
|
||||
use flowy_grid_data_model::parser::NotEmptyStr;
|
||||
|
||||
@ -52,25 +52,51 @@ impl std::convert::From<&str> for GridBlockIdPB {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, ProtoBuf_Enum)]
|
||||
pub enum MoveItemTypePB {
|
||||
MoveField = 0,
|
||||
MoveRow = 1,
|
||||
}
|
||||
|
||||
impl std::default::Default for MoveItemTypePB {
|
||||
fn default() -> Self {
|
||||
MoveItemTypePB::MoveField
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, ProtoBuf)]
|
||||
pub struct MoveItemPayloadPB {
|
||||
pub struct MoveFieldPayloadPB {
|
||||
#[pb(index = 1)]
|
||||
pub grid_id: String,
|
||||
|
||||
#[pb(index = 2)]
|
||||
pub item_id: String,
|
||||
pub field_id: String,
|
||||
|
||||
#[pb(index = 3)]
|
||||
pub from_index: i32,
|
||||
|
||||
#[pb(index = 4)]
|
||||
pub to_index: i32,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct MoveFieldParams {
|
||||
pub grid_id: String,
|
||||
pub field_id: String,
|
||||
pub from_index: i32,
|
||||
pub to_index: i32,
|
||||
}
|
||||
|
||||
impl TryInto<MoveFieldParams> for MoveFieldPayloadPB {
|
||||
type Error = ErrorCode;
|
||||
|
||||
fn try_into(self) -> Result<MoveFieldParams, Self::Error> {
|
||||
let grid_id = NotEmptyStr::parse(self.grid_id).map_err(|_| ErrorCode::GridIdIsEmpty)?;
|
||||
let item_id = NotEmptyStr::parse(self.field_id).map_err(|_| ErrorCode::InvalidData)?;
|
||||
Ok(MoveFieldParams {
|
||||
grid_id: grid_id.0,
|
||||
field_id: item_id.0,
|
||||
from_index: self.from_index,
|
||||
to_index: self.to_index,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, ProtoBuf)]
|
||||
pub struct MoveRowPayloadPB {
|
||||
#[pb(index = 1)]
|
||||
pub view_id: String,
|
||||
|
||||
#[pb(index = 2)]
|
||||
pub row_id: String,
|
||||
|
||||
#[pb(index = 3)]
|
||||
pub from_index: i32,
|
||||
@ -79,30 +105,38 @@ pub struct MoveItemPayloadPB {
|
||||
pub to_index: i32,
|
||||
|
||||
#[pb(index = 5)]
|
||||
pub ty: MoveItemTypePB,
|
||||
pub layout: GridLayout,
|
||||
|
||||
#[pb(index = 6, one_of)]
|
||||
pub upper_row_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct MoveItemParams {
|
||||
pub grid_id: String,
|
||||
pub item_id: String,
|
||||
pub struct MoveRowParams {
|
||||
pub view_id: String,
|
||||
pub row_id: String,
|
||||
pub from_index: i32,
|
||||
pub to_index: i32,
|
||||
pub ty: MoveItemTypePB,
|
||||
pub layout: GridLayout,
|
||||
pub upper_row_id: Option<String>,
|
||||
}
|
||||
|
||||
impl TryInto<MoveItemParams> for MoveItemPayloadPB {
|
||||
impl TryInto<MoveRowParams> for MoveRowPayloadPB {
|
||||
type Error = ErrorCode;
|
||||
|
||||
fn try_into(self) -> Result<MoveItemParams, Self::Error> {
|
||||
let grid_id = NotEmptyStr::parse(self.grid_id).map_err(|_| ErrorCode::GridIdIsEmpty)?;
|
||||
let item_id = NotEmptyStr::parse(self.item_id).map_err(|_| ErrorCode::InvalidData)?;
|
||||
Ok(MoveItemParams {
|
||||
grid_id: grid_id.0,
|
||||
item_id: item_id.0,
|
||||
fn try_into(self) -> Result<MoveRowParams, Self::Error> {
|
||||
let view_id = NotEmptyStr::parse(self.view_id).map_err(|_| ErrorCode::GridViewIdIsEmpty)?;
|
||||
let row_id = NotEmptyStr::parse(self.row_id).map_err(|_| ErrorCode::RowIdIsEmpty)?;
|
||||
let upper_row_id = match self.upper_row_id {
|
||||
None => None,
|
||||
Some(upper_row_id) => Some(NotEmptyStr::parse(upper_row_id).map_err(|_| ErrorCode::RowIdIsEmpty)?.0),
|
||||
};
|
||||
Ok(MoveRowParams {
|
||||
view_id: view_id.0,
|
||||
row_id: row_id.0,
|
||||
from_index: self.from_index,
|
||||
to_index: self.to_index,
|
||||
ty: self.ty,
|
||||
layout: self.layout,
|
||||
upper_row_id,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::entities::{CreateRowParams, RowPB};
|
||||
use crate::entities::{CreateRowParams, GridLayout, RowPB};
|
||||
use flowy_derive::ProtoBuf;
|
||||
use flowy_error::ErrorCode;
|
||||
use flowy_grid_data_model::parser::NotEmptyStr;
|
||||
@ -22,45 +22,46 @@ impl TryInto<CreateRowParams> for CreateBoardCardPayloadPB {
|
||||
grid_id: grid_id.0,
|
||||
start_row_id: None,
|
||||
group_id: Some(group_id.0),
|
||||
layout: GridLayout::Board,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, ProtoBuf)]
|
||||
pub struct BoardCardChangesetPB {
|
||||
pub struct GroupRowsChangesetPB {
|
||||
#[pb(index = 1)]
|
||||
pub group_id: String,
|
||||
|
||||
#[pb(index = 2)]
|
||||
pub inserted_cards: Vec<RowPB>,
|
||||
pub inserted_rows: Vec<RowPB>,
|
||||
|
||||
#[pb(index = 3)]
|
||||
pub deleted_cards: Vec<String>,
|
||||
pub deleted_rows: Vec<String>,
|
||||
|
||||
#[pb(index = 4)]
|
||||
pub updated_cards: Vec<RowPB>,
|
||||
pub updated_rows: Vec<RowPB>,
|
||||
}
|
||||
impl BoardCardChangesetPB {
|
||||
pub fn insert(group_id: String, inserted_cards: Vec<RowPB>) -> Self {
|
||||
impl GroupRowsChangesetPB {
|
||||
pub fn insert(group_id: String, inserted_rows: Vec<RowPB>) -> Self {
|
||||
Self {
|
||||
group_id,
|
||||
inserted_cards,
|
||||
inserted_rows,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn delete(group_id: String, deleted_cards: Vec<String>) -> Self {
|
||||
pub fn delete(group_id: String, deleted_rows: Vec<String>) -> Self {
|
||||
Self {
|
||||
group_id,
|
||||
deleted_cards,
|
||||
deleted_rows,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update(group_id: String, updated_cards: Vec<RowPB>) -> Self {
|
||||
pub fn update(group_id: String, updated_rows: Vec<RowPB>) -> Self {
|
||||
Self {
|
||||
group_id,
|
||||
updated_cards,
|
||||
updated_rows,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
use crate::entities::GridLayout;
|
||||
use flowy_derive::ProtoBuf;
|
||||
use flowy_error::ErrorCode;
|
||||
use flowy_grid_data_model::parser::NotEmptyStr;
|
||||
@ -46,7 +47,7 @@ pub struct BlockRowIdPB {
|
||||
}
|
||||
|
||||
#[derive(ProtoBuf, Default)]
|
||||
pub struct CreateRowPayloadPB {
|
||||
pub struct CreateTableRowPayloadPB {
|
||||
#[pb(index = 1)]
|
||||
pub grid_id: String,
|
||||
|
||||
@ -59,17 +60,20 @@ pub struct CreateRowParams {
|
||||
pub grid_id: String,
|
||||
pub start_row_id: Option<String>,
|
||||
pub group_id: Option<String>,
|
||||
pub layout: GridLayout,
|
||||
}
|
||||
|
||||
impl TryInto<CreateRowParams> for CreateRowPayloadPB {
|
||||
impl TryInto<CreateRowParams> for CreateTableRowPayloadPB {
|
||||
type Error = ErrorCode;
|
||||
|
||||
fn try_into(self) -> Result<CreateRowParams, Self::Error> {
|
||||
let grid_id = NotEmptyStr::parse(self.grid_id).map_err(|_| ErrorCode::GridIdIsEmpty)?;
|
||||
|
||||
Ok(CreateRowParams {
|
||||
grid_id: grid_id.0,
|
||||
start_row_id: self.start_row_id,
|
||||
group_id: None,
|
||||
layout: GridLayout::Table,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ pub struct GridSettingPB {
|
||||
pub layouts: Vec<GridLayoutPB>,
|
||||
|
||||
#[pb(index = 2)]
|
||||
pub current_layout_type: Layout,
|
||||
pub current_layout_type: GridLayout,
|
||||
|
||||
#[pb(index = 3)]
|
||||
pub filter_configuration_by_field_id: HashMap<String, RepeatedGridConfigurationFilterPB>,
|
||||
@ -34,13 +34,13 @@ pub struct GridSettingPB {
|
||||
#[derive(Eq, PartialEq, ProtoBuf, Debug, Default, Clone)]
|
||||
pub struct GridLayoutPB {
|
||||
#[pb(index = 1)]
|
||||
ty: Layout,
|
||||
ty: GridLayout,
|
||||
}
|
||||
|
||||
impl GridLayoutPB {
|
||||
pub fn all() -> Vec<GridLayoutPB> {
|
||||
let mut layouts = vec![];
|
||||
for layout_ty in Layout::iter() {
|
||||
for layout_ty in GridLayout::iter() {
|
||||
layouts.push(GridLayoutPB { ty: layout_ty })
|
||||
}
|
||||
|
||||
@ -50,31 +50,31 @@ impl GridLayoutPB {
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, ProtoBuf_Enum, EnumIter)]
|
||||
#[repr(u8)]
|
||||
pub enum Layout {
|
||||
pub enum GridLayout {
|
||||
Table = 0,
|
||||
Board = 1,
|
||||
}
|
||||
|
||||
impl std::default::Default for Layout {
|
||||
impl std::default::Default for GridLayout {
|
||||
fn default() -> Self {
|
||||
Layout::Table
|
||||
GridLayout::Table
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<LayoutRevision> for Layout {
|
||||
impl std::convert::From<LayoutRevision> for GridLayout {
|
||||
fn from(rev: LayoutRevision) -> Self {
|
||||
match rev {
|
||||
LayoutRevision::Table => Layout::Table,
|
||||
LayoutRevision::Board => Layout::Board,
|
||||
LayoutRevision::Table => GridLayout::Table,
|
||||
LayoutRevision::Board => GridLayout::Board,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<Layout> for LayoutRevision {
|
||||
fn from(layout: Layout) -> Self {
|
||||
impl std::convert::From<GridLayout> for LayoutRevision {
|
||||
fn from(layout: GridLayout) -> Self {
|
||||
match layout {
|
||||
Layout::Table => LayoutRevision::Table,
|
||||
Layout::Board => LayoutRevision::Board,
|
||||
GridLayout::Table => LayoutRevision::Table,
|
||||
GridLayout::Board => LayoutRevision::Board,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -85,7 +85,7 @@ pub struct GridSettingChangesetPayloadPB {
|
||||
pub grid_id: String,
|
||||
|
||||
#[pb(index = 2)]
|
||||
pub layout_type: Layout,
|
||||
pub layout_type: GridLayout,
|
||||
|
||||
#[pb(index = 3, one_of)]
|
||||
pub insert_filter: Option<CreateGridFilterPayloadPB>,
|
||||
|
@ -203,13 +203,13 @@ pub(crate) async fn create_field_type_option_data_handler(
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "trace", skip(data, manager), err)]
|
||||
pub(crate) async fn move_item_handler(
|
||||
data: Data<MoveItemPayloadPB>,
|
||||
pub(crate) async fn move_field_handler(
|
||||
data: Data<MoveFieldPayloadPB>,
|
||||
manager: AppData<Arc<GridManager>>,
|
||||
) -> Result<(), FlowyError> {
|
||||
let params: MoveItemParams = data.into_inner().try_into()?;
|
||||
let params: MoveFieldParams = data.into_inner().try_into()?;
|
||||
let editor = manager.get_grid_editor(¶ms.grid_id)?;
|
||||
let _ = editor.move_item(params).await?;
|
||||
let _ = editor.move_field(params).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -260,8 +260,19 @@ pub(crate) async fn duplicate_row_handler(
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(data, manager), err)]
|
||||
pub(crate) async fn create_row_handler(
|
||||
data: Data<CreateRowPayloadPB>,
|
||||
pub(crate) async fn move_row_handler(
|
||||
data: Data<MoveRowPayloadPB>,
|
||||
manager: AppData<Arc<GridManager>>,
|
||||
) -> Result<(), FlowyError> {
|
||||
let params: MoveRowParams = data.into_inner().try_into()?;
|
||||
let editor = manager.get_grid_editor(¶ms.view_id)?;
|
||||
let _ = editor.move_row(params).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(data, manager), err)]
|
||||
pub(crate) async fn create_table_row_handler(
|
||||
data: Data<CreateTableRowPayloadPB>,
|
||||
manager: AppData<Arc<GridManager>>,
|
||||
) -> DataResult<RowPB, FlowyError> {
|
||||
let params: CreateRowParams = data.into_inner().try_into()?;
|
||||
|
@ -20,14 +20,15 @@ pub fn create(grid_manager: Arc<GridManager>) -> Module {
|
||||
.event(GridEvent::DeleteField, delete_field_handler)
|
||||
.event(GridEvent::SwitchToField, switch_to_field_handler)
|
||||
.event(GridEvent::DuplicateField, duplicate_field_handler)
|
||||
.event(GridEvent::MoveItem, move_item_handler)
|
||||
.event(GridEvent::MoveField, move_field_handler)
|
||||
.event(GridEvent::GetFieldTypeOption, get_field_type_option_data_handler)
|
||||
.event(GridEvent::CreateFieldTypeOption, create_field_type_option_data_handler)
|
||||
// Row
|
||||
.event(GridEvent::CreateRow, create_row_handler)
|
||||
.event(GridEvent::CreateTableRow, create_table_row_handler)
|
||||
.event(GridEvent::GetRow, get_row_handler)
|
||||
.event(GridEvent::DeleteRow, delete_row_handler)
|
||||
.event(GridEvent::DuplicateRow, duplicate_row_handler)
|
||||
.event(GridEvent::MoveRow, move_row_handler)
|
||||
// Cell
|
||||
.event(GridEvent::GetCell, get_cell_handler)
|
||||
.event(GridEvent::UpdateCell, update_cell_handler)
|
||||
@ -130,8 +131,8 @@ pub enum GridEvent {
|
||||
|
||||
/// [MoveItem] event is used to move an item. For the moment, Item has two types defined in
|
||||
/// [MoveItemTypePB].
|
||||
#[event(input = "MoveItemPayloadPB")]
|
||||
MoveItem = 22,
|
||||
#[event(input = "MoveFieldPayloadPB")]
|
||||
MoveField = 22,
|
||||
|
||||
/// [FieldTypeOptionIdPB] event is used to get the FieldTypeOption data for a specific field type.
|
||||
///
|
||||
@ -166,8 +167,8 @@ pub enum GridEvent {
|
||||
#[event(input = "SelectOptionChangesetPayloadPB")]
|
||||
UpdateSelectOption = 32,
|
||||
|
||||
#[event(input = "CreateRowPayloadPB", output = "RowPB")]
|
||||
CreateRow = 50,
|
||||
#[event(input = "CreateTableRowPayloadPB", output = "RowPB")]
|
||||
CreateTableRow = 50,
|
||||
|
||||
/// [GetRow] event is used to get the row data,[RowPB]. [OptionalRowPB] is a wrapper that enables
|
||||
/// to return a nullable row data.
|
||||
@ -180,6 +181,9 @@ pub enum GridEvent {
|
||||
#[event(input = "RowIdPB")]
|
||||
DuplicateRow = 53,
|
||||
|
||||
#[event(input = "MoveRowPayloadPB")]
|
||||
MoveRow = 54,
|
||||
|
||||
#[event(input = "GridCellIdPB", output = "GridCellPB")]
|
||||
GetCell = 70,
|
||||
|
||||
|
@ -59,7 +59,7 @@ impl GridBlockRevisionEditor {
|
||||
if let Some(start_row_id) = prev_row_id.as_ref() {
|
||||
match block_pad.index_of_row(start_row_id) {
|
||||
None => {}
|
||||
Some(index) => row_index = Some(index + 1),
|
||||
Some(index) => row_index = Some(index as i32 + 1),
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,6 +100,10 @@ impl GridBlockRevisionEditor {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn index_of_row(&self, row_id: &str) -> Option<usize> {
|
||||
self.pad.read().await.index_of_row(row_id)
|
||||
}
|
||||
|
||||
pub async fn get_row_rev(&self, row_id: &str) -> FlowyResult<Option<Arc<RowRevision>>> {
|
||||
let row_ids = vec![Cow::Borrowed(row_id)];
|
||||
let row_rev = self.get_row_revs(Some(row_ids)).await?.pop();
|
||||
|
@ -52,7 +52,7 @@ impl GridBlockManager {
|
||||
}
|
||||
}
|
||||
|
||||
async fn get_editor_from_row_id(&self, row_id: &str) -> FlowyResult<Arc<GridBlockRevisionEditor>> {
|
||||
pub(crate) async fn get_editor_from_row_id(&self, row_id: &str) -> FlowyResult<Arc<GridBlockRevisionEditor>> {
|
||||
let block_id = self.persistence.get_block_id(row_id)?;
|
||||
Ok(self.get_block_editor(&block_id).await?)
|
||||
}
|
||||
@ -155,7 +155,7 @@ impl GridBlockManager {
|
||||
|
||||
Ok(changesets)
|
||||
}
|
||||
|
||||
// This function will be moved to GridViewRevisionEditor
|
||||
pub(crate) async fn move_row(&self, row_rev: Arc<RowRevision>, from: usize, to: usize) -> FlowyResult<()> {
|
||||
let editor = self.get_editor_from_row_id(&row_rev.id).await?;
|
||||
let _ = editor.move_row(&row_rev.id, from, to).await?;
|
||||
@ -180,6 +180,14 @@ impl GridBlockManager {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// This function will be moved to GridViewRevisionEditor.
|
||||
pub async fn index_of_row(&self, row_id: &str) -> Option<usize> {
|
||||
match self.get_editor_from_row_id(row_id).await {
|
||||
Ok(editor) => editor.index_of_row(row_id).await,
|
||||
Err(_) => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn update_cell<F>(&self, changeset: CellChangesetPB, row_builder: F) -> FlowyResult<()>
|
||||
where
|
||||
F: FnOnce(Arc<RowRevision>) -> RowPB,
|
||||
|
@ -342,7 +342,7 @@ impl GridRevisionEditor {
|
||||
|
||||
pub async fn delete_row(&self, row_id: &str) -> FlowyResult<()> {
|
||||
let _ = self.block_manager.delete_row(row_id).await?;
|
||||
self.view_manager.delete_row(row_id).await;
|
||||
self.view_manager.did_delete_row(row_id).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -484,21 +484,22 @@ impl GridRevisionEditor {
|
||||
Ok(snapshots)
|
||||
}
|
||||
|
||||
pub async fn move_item(&self, params: MoveItemParams) -> FlowyResult<()> {
|
||||
match params.ty {
|
||||
MoveItemTypePB::MoveField => {
|
||||
self.move_field(¶ms.item_id, params.from_index, params.to_index)
|
||||
.await
|
||||
}
|
||||
MoveItemTypePB::MoveRow => self.move_row(¶ms.item_id, params.from_index, params.to_index).await,
|
||||
}
|
||||
pub async fn move_row(&self, params: MoveRowParams) -> FlowyResult<()> {
|
||||
self.view_manager.move_row(params).await
|
||||
}
|
||||
|
||||
pub async fn move_field(&self, field_id: &str, from: i32, to: i32) -> FlowyResult<()> {
|
||||
pub async fn move_field(&self, params: MoveFieldParams) -> FlowyResult<()> {
|
||||
let MoveFieldParams {
|
||||
grid_id: _,
|
||||
field_id,
|
||||
from_index,
|
||||
to_index,
|
||||
} = params;
|
||||
|
||||
let _ = self
|
||||
.modify(|grid_pad| Ok(grid_pad.move_field(field_id, from as usize, to as usize)?))
|
||||
.modify(|grid_pad| Ok(grid_pad.move_field(&field_id, from_index as usize, to_index as usize)?))
|
||||
.await?;
|
||||
if let Some((index, field_rev)) = self.grid_pad.read().await.get_field_rev(field_id) {
|
||||
if let Some((index, field_rev)) = self.grid_pad.read().await.get_field_rev(&field_id) {
|
||||
let delete_field_order = FieldIdPB::from(field_id);
|
||||
let insert_field = IndexFieldPB::from_field_rev(field_rev, index);
|
||||
let notified_changeset = FieldChangesetPB {
|
||||
@ -513,10 +514,6 @@ impl GridRevisionEditor {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn move_row(&self, row_id: &str, from: i32, to: i32) -> FlowyResult<()> {
|
||||
self.view_manager.move_row(row_id, from, to).await
|
||||
}
|
||||
|
||||
pub async fn delta_bytes(&self) -> Bytes {
|
||||
self.grid_pad.read().await.delta_bytes()
|
||||
}
|
||||
|
@ -1,13 +1,16 @@
|
||||
use flowy_error::{FlowyError, FlowyResult};
|
||||
|
||||
use crate::entities::{CreateRowParams, GridFilterConfiguration, GridSettingPB, GroupPB, RowPB};
|
||||
use crate::entities::{
|
||||
CreateRowParams, GridFilterConfiguration, GridLayout, GridSettingPB, GroupPB, GroupRowsChangesetPB, RowPB,
|
||||
};
|
||||
use crate::services::grid_editor_task::GridServiceTaskScheduler;
|
||||
use crate::services::group::{default_group_configuration, GroupConfigurationDelegate, GroupService};
|
||||
use crate::services::group::{default_group_configuration, Group, GroupConfigurationDelegate, GroupService};
|
||||
use flowy_grid_data_model::revision::{FieldRevision, GroupConfigurationRevision, RowRevision};
|
||||
use flowy_revision::{RevisionCloudService, RevisionManager, RevisionObjectBuilder};
|
||||
use flowy_sync::client_grid::{GridViewRevisionChangeset, GridViewRevisionPad};
|
||||
use flowy_sync::entities::revision::Revision;
|
||||
|
||||
use crate::dart_notification::{send_dart_notification, GridNotification};
|
||||
use crate::services::setting::make_grid_setting;
|
||||
use flowy_sync::entities::grid::GridSettingChangesetParams;
|
||||
use lib_infra::future::{wrap_future, AFFuture, FutureResult};
|
||||
@ -19,7 +22,7 @@ pub trait GridViewRevisionDelegate: Send + Sync + 'static {
|
||||
fn get_field_rev(&self, field_id: &str) -> AFFuture<Option<Arc<FieldRevision>>>;
|
||||
}
|
||||
|
||||
pub trait GridViewRevisionDataSource: Send + Sync + 'static {
|
||||
pub trait GridViewRevisionRowDataSource: Send + Sync + 'static {
|
||||
fn row_revs(&self) -> AFFuture<Vec<Arc<RowRevision>>>;
|
||||
}
|
||||
|
||||
@ -30,8 +33,9 @@ pub struct GridViewRevisionEditor {
|
||||
pad: Arc<RwLock<GridViewRevisionPad>>,
|
||||
rev_manager: Arc<RevisionManager>,
|
||||
delegate: Arc<dyn GridViewRevisionDelegate>,
|
||||
data_source: Arc<dyn GridViewRevisionDataSource>,
|
||||
data_source: Arc<dyn GridViewRevisionRowDataSource>,
|
||||
group_service: Arc<RwLock<GroupService>>,
|
||||
groups: Arc<RwLock<Vec<Group>>>,
|
||||
scheduler: Arc<dyn GridServiceTaskScheduler>,
|
||||
}
|
||||
|
||||
@ -47,7 +51,7 @@ impl GridViewRevisionEditor {
|
||||
) -> FlowyResult<Self>
|
||||
where
|
||||
Delegate: GridViewRevisionDelegate,
|
||||
DataSource: GridViewRevisionDataSource,
|
||||
DataSource: GridViewRevisionRowDataSource,
|
||||
{
|
||||
let cloud = Arc::new(GridViewRevisionCloudService {
|
||||
token: token.to_owned(),
|
||||
@ -57,52 +61,85 @@ impl GridViewRevisionEditor {
|
||||
let rev_manager = Arc::new(rev_manager);
|
||||
let group_service = GroupService::new(Box::new(pad.clone())).await;
|
||||
let user_id = user_id.to_owned();
|
||||
let groups = Arc::new(RwLock::new(vec![]));
|
||||
Ok(Self {
|
||||
pad,
|
||||
user_id,
|
||||
view_id,
|
||||
rev_manager,
|
||||
scheduler,
|
||||
groups,
|
||||
delegate: Arc::new(delegate),
|
||||
data_source: Arc::new(data_source),
|
||||
group_service: Arc::new(RwLock::new(group_service)),
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) async fn create_row(&self, row_rev: &mut RowRevision, params: &CreateRowParams) {
|
||||
match params.group_id.as_ref() {
|
||||
None => {}
|
||||
Some(group_id) => {
|
||||
self.group_service
|
||||
.read()
|
||||
.await
|
||||
.update_row(row_rev, group_id, |field_id| self.delegate.get_field_rev(&field_id))
|
||||
.await;
|
||||
pub(crate) async fn update_row(&self, row_rev: &mut RowRevision, params: &CreateRowParams) {
|
||||
match params.layout {
|
||||
GridLayout::Table => {
|
||||
// Table can be grouped too
|
||||
}
|
||||
GridLayout::Board => match params.group_id.as_ref() {
|
||||
None => {}
|
||||
Some(group_id) => {
|
||||
self.group_service
|
||||
.read()
|
||||
.await
|
||||
.update_row(row_rev, group_id, |field_id| self.delegate.get_field_rev(&field_id))
|
||||
.await;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub(crate) async fn did_create_row(&self, row_pb: &RowPB, params: &CreateRowParams) {
|
||||
// Send the group notification if the current view has groups
|
||||
match params.group_id.as_ref() {
|
||||
None => {}
|
||||
Some(group_id) => {
|
||||
self.group_service.read().await.did_create_row(group_id, row_pb).await;
|
||||
let changeset = GroupRowsChangesetPB::insert(group_id.clone(), vec![row_pb.clone()]);
|
||||
self.notify_did_update_group(changeset).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn delete_row(&self, row_id: &str) {
|
||||
self.group_service.read().await.did_delete_card(row_id.to_owned()).await;
|
||||
pub(crate) async fn did_delete_row(&self, row_id: &str) {
|
||||
// Send the group notification if the current view has groups;
|
||||
match self.group_id_of_row(row_id).await {
|
||||
None => {}
|
||||
Some(group_id) => {
|
||||
let changeset = GroupRowsChangesetPB::delete(group_id, vec![row_id.to_owned()]);
|
||||
self.notify_did_update_group(changeset).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn group_id_of_row(&self, row_id: &str) -> Option<String> {
|
||||
let read_guard = self.groups.read().await;
|
||||
for group in read_guard.iter() {
|
||||
if group.rows.iter().find(|row| row.id == row_id).is_some() {
|
||||
return Some(group.id.clone());
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
pub(crate) async fn load_groups(&self) -> FlowyResult<Vec<GroupPB>> {
|
||||
let field_revs = self.delegate.get_field_revs().await;
|
||||
let row_revs = self.data_source.row_revs().await;
|
||||
|
||||
//
|
||||
let mut write_guard = self.group_service.write().await;
|
||||
match write_guard.load_groups(&field_revs, row_revs).await {
|
||||
None => Ok(vec![]),
|
||||
Some(groups) => Ok(groups),
|
||||
Some(groups) => {
|
||||
*self.groups.write().await = groups.clone();
|
||||
Ok(groups.into_iter().map(GroupPB::from).collect())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,6 +166,12 @@ impl GridViewRevisionEditor {
|
||||
}
|
||||
}
|
||||
|
||||
async fn notify_did_update_group(&self, changeset: GroupRowsChangesetPB) {
|
||||
send_dart_notification(&changeset.group_id, GridNotification::DidUpdateBoard)
|
||||
.payload(changeset)
|
||||
.send();
|
||||
}
|
||||
|
||||
async fn modify<F>(&self, f: F) -> FlowyResult<()>
|
||||
where
|
||||
F: for<'a> FnOnce(&'a mut GridViewRevisionPad) -> FlowyResult<Option<GridViewRevisionChangeset>>,
|
||||
|
@ -1,8 +1,12 @@
|
||||
use crate::entities::{CreateRowParams, GridFilterConfiguration, GridSettingPB, RepeatedGridGroupPB, RowPB};
|
||||
use crate::entities::{
|
||||
CreateRowParams, GridFilterConfiguration, GridLayout, GridSettingPB, MoveRowParams, RepeatedGridGroupPB, RowPB,
|
||||
};
|
||||
use crate::manager::GridUser;
|
||||
use crate::services::block_manager::GridBlockManager;
|
||||
use crate::services::grid_editor_task::GridServiceTaskScheduler;
|
||||
use crate::services::grid_view_editor::{GridViewRevisionDataSource, GridViewRevisionDelegate, GridViewRevisionEditor};
|
||||
use crate::services::grid_view_editor::{
|
||||
GridViewRevisionDelegate, GridViewRevisionEditor, GridViewRevisionRowDataSource,
|
||||
};
|
||||
use bytes::Bytes;
|
||||
use dashmap::DashMap;
|
||||
use flowy_error::FlowyResult;
|
||||
@ -45,7 +49,7 @@ impl GridViewManager {
|
||||
|
||||
pub(crate) async fn update_row(&self, row_rev: &mut RowRevision, params: &CreateRowParams) {
|
||||
for view_editor in self.view_editors.iter() {
|
||||
view_editor.create_row(row_rev, params).await;
|
||||
view_editor.update_row(row_rev, params).await;
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,9 +59,9 @@ impl GridViewManager {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn delete_row(&self, row_id: &str) {
|
||||
pub(crate) async fn did_delete_row(&self, row_id: &str) {
|
||||
for view_editor in self.view_editors.iter() {
|
||||
view_editor.delete_row(row_id).await;
|
||||
view_editor.did_delete_row(row_id).await;
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,15 +87,35 @@ impl GridViewManager {
|
||||
Ok(RepeatedGridGroupPB { items: groups })
|
||||
}
|
||||
|
||||
pub(crate) async fn move_row(&self, row_id: &str, from: i32, to: i32) -> FlowyResult<()> {
|
||||
match self.block_manager.get_row_rev(row_id).await? {
|
||||
pub(crate) async fn move_row(&self, params: MoveRowParams) -> FlowyResult<()> {
|
||||
let MoveRowParams {
|
||||
view_id: _,
|
||||
row_id,
|
||||
from_index,
|
||||
to_index,
|
||||
layout,
|
||||
upper_row_id,
|
||||
} = params;
|
||||
|
||||
let from_index = from_index as usize;
|
||||
|
||||
match self.block_manager.get_row_rev(&row_id).await? {
|
||||
None => tracing::warn!("Move row failed, can not find the row:{}", row_id),
|
||||
Some(row_rev) => {
|
||||
let _ = self
|
||||
.block_manager
|
||||
.move_row(row_rev.clone(), from as usize, to as usize)
|
||||
.await?;
|
||||
}
|
||||
Some(row_rev) => match layout {
|
||||
GridLayout::Table => {
|
||||
tracing::trace!("Move row from {} to {}", from_index, to_index);
|
||||
let to_index = to_index as usize;
|
||||
let _ = self.block_manager.move_row(row_rev, from_index, to_index).await?;
|
||||
}
|
||||
GridLayout::Board => {
|
||||
if let Some(upper_row_id) = upper_row_id {
|
||||
if let Some(to_index) = self.block_manager.index_of_row(&upper_row_id).await {
|
||||
tracing::trace!("Move row from {} to {}", from_index, to_index);
|
||||
let _ = self.block_manager.move_row(row_rev, from_index, to_index).await?;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@ -132,7 +156,7 @@ async fn make_view_editor<Delegate, DataSource>(
|
||||
) -> FlowyResult<GridViewRevisionEditor>
|
||||
where
|
||||
Delegate: GridViewRevisionDelegate,
|
||||
DataSource: GridViewRevisionDataSource,
|
||||
DataSource: GridViewRevisionRowDataSource,
|
||||
{
|
||||
tracing::trace!("Open view:{} editor", view_id);
|
||||
|
||||
@ -170,7 +194,7 @@ impl RevisionCompactor for GridViewRevisionCompactor {
|
||||
}
|
||||
}
|
||||
|
||||
impl GridViewRevisionDataSource for Arc<GridBlockManager> {
|
||||
impl GridViewRevisionRowDataSource for Arc<GridBlockManager> {
|
||||
fn row_revs(&self) -> AFFuture<Vec<Arc<RowRevision>>> {
|
||||
let block_manager = self.clone();
|
||||
|
||||
|
@ -22,7 +22,7 @@ impl GroupActionHandler for CheckboxGroupController {
|
||||
&self.field_id
|
||||
}
|
||||
|
||||
fn get_groups(&self) -> Vec<Group> {
|
||||
fn build_groups(&self) -> Vec<Group> {
|
||||
self.make_groups()
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ pub trait Groupable {
|
||||
|
||||
pub trait GroupActionHandler: Send + Sync {
|
||||
fn field_id(&self) -> &str;
|
||||
fn get_groups(&self) -> Vec<Group>;
|
||||
fn build_groups(&self) -> Vec<Group>;
|
||||
fn group_rows(&mut self, row_revs: &[Arc<RowRevision>], field_rev: &FieldRevision) -> FlowyResult<()>;
|
||||
fn update_card(&self, row_rev: &mut RowRevision, field_rev: &FieldRevision, group_id: &str);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ impl GroupActionHandler for SingleSelectGroupController {
|
||||
&self.field_id
|
||||
}
|
||||
|
||||
fn get_groups(&self) -> Vec<Group> {
|
||||
fn build_groups(&self) -> Vec<Group> {
|
||||
self.make_groups()
|
||||
}
|
||||
|
||||
@ -94,7 +94,7 @@ impl GroupActionHandler for MultiSelectGroupController {
|
||||
&self.field_id
|
||||
}
|
||||
|
||||
fn get_groups(&self) -> Vec<Group> {
|
||||
fn build_groups(&self) -> Vec<Group> {
|
||||
self.make_groups()
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
use crate::dart_notification::{send_dart_notification, GridNotification};
|
||||
use crate::entities::{
|
||||
BoardCardChangesetPB, CheckboxGroupConfigurationPB, DateGroupConfigurationPB, FieldType, GroupPB,
|
||||
CheckboxGroupConfigurationPB, DateGroupConfigurationPB, FieldType, GroupPB, GroupRowsChangesetPB,
|
||||
NumberGroupConfigurationPB, RowPB, SelectOptionGroupConfigurationPB, TextGroupConfigurationPB,
|
||||
UrlGroupConfigurationPB,
|
||||
};
|
||||
use crate::services::group::{
|
||||
CheckboxGroupController, GroupActionHandler, MultiSelectGroupController, SingleSelectGroupController,
|
||||
CheckboxGroupController, Group, GroupActionHandler, MultiSelectGroupController, SingleSelectGroupController,
|
||||
};
|
||||
use bytes::Bytes;
|
||||
use flowy_error::FlowyResult;
|
||||
@ -36,7 +36,7 @@ impl GroupService {
|
||||
&mut self,
|
||||
field_revs: &[Arc<FieldRevision>],
|
||||
row_revs: Vec<Arc<RowRevision>>,
|
||||
) -> Option<Vec<GroupPB>> {
|
||||
) -> Option<Vec<Group>> {
|
||||
let field_rev = find_group_field(field_revs).unwrap();
|
||||
let field_type: FieldType = field_rev.field_type_rev.into();
|
||||
let configuration = self.delegate.get_group_configuration(field_rev.clone()).await;
|
||||
@ -79,26 +79,6 @@ impl GroupService {
|
||||
// let row_pb = make_row_from_row_rev(row_rev);
|
||||
todo!()
|
||||
}
|
||||
#[allow(dead_code)]
|
||||
pub async fn did_delete_card(&self, _row_id: String) {
|
||||
// let changeset = BoardCardChangesetPB::delete(group_id.to_owned(), vec![row_id]);
|
||||
// self.notify_did_update_board(changeset).await;
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub async fn did_create_row(&self, group_id: &str, row_pb: &RowPB) {
|
||||
let changeset = BoardCardChangesetPB::insert(group_id.to_owned(), vec![row_pb.clone()]);
|
||||
self.notify_did_update_board(changeset).await;
|
||||
}
|
||||
|
||||
pub async fn notify_did_update_board(&self, changeset: BoardCardChangesetPB) {
|
||||
if self.action_handler.is_none() {
|
||||
return;
|
||||
}
|
||||
send_dart_notification(&changeset.group_id, GridNotification::DidUpdateBoard)
|
||||
.payload(changeset)
|
||||
.send();
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "trace", skip_all, err)]
|
||||
async fn build_groups(
|
||||
@ -107,7 +87,7 @@ impl GroupService {
|
||||
field_rev: &Arc<FieldRevision>,
|
||||
row_revs: Vec<Arc<RowRevision>>,
|
||||
configuration: GroupConfigurationRevision,
|
||||
) -> FlowyResult<Vec<GroupPB>> {
|
||||
) -> FlowyResult<Vec<Group>> {
|
||||
match field_type {
|
||||
FieldType::RichText => {
|
||||
// let generator = GroupGenerator::<TextGroupConfigurationPB>::from_configuration(configuration);
|
||||
@ -139,11 +119,11 @@ impl GroupService {
|
||||
if let Some(group_action_handler) = self.action_handler.as_ref() {
|
||||
let mut write_guard = group_action_handler.write().await;
|
||||
let _ = write_guard.group_rows(&row_revs, field_rev)?;
|
||||
groups = write_guard.get_groups();
|
||||
groups = write_guard.build_groups();
|
||||
drop(write_guard);
|
||||
}
|
||||
|
||||
Ok(groups.into_iter().map(GroupPB::from).collect())
|
||||
Ok(groups)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::entities::{
|
||||
GridLayoutPB, GridSettingPB, Layout, RepeatedGridConfigurationFilterPB, RepeatedGridGroupConfigurationPB,
|
||||
GridLayout, GridLayoutPB, GridSettingPB, RepeatedGridConfigurationFilterPB, RepeatedGridGroupConfigurationPB,
|
||||
RepeatedGridSortPB,
|
||||
};
|
||||
use flowy_grid_data_model::revision::{FieldRevision, SettingRevision};
|
||||
@ -12,7 +12,7 @@ pub struct GridSettingChangesetBuilder {
|
||||
}
|
||||
|
||||
impl GridSettingChangesetBuilder {
|
||||
pub fn new(grid_id: &str, layout_type: &Layout) -> Self {
|
||||
pub fn new(grid_id: &str, layout_type: &GridLayout) -> Self {
|
||||
let params = GridSettingChangesetParams {
|
||||
grid_id: grid_id.to_string(),
|
||||
layout_type: layout_type.clone().into(),
|
||||
@ -42,7 +42,7 @@ impl GridSettingChangesetBuilder {
|
||||
}
|
||||
|
||||
pub fn make_grid_setting(grid_setting_rev: &SettingRevision, field_revs: &[Arc<FieldRevision>]) -> GridSettingPB {
|
||||
let current_layout_type: Layout = grid_setting_rev.layout.clone().into();
|
||||
let current_layout_type: GridLayout = grid_setting_rev.layout.clone().into();
|
||||
let filters_by_field_id = grid_setting_rev
|
||||
.get_all_filters(field_revs)
|
||||
.map(|filters_by_field_id| {
|
||||
|
@ -2,7 +2,7 @@ use crate::grid::block_test::script::RowScript::{AssertCell, CreateRow};
|
||||
use crate::grid::block_test::util::GridRowTestBuilder;
|
||||
use crate::grid::grid_editor::GridEditorTest;
|
||||
|
||||
use flowy_grid::entities::{CreateRowParams, FieldType, GridCellIdParams, RowPB};
|
||||
use flowy_grid::entities::{CreateRowParams, FieldType, GridCellIdParams, GridLayout, RowPB};
|
||||
use flowy_grid::services::field::*;
|
||||
use flowy_grid_data_model::revision::{
|
||||
GridBlockMetaRevision, GridBlockMetaRevisionChangeset, RowMetaChangeset, RowRevision,
|
||||
@ -81,6 +81,7 @@ impl GridRowTest {
|
||||
grid_id: self.editor.grid_id.clone(),
|
||||
start_row_id: None,
|
||||
group_id: None,
|
||||
layout: GridLayout::Table,
|
||||
};
|
||||
let row_order = self.editor.create_row(params).await.unwrap();
|
||||
self.row_order_by_row_id
|
||||
|
@ -3,7 +3,7 @@
|
||||
#![allow(dead_code)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use flowy_grid::entities::{CreateGridFilterPayloadPB, Layout, GridSettingPB};
|
||||
use flowy_grid::entities::{CreateGridFilterPayloadPB, GridLayout, GridSettingPB};
|
||||
use flowy_grid::services::setting::GridSettingChangesetBuilder;
|
||||
use flowy_grid_data_model::revision::{FieldRevision, FieldTypeRevision};
|
||||
use flowy_sync::entities::grid::{CreateGridFilterParams, DeleteFilterParams, GridSettingChangesetParams};
|
||||
@ -55,7 +55,7 @@ impl GridFilterTest {
|
||||
}
|
||||
FilterScript::InsertGridTableFilter { payload } => {
|
||||
let params: CreateGridFilterParams = payload.try_into().unwrap();
|
||||
let layout_type = Layout::Table;
|
||||
let layout_type = GridLayout::Table;
|
||||
let params = GridSettingChangesetBuilder::new(&self.grid_id, &layout_type)
|
||||
.insert_filter(params)
|
||||
.build();
|
||||
@ -66,7 +66,7 @@ impl GridFilterTest {
|
||||
assert_eq!(count as usize, filters.len());
|
||||
}
|
||||
FilterScript::DeleteGridTableFilter { filter_id, field_rev} => {
|
||||
let layout_type = Layout::Table;
|
||||
let layout_type = GridLayout::Table;
|
||||
let params = GridSettingChangesetBuilder::new(&self.grid_id, &layout_type)
|
||||
.delete_filter(DeleteFilterParams { field_id: field_rev.id, filter_id, field_type_rev: field_rev.field_type_rev })
|
||||
.build();
|
||||
|
@ -91,6 +91,9 @@ pub enum ErrorCode {
|
||||
|
||||
#[display(fmt = "Grid id is empty")]
|
||||
GridIdIsEmpty = 410,
|
||||
#[display(fmt = "Grid view id is empty")]
|
||||
GridViewIdIsEmpty = 411,
|
||||
|
||||
#[display(fmt = "Grid block id is empty")]
|
||||
BlockIdIsEmpty = 420,
|
||||
#[display(fmt = "Row id is empty")]
|
||||
|
@ -139,12 +139,8 @@ impl GridBlockRevisionPad {
|
||||
self.block.rows.len() as i32
|
||||
}
|
||||
|
||||
pub fn index_of_row(&self, row_id: &str) -> Option<i32> {
|
||||
self.block
|
||||
.rows
|
||||
.iter()
|
||||
.position(|row| row.id == row_id)
|
||||
.map(|index| index as i32)
|
||||
pub fn index_of_row(&self, row_id: &str) -> Option<usize> {
|
||||
self.block.rows.iter().position(|row| row.id == row_id)
|
||||
}
|
||||
|
||||
pub fn update_row(&mut self, changeset: RowMetaChangeset) -> CollaborateResult<Option<GridBlockRevisionChangeset>> {
|
||||
|
Loading…
Reference in New Issue
Block a user