mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: move card from one column to another
This commit is contained in:
2
frontend/.vscode/launch.json
vendored
2
frontend/.vscode/launch.json
vendored
@ -29,7 +29,7 @@
|
|||||||
"program": "./lib/main.dart",
|
"program": "./lib/main.dart",
|
||||||
"type": "dart",
|
"type": "dart",
|
||||||
"env": {
|
"env": {
|
||||||
"RUST_LOG": "debug"
|
"RUST_LOG": "trace"
|
||||||
},
|
},
|
||||||
"cwd": "${workspaceRoot}/app_flowy"
|
"cwd": "${workspaceRoot}/app_flowy"
|
||||||
},
|
},
|
||||||
|
@ -2,6 +2,7 @@ import 'dart:async';
|
|||||||
import 'package:app_flowy/plugins/grid/application/block/block_cache.dart';
|
import 'package:app_flowy/plugins/grid/application/block/block_cache.dart';
|
||||||
import 'package:app_flowy/plugins/grid/application/field/field_cache.dart';
|
import 'package:app_flowy/plugins/grid/application/field/field_cache.dart';
|
||||||
import 'package:app_flowy/plugins/grid/application/row/row_cache.dart';
|
import 'package:app_flowy/plugins/grid/application/row/row_cache.dart';
|
||||||
|
import 'package:app_flowy/plugins/grid/application/row/row_service.dart';
|
||||||
import 'package:appflowy_board/appflowy_board.dart';
|
import 'package:appflowy_board/appflowy_board.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
@ -21,13 +22,15 @@ part 'board_bloc.freezed.dart';
|
|||||||
class BoardBloc extends Bloc<BoardEvent, BoardState> {
|
class BoardBloc extends Bloc<BoardEvent, BoardState> {
|
||||||
final BoardDataController _dataController;
|
final BoardDataController _dataController;
|
||||||
late final AFBoardDataController afBoardDataController;
|
late final AFBoardDataController afBoardDataController;
|
||||||
|
final MoveRowFFIService _rowService;
|
||||||
Map<String, GroupController> groupControllers = {};
|
Map<String, GroupController> groupControllers = {};
|
||||||
|
|
||||||
GridFieldCache get fieldCache => _dataController.fieldCache;
|
GridFieldCache get fieldCache => _dataController.fieldCache;
|
||||||
String get gridId => _dataController.gridId;
|
String get gridId => _dataController.gridId;
|
||||||
|
|
||||||
BoardBloc({required ViewPB view})
|
BoardBloc({required ViewPB view})
|
||||||
: _dataController = BoardDataController(view: view),
|
: _rowService = MoveRowFFIService(gridId: view.id),
|
||||||
|
_dataController = BoardDataController(view: view),
|
||||||
super(BoardState.initial(view.id)) {
|
super(BoardState.initial(view.id)) {
|
||||||
afBoardDataController = AFBoardDataController(
|
afBoardDataController = AFBoardDataController(
|
||||||
onMoveColumn: (
|
onMoveColumn: (
|
||||||
@ -39,7 +42,9 @@ class BoardBloc extends Bloc<BoardEvent, BoardState> {
|
|||||||
fromIndex,
|
fromIndex,
|
||||||
toIndex,
|
toIndex,
|
||||||
) {
|
) {
|
||||||
groupControllers[columnId]?.moveRow(fromIndex, toIndex);
|
final fromRow = groupControllers[columnId]?.rowAtIndex(fromIndex);
|
||||||
|
final toRow = groupControllers[columnId]?.rowAtIndex(toIndex);
|
||||||
|
_moveRow(fromRow, toRow);
|
||||||
},
|
},
|
||||||
onMoveColumnItemToColumn: (
|
onMoveColumnItemToColumn: (
|
||||||
fromColumnId,
|
fromColumnId,
|
||||||
@ -47,7 +52,9 @@ class BoardBloc extends Bloc<BoardEvent, BoardState> {
|
|||||||
toColumnId,
|
toColumnId,
|
||||||
toIndex,
|
toIndex,
|
||||||
) {
|
) {
|
||||||
//
|
final fromRow = groupControllers[fromColumnId]?.rowAtIndex(fromIndex);
|
||||||
|
final toRow = groupControllers[toColumnId]?.rowAtIndex(toIndex);
|
||||||
|
_moveRow(fromRow, toRow);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -80,11 +87,27 @@ class BoardBloc extends Bloc<BoardEvent, BoardState> {
|
|||||||
didReceiveRows: (List<RowInfo> rowInfos) {
|
didReceiveRows: (List<RowInfo> rowInfos) {
|
||||||
emit(state.copyWith(rowInfos: rowInfos));
|
emit(state.copyWith(rowInfos: rowInfos));
|
||||||
},
|
},
|
||||||
|
didReceiveError: (FlowyError error) {
|
||||||
|
emit(state.copyWith(noneOrError: some(error)));
|
||||||
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _moveRow(RowPB? fromRow, RowPB? toRow) {
|
||||||
|
if (fromRow != null && toRow != null) {
|
||||||
|
_rowService
|
||||||
|
.moveRow(
|
||||||
|
fromRowId: fromRow.id,
|
||||||
|
toRowId: toRow.id,
|
||||||
|
)
|
||||||
|
.then((result) {
|
||||||
|
result.fold((l) => null, (r) => add(BoardEvent.didReceiveError(r)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> close() async {
|
Future<void> close() async {
|
||||||
await _dataController.dispose();
|
await _dataController.dispose();
|
||||||
@ -167,6 +190,7 @@ class BoardEvent with _$BoardEvent {
|
|||||||
const factory BoardEvent.initial() = InitialGrid;
|
const factory BoardEvent.initial() = InitialGrid;
|
||||||
const factory BoardEvent.createRow(String groupId) = _CreateRow;
|
const factory BoardEvent.createRow(String groupId) = _CreateRow;
|
||||||
const factory BoardEvent.endEditRow(String rowId) = _EndEditRow;
|
const factory BoardEvent.endEditRow(String rowId) = _EndEditRow;
|
||||||
|
const factory BoardEvent.didReceiveError(FlowyError error) = _DidReceiveError;
|
||||||
const factory BoardEvent.didReceiveRows(List<RowInfo> rowInfos) =
|
const factory BoardEvent.didReceiveRows(List<RowInfo> rowInfos) =
|
||||||
_DidReceiveRows;
|
_DidReceiveRows;
|
||||||
const factory BoardEvent.didReceiveGridUpdate(
|
const factory BoardEvent.didReceiveGridUpdate(
|
||||||
@ -182,6 +206,7 @@ class BoardState with _$BoardState {
|
|||||||
required Option<RowPB> editingRow,
|
required Option<RowPB> editingRow,
|
||||||
required List<RowInfo> rowInfos,
|
required List<RowInfo> rowInfos,
|
||||||
required GridLoadingState loadingState,
|
required GridLoadingState loadingState,
|
||||||
|
required Option<FlowyError> noneOrError,
|
||||||
}) = _BoardState;
|
}) = _BoardState;
|
||||||
|
|
||||||
factory BoardState.initial(String gridId) => BoardState(
|
factory BoardState.initial(String gridId) => BoardState(
|
||||||
@ -189,6 +214,7 @@ class BoardState with _$BoardState {
|
|||||||
grid: none(),
|
grid: none(),
|
||||||
gridId: gridId,
|
gridId: gridId,
|
||||||
editingRow: none(),
|
editingRow: none(),
|
||||||
|
noneOrError: none(),
|
||||||
loadingState: const _Loading(),
|
loadingState: const _Loading(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import 'package:app_flowy/plugins/grid/application/row/row_service.dart';
|
|
||||||
import 'package:flowy_sdk/log.dart';
|
import 'package:flowy_sdk/log.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-grid/protobuf.dart';
|
import 'package:flowy_sdk/protobuf/flowy-grid/protobuf.dart';
|
||||||
@ -16,36 +15,23 @@ abstract class GroupControllerDelegate {
|
|||||||
class GroupController {
|
class GroupController {
|
||||||
final GroupPB group;
|
final GroupPB group;
|
||||||
final GroupListener _listener;
|
final GroupListener _listener;
|
||||||
final MoveRowFFIService _rowService;
|
|
||||||
final GroupControllerDelegate delegate;
|
final GroupControllerDelegate delegate;
|
||||||
OnGroupError? _onError;
|
|
||||||
|
|
||||||
GroupController({
|
GroupController({
|
||||||
required String gridId,
|
required String gridId,
|
||||||
required this.group,
|
required this.group,
|
||||||
required this.delegate,
|
required this.delegate,
|
||||||
}) : _rowService = MoveRowFFIService(gridId: gridId),
|
}) : _listener = GroupListener(group);
|
||||||
_listener = GroupListener(group);
|
|
||||||
|
|
||||||
Future<void> moveRow(int fromIndex, int toIndex) async {
|
RowPB? rowAtIndex(int index) {
|
||||||
if (fromIndex < group.rows.length && toIndex < group.rows.length) {
|
if (index < group.rows.length) {
|
||||||
final fromRow = group.rows[fromIndex];
|
return group.rows[index];
|
||||||
final toRow = group.rows[toIndex];
|
} else {
|
||||||
|
return null;
|
||||||
final result = await _rowService.moveRow(
|
|
||||||
rowId: fromRow.id,
|
|
||||||
fromIndex: fromIndex,
|
|
||||||
toIndex: toIndex,
|
|
||||||
upperRowId: toRow.id,
|
|
||||||
layout: GridLayout.Board,
|
|
||||||
);
|
|
||||||
|
|
||||||
result.fold((l) => null, (r) => _onError?.call(r));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void startListening({OnGroupError? onError}) {
|
void startListening() {
|
||||||
_onError = onError;
|
|
||||||
_listener.start(onGroupChanged: (result) {
|
_listener.start(onGroupChanged: (result) {
|
||||||
result.fold(
|
result.fold(
|
||||||
(GroupRowsChangesetPB changeset) {
|
(GroupRowsChangesetPB changeset) {
|
||||||
|
@ -4,7 +4,6 @@ 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/block_entities.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-grid/grid_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/row_entities.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-grid/setting_entities.pb.dart';
|
|
||||||
|
|
||||||
class RowFFIService {
|
class RowFFIService {
|
||||||
final String gridId;
|
final String gridId;
|
||||||
@ -23,27 +22,6 @@ class RowFFIService {
|
|||||||
return GridEventCreateTableRow(payload).send();
|
return GridEventCreateTableRow(payload).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
if (upperRowId != null) {
|
|
||||||
payload.upperRowId = upperRowId;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GridEventMoveRow(payload).send();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<Either<OptionalRowPB, FlowyError>> getRow(String rowId) {
|
Future<Either<OptionalRowPB, FlowyError>> getRow(String rowId) {
|
||||||
final payload = RowIdPB.create()
|
final payload = RowIdPB.create()
|
||||||
..gridId = gridId
|
..gridId = gridId
|
||||||
@ -80,22 +58,13 @@ class MoveRowFFIService {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Future<Either<Unit, FlowyError>> moveRow({
|
Future<Either<Unit, FlowyError>> moveRow({
|
||||||
required String rowId,
|
required String fromRowId,
|
||||||
required int fromIndex,
|
required String toRowId,
|
||||||
required int toIndex,
|
|
||||||
required GridLayout layout,
|
|
||||||
String? upperRowId,
|
|
||||||
}) {
|
}) {
|
||||||
var payload = MoveRowPayloadPB.create()
|
var payload = MoveRowPayloadPB.create()
|
||||||
..viewId = gridId
|
..viewId = gridId
|
||||||
..rowId = rowId
|
..fromRowId = fromRowId
|
||||||
..layout = layout
|
..toRowId = toRowId;
|
||||||
..fromIndex = fromIndex
|
|
||||||
..toIndex = toIndex;
|
|
||||||
|
|
||||||
if (upperRowId != null) {
|
|
||||||
payload.upperRowId = upperRowId;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GridEventMoveRow(payload).send();
|
return GridEventMoveRow(payload).send();
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ const DART_LOG = "Dart_LOG";
|
|||||||
class Log {
|
class Log {
|
||||||
// static const enableLog = bool.hasEnvironment(DART_LOG);
|
// static const enableLog = bool.hasEnvironment(DART_LOG);
|
||||||
// static final shared = Log();
|
// static final shared = Log();
|
||||||
static const enableLog = true;
|
static const enableLog = false;
|
||||||
|
|
||||||
static void info(String? message) {
|
static void info(String? message) {
|
||||||
if (enableLog) {
|
if (enableLog) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use crate::entities::{BlockPB, FieldIdPB, GridLayout};
|
use crate::entities::{BlockPB, FieldIdPB};
|
||||||
use flowy_derive::ProtoBuf;
|
use flowy_derive::ProtoBuf;
|
||||||
use flowy_error::ErrorCode;
|
use flowy_error::ErrorCode;
|
||||||
use flowy_grid_data_model::parser::NotEmptyStr;
|
use flowy_grid_data_model::parser::NotEmptyStr;
|
||||||
@ -98,24 +98,13 @@ pub struct MoveRowPayloadPB {
|
|||||||
#[pb(index = 2)]
|
#[pb(index = 2)]
|
||||||
pub from_row_id: String,
|
pub from_row_id: String,
|
||||||
|
|
||||||
// #[pb(index = 3)]
|
#[pb(index = 4)]
|
||||||
// pub from_index: i32,
|
|
||||||
//
|
|
||||||
// #[pb(index = 4)]
|
|
||||||
// pub to_index: i32,
|
|
||||||
#[pb(index = 5)]
|
|
||||||
pub layout: GridLayout,
|
|
||||||
|
|
||||||
#[pb(index = 6)]
|
|
||||||
pub to_row_id: String,
|
pub to_row_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct MoveRowParams {
|
pub struct MoveRowParams {
|
||||||
pub view_id: String,
|
pub view_id: String,
|
||||||
pub from_row_id: String,
|
pub from_row_id: String,
|
||||||
// pub from_index: i32,
|
|
||||||
// pub to_index: i32,
|
|
||||||
pub layout: GridLayout,
|
|
||||||
pub to_row_id: String,
|
pub to_row_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,17 +115,11 @@ impl TryInto<MoveRowParams> for MoveRowPayloadPB {
|
|||||||
let view_id = NotEmptyStr::parse(self.view_id).map_err(|_| ErrorCode::GridViewIdIsEmpty)?;
|
let view_id = NotEmptyStr::parse(self.view_id).map_err(|_| ErrorCode::GridViewIdIsEmpty)?;
|
||||||
let from_row_id = NotEmptyStr::parse(self.from_row_id).map_err(|_| ErrorCode::RowIdIsEmpty)?;
|
let from_row_id = NotEmptyStr::parse(self.from_row_id).map_err(|_| ErrorCode::RowIdIsEmpty)?;
|
||||||
let to_row_id = NotEmptyStr::parse(self.to_row_id).map_err(|_| ErrorCode::RowIdIsEmpty)?;
|
let to_row_id = NotEmptyStr::parse(self.to_row_id).map_err(|_| ErrorCode::RowIdIsEmpty)?;
|
||||||
let upper_row_id = match self.to_row_id {
|
|
||||||
None => None,
|
|
||||||
Some(upper_row_id) => Some(NotEmptyStr::parse(upper_row_id).map_err(|_| ErrorCode::RowIdIsEmpty)?.0),
|
|
||||||
};
|
|
||||||
Ok(MoveRowParams {
|
Ok(MoveRowParams {
|
||||||
view_id: view_id.0,
|
view_id: view_id.0,
|
||||||
from_row_id: from_row_id.0,
|
from_row_id: from_row_id.0,
|
||||||
// from_index: self.from_index,
|
to_row_id: to_row_id.0,
|
||||||
// to_index: self.to_index,
|
|
||||||
layout: self.layout,
|
|
||||||
to_row_id: upper_row_id,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::services::block_manager::GridBlockManager;
|
use crate::services::block_manager::GridBlockManager;
|
||||||
use crate::services::grid_view_manager::GridViewRowDelegate;
|
use crate::services::grid_view_manager::GridViewRowDelegate;
|
||||||
use flowy_error::FlowyResult;
|
|
||||||
use flowy_grid_data_model::revision::RowRevision;
|
use flowy_grid_data_model::revision::RowRevision;
|
||||||
use lib_infra::future::{wrap_future, AFFuture};
|
use lib_infra::future::{wrap_future, AFFuture};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
@ -495,38 +495,29 @@ impl GridRevisionEditor {
|
|||||||
pub async fn move_row(&self, params: MoveRowParams) -> FlowyResult<()> {
|
pub async fn move_row(&self, params: MoveRowParams) -> FlowyResult<()> {
|
||||||
let MoveRowParams {
|
let MoveRowParams {
|
||||||
view_id: _,
|
view_id: _,
|
||||||
from_row_id: row_id,
|
from_row_id,
|
||||||
from_index,
|
to_row_id,
|
||||||
to_index,
|
|
||||||
layout: _,
|
|
||||||
to_row_id: upper_row_id,
|
|
||||||
} = params;
|
} = params;
|
||||||
|
|
||||||
let from_index = from_index as usize;
|
match self.block_manager.get_row_rev(&from_row_id).await? {
|
||||||
let to_index = to_index as usize;
|
None => tracing::warn!("Move row failed, can not find the row:{}", from_row_id),
|
||||||
|
Some(row_rev) => {
|
||||||
match self.block_manager.get_row_rev(&row_id).await? {
|
match (
|
||||||
None => tracing::warn!("Move row failed, can not find the row:{}", row_id),
|
self.block_manager.index_of_row(&from_row_id).await,
|
||||||
Some(row_rev) => match upper_row_id {
|
self.block_manager.index_of_row(&to_row_id).await,
|
||||||
None => {
|
) {
|
||||||
tracing::trace!("Move row from {} to {}", from_index, to_index);
|
(Some(from_index), Some(to_index)) => {
|
||||||
let _ = self
|
tracing::trace!("Move row from {} to {}", from_index, to_index);
|
||||||
.block_manager
|
|
||||||
.move_row(row_rev.clone(), from_index, to_index)
|
|
||||||
.await?;
|
|
||||||
}
|
|
||||||
Some(to_row_id) => match self.block_manager.index_of_row(&to_row_id).await {
|
|
||||||
None => tracing::error!("Can not find the row: {} when moving the row", to_row_id),
|
|
||||||
Some(to_row_index) => {
|
|
||||||
tracing::trace!("Move row from {} to {}", from_index, to_row_index);
|
|
||||||
let _ = self
|
let _ = self
|
||||||
.block_manager
|
.block_manager
|
||||||
.move_row(row_rev.clone(), from_index, to_row_index)
|
.move_row(row_rev.clone(), from_index, to_index)
|
||||||
.await?;
|
.await?;
|
||||||
self.view_manager.move_row(row_rev, to_row_id).await;
|
self.view_manager.move_row(row_rev, to_row_id.clone()).await;
|
||||||
}
|
}
|
||||||
},
|
(_, None) => tracing::error!("Can not find the from row id: {}", from_row_id),
|
||||||
},
|
(None, _) => tracing::error!("Can not find the to row id: {}", to_row_id),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
use crate::dart_notification::{send_dart_notification, GridNotification};
|
use crate::dart_notification::{send_dart_notification, GridNotification};
|
||||||
use crate::entities::{
|
use crate::entities::{
|
||||||
CreateRowParams, GridFilterConfiguration, GridLayout, GridSettingPB, GroupPB, GroupRowsChangesetPB, InsertedRowPB,
|
CreateRowParams, GridFilterConfiguration, GridSettingPB, GroupPB, GroupRowsChangesetPB, InsertedRowPB, RowPB,
|
||||||
RowPB,
|
|
||||||
};
|
};
|
||||||
use crate::services::grid_editor_task::GridServiceTaskScheduler;
|
use crate::services::grid_editor_task::GridServiceTaskScheduler;
|
||||||
use crate::services::grid_view_manager::{GridViewFieldDelegate, GridViewRowDelegate};
|
use crate::services::grid_view_manager::{GridViewFieldDelegate, GridViewRowDelegate};
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
use crate::entities::{
|
use crate::entities::{
|
||||||
CreateRowParams, GridFilterConfiguration, GridLayout, GridSettingPB, MoveRowParams, RepeatedGridGroupPB, RowPB,
|
CreateRowParams, GridFilterConfiguration, GridSettingPB, RepeatedGridGroupPB, RowPB,
|
||||||
};
|
};
|
||||||
use crate::manager::GridUser;
|
use crate::manager::GridUser;
|
||||||
|
|
||||||
use crate::services::grid_editor_task::GridServiceTaskScheduler;
|
use crate::services::grid_editor_task::GridServiceTaskScheduler;
|
||||||
use crate::services::grid_view_editor::GridViewRevisionEditor;
|
use crate::services::grid_view_editor::GridViewRevisionEditor;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
@ -11,7 +10,6 @@ use flowy_error::FlowyResult;
|
|||||||
use flowy_grid_data_model::revision::{FieldRevision, RowRevision};
|
use flowy_grid_data_model::revision::{FieldRevision, RowRevision};
|
||||||
use flowy_revision::disk::SQLiteGridViewRevisionPersistence;
|
use flowy_revision::disk::SQLiteGridViewRevisionPersistence;
|
||||||
use flowy_revision::{RevisionCompactor, RevisionManager, RevisionPersistence, SQLiteRevisionSnapshotPersistence};
|
use flowy_revision::{RevisionCompactor, RevisionManager, RevisionPersistence, SQLiteRevisionSnapshotPersistence};
|
||||||
|
|
||||||
use flowy_sync::entities::grid::GridSettingChangesetParams;
|
use flowy_sync::entities::grid::GridSettingChangesetParams;
|
||||||
use flowy_sync::entities::revision::Revision;
|
use flowy_sync::entities::revision::Revision;
|
||||||
use flowy_sync::util::make_text_delta_from_revisions;
|
use flowy_sync::util::make_text_delta_from_revisions;
|
||||||
|
@ -29,17 +29,17 @@ impl Groupable for CheckboxGroupController {
|
|||||||
|
|
||||||
fn remove_row_if_match(
|
fn remove_row_if_match(
|
||||||
&mut self,
|
&mut self,
|
||||||
row_rev: &RowRevision,
|
_row_rev: &RowRevision,
|
||||||
cell_data: &Self::CellDataType,
|
_cell_data: &Self::CellDataType,
|
||||||
) -> Vec<GroupRowsChangesetPB> {
|
) -> Vec<GroupRowsChangesetPB> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn move_row_if_match(
|
fn move_row_if_match(
|
||||||
&mut self,
|
&mut self,
|
||||||
row_rev: &RowRevision,
|
_row_rev: &RowRevision,
|
||||||
cell_data: &Self::CellDataType,
|
_cell_data: &Self::CellDataType,
|
||||||
to_row_id: &str,
|
_to_row_id: &str,
|
||||||
) -> Vec<GroupRowsChangesetPB> {
|
) -> Vec<GroupRowsChangesetPB> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
@ -177,15 +177,13 @@ fn add_row(
|
|||||||
row_rev: &RowRevision,
|
row_rev: &RowRevision,
|
||||||
) {
|
) {
|
||||||
cell_data.select_options.iter().for_each(|option| {
|
cell_data.select_options.iter().for_each(|option| {
|
||||||
if option.id == group.id {
|
if option.id == group.id && !group.contains_row(&row_rev.id) {
|
||||||
if !group.contains_row(&row_rev.id) {
|
let row_pb = RowPB::from(row_rev);
|
||||||
let row_pb = RowPB::from(row_rev);
|
changesets.push(GroupRowsChangesetPB::insert(
|
||||||
changesets.push(GroupRowsChangesetPB::insert(
|
group.id.clone(),
|
||||||
group.id.clone(),
|
vec![InsertedRowPB::new(row_pb.clone())],
|
||||||
vec![InsertedRowPB::new(row_pb.clone())],
|
));
|
||||||
));
|
group.add_row(row_pb);
|
||||||
group.add_row(row_pb);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -197,11 +195,9 @@ fn remove_row(
|
|||||||
row_rev: &RowRevision,
|
row_rev: &RowRevision,
|
||||||
) {
|
) {
|
||||||
cell_data.select_options.iter().for_each(|option| {
|
cell_data.select_options.iter().for_each(|option| {
|
||||||
if option.id == group.id {
|
if option.id == group.id && group.contains_row(&row_rev.id) {
|
||||||
if group.contains_row(&row_rev.id) {
|
changesets.push(GroupRowsChangesetPB::delete(group.id.clone(), vec![row_rev.id.clone()]));
|
||||||
changesets.push(GroupRowsChangesetPB::delete(group.id.clone(), vec![row_rev.id.clone()]));
|
group.remove_row(&row_rev.id);
|
||||||
group.remove_row(&row_rev.id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -214,11 +210,9 @@ fn move_row(
|
|||||||
upper_row_id: &str,
|
upper_row_id: &str,
|
||||||
) {
|
) {
|
||||||
cell_data.select_options.iter().for_each(|option| {
|
cell_data.select_options.iter().for_each(|option| {
|
||||||
if option.id == group.id {
|
if option.id == group.id && group.contains_row(&row_rev.id) {
|
||||||
if group.contains_row(&row_rev.id) {
|
changesets.push(GroupRowsChangesetPB::delete(group.id.clone(), vec![row_rev.id.clone()]));
|
||||||
changesets.push(GroupRowsChangesetPB::delete(group.id.clone(), vec![row_rev.id.clone()]));
|
group.remove_row(&row_rev.id);
|
||||||
group.remove_row(&row_rev.id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(index) = group.index_of_row(upper_row_id) {
|
if let Some(index) = group.index_of_row(upper_row_id) {
|
||||||
|
@ -179,7 +179,7 @@ impl GridBlockRevisionPad {
|
|||||||
debug_assert_eq!(from, position);
|
debug_assert_eq!(from, position);
|
||||||
let row_rev = row_revs.remove(position);
|
let row_rev = row_revs.remove(position);
|
||||||
if to > row_revs.len() {
|
if to > row_revs.len() {
|
||||||
return Err(CollaborateError::out_of_bound());
|
Err(CollaborateError::out_of_bound())
|
||||||
} else {
|
} else {
|
||||||
row_revs.insert(to, row_rev);
|
row_revs.insert(to, row_rev);
|
||||||
Ok(Some(()))
|
Ok(Some(()))
|
||||||
|
Reference in New Issue
Block a user