mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-09-11 11:15:53 +03:00
Feat/database view (#1765)
* chore: rename flowy-database to flowy-sqlite * refactor: rename flowy-grid to flowy-database * refactor: rename grid to database * refactor: rename GridEvent to DatabaseEvent * refactor: rename grid_id to database_id * refactor: rename dart code
This commit is contained in:
parent
5de3912fe3
commit
5b07656295
@ -3,37 +3,37 @@ import 'dart:typed_data';
|
||||
import 'package:appflowy_backend/protobuf/flowy-notification/protobuf.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/notification.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/notification.pb.dart';
|
||||
import 'package:appflowy_backend/rust_stream.dart';
|
||||
|
||||
import 'notification_helper.dart';
|
||||
|
||||
// GridPB
|
||||
typedef GridNotificationCallback = void Function(
|
||||
GridNotification, Either<Uint8List, FlowyError>);
|
||||
// DatabasePB
|
||||
typedef DatabaseNotificationCallback = void Function(
|
||||
DatabaseNotification, Either<Uint8List, FlowyError>);
|
||||
|
||||
class GridNotificationParser
|
||||
extends NotificationParser<GridNotification, FlowyError> {
|
||||
GridNotificationParser(
|
||||
{String? id, required GridNotificationCallback callback})
|
||||
class DatabaseNotificationParser
|
||||
extends NotificationParser<DatabaseNotification, FlowyError> {
|
||||
DatabaseNotificationParser(
|
||||
{String? id, required DatabaseNotificationCallback callback})
|
||||
: super(
|
||||
id: id,
|
||||
callback: callback,
|
||||
tyParser: (ty) => GridNotification.valueOf(ty),
|
||||
tyParser: (ty) => DatabaseNotification.valueOf(ty),
|
||||
errorParser: (bytes) => FlowyError.fromBuffer(bytes),
|
||||
);
|
||||
}
|
||||
|
||||
typedef GridNotificationHandler = Function(
|
||||
GridNotification ty, Either<Uint8List, FlowyError> result);
|
||||
typedef DatabaseNotificationHandler = Function(
|
||||
DatabaseNotification ty, Either<Uint8List, FlowyError> result);
|
||||
|
||||
class GridNotificationListener {
|
||||
class DatabaseNotificationListener {
|
||||
StreamSubscription<SubscribeObject>? _subscription;
|
||||
GridNotificationParser? _parser;
|
||||
DatabaseNotificationParser? _parser;
|
||||
|
||||
GridNotificationListener(
|
||||
{required String objectId, required GridNotificationHandler handler})
|
||||
: _parser = GridNotificationParser(id: objectId, callback: handler) {
|
||||
DatabaseNotificationListener(
|
||||
{required String objectId, required DatabaseNotificationHandler handler})
|
||||
: _parser = DatabaseNotificationParser(id: objectId, callback: handler) {
|
||||
_subscription =
|
||||
RustStreamReceiver.listen((observable) => _parser?.parse(observable));
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import 'package:equatable/equatable.dart';
|
||||
import 'package:appflowy_backend/log.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/protobuf.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/protobuf.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
@ -28,10 +28,10 @@ class BoardBloc extends Bloc<BoardEvent, BoardState> {
|
||||
|
||||
GridFieldController get fieldController =>
|
||||
_gridDataController.fieldController;
|
||||
String get gridId => _gridDataController.gridId;
|
||||
String get databaseId => _gridDataController.viewId;
|
||||
|
||||
BoardBloc({required ViewPB view})
|
||||
: _rowService = MoveRowFFIService(gridId: view.id),
|
||||
: _rowService = MoveRowFFIService(viewId: view.id),
|
||||
_gridDataController = BoardDataController(view: view),
|
||||
super(BoardState.initial(view.id)) {
|
||||
boardController = AppFlowyBoardController(
|
||||
@ -116,7 +116,7 @@ class BoardBloc extends Bloc<BoardEvent, BoardState> {
|
||||
emit(state.copyWith(editingRow: none()));
|
||||
});
|
||||
},
|
||||
didReceiveGridUpdate: (GridPB grid) {
|
||||
didReceiveGridUpdate: (DatabasePB grid) {
|
||||
emit(state.copyWith(grid: Some(grid)));
|
||||
},
|
||||
didReceiveError: (FlowyError error) {
|
||||
@ -218,7 +218,7 @@ class BoardBloc extends Bloc<BoardEvent, BoardState> {
|
||||
},
|
||||
);
|
||||
final controller = GroupController(
|
||||
gridId: state.gridId,
|
||||
databaseId: state.databaseId,
|
||||
group: group,
|
||||
delegate: delegate,
|
||||
);
|
||||
@ -313,7 +313,7 @@ class BoardEvent with _$BoardEvent {
|
||||
const factory BoardEvent.endEditingRow(String rowId) = _EndEditRow;
|
||||
const factory BoardEvent.didReceiveError(FlowyError error) = _DidReceiveError;
|
||||
const factory BoardEvent.didReceiveGridUpdate(
|
||||
GridPB grid,
|
||||
DatabasePB grid,
|
||||
) = _DidReceiveGridUpdate;
|
||||
const factory BoardEvent.didReceiveGroups(List<GroupPB> groups) =
|
||||
_DidReceiveGroups;
|
||||
@ -322,17 +322,17 @@ class BoardEvent with _$BoardEvent {
|
||||
@freezed
|
||||
class BoardState with _$BoardState {
|
||||
const factory BoardState({
|
||||
required String gridId,
|
||||
required Option<GridPB> grid,
|
||||
required String databaseId,
|
||||
required Option<DatabasePB> grid,
|
||||
required List<String> groupIds,
|
||||
required Option<BoardEditingRow> editingRow,
|
||||
required GridLoadingState loadingState,
|
||||
required Option<FlowyError> noneOrError,
|
||||
}) = _BoardState;
|
||||
|
||||
factory BoardState.initial(String gridId) => BoardState(
|
||||
factory BoardState.initial(String databaseId) => BoardState(
|
||||
grid: none(),
|
||||
gridId: gridId,
|
||||
databaseId: databaseId,
|
||||
groupIds: [],
|
||||
editingRow: none(),
|
||||
noneOrError: none(),
|
||||
|
@ -8,12 +8,12 @@ import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'dart:async';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/protobuf.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/protobuf.dart';
|
||||
|
||||
import 'board_listener.dart';
|
||||
|
||||
typedef OnFieldsChanged = void Function(UnmodifiableListView<FieldInfo>);
|
||||
typedef OnGridChanged = void Function(GridPB);
|
||||
typedef OnGridChanged = void Function(DatabasePB);
|
||||
typedef DidLoadGroups = void Function(List<GroupPB>);
|
||||
typedef OnUpdatedGroup = void Function(List<GroupPB>);
|
||||
typedef OnDeletedGroup = void Function(List<String>);
|
||||
@ -27,11 +27,11 @@ typedef OnRowsChanged = void Function(
|
||||
typedef OnError = void Function(FlowyError);
|
||||
|
||||
class BoardDataController {
|
||||
final String gridId;
|
||||
final GridFFIService _gridFFIService;
|
||||
final String viewId;
|
||||
final DatabaseFFIService _databaseFFIService;
|
||||
final GridFieldController fieldController;
|
||||
final BoardListener _listener;
|
||||
late GridViewCache _viewCache;
|
||||
late DatabaseViewCache _viewCache;
|
||||
|
||||
OnFieldsChanged? _onFieldsChanged;
|
||||
OnGridChanged? _onGridChanged;
|
||||
@ -43,13 +43,13 @@ class BoardDataController {
|
||||
GridRowCache get rowCache => _viewCache.rowCache;
|
||||
|
||||
BoardDataController({required ViewPB view})
|
||||
: gridId = view.id,
|
||||
: viewId = view.id,
|
||||
_listener = BoardListener(view.id),
|
||||
_gridFFIService = GridFFIService(gridId: view.id),
|
||||
fieldController = GridFieldController(gridId: view.id) {
|
||||
_databaseFFIService = DatabaseFFIService(databaseId: view.id),
|
||||
fieldController = GridFieldController(databaseId: view.id) {
|
||||
//
|
||||
_viewCache = GridViewCache(
|
||||
gridId: view.id,
|
||||
_viewCache = DatabaseViewCache(
|
||||
databaseId: view.id,
|
||||
fieldController: fieldController,
|
||||
);
|
||||
_viewCache.addListener(onRowsChanged: (reason) {
|
||||
@ -107,7 +107,7 @@ class BoardDataController {
|
||||
}
|
||||
|
||||
Future<Either<Unit, FlowyError>> openGrid() async {
|
||||
final result = await _gridFFIService.openGrid();
|
||||
final result = await _databaseFFIService.openGrid();
|
||||
return result.fold(
|
||||
(grid) async {
|
||||
_onGridChanged?.call(grid);
|
||||
@ -128,17 +128,17 @@ class BoardDataController {
|
||||
|
||||
Future<Either<RowPB, FlowyError>> createBoardCard(String groupId,
|
||||
{String? startRowId}) {
|
||||
return _gridFFIService.createBoardCard(groupId, startRowId);
|
||||
return _databaseFFIService.createBoardCard(groupId, startRowId);
|
||||
}
|
||||
|
||||
Future<void> dispose() async {
|
||||
await _viewCache.dispose();
|
||||
await _gridFFIService.closeGrid();
|
||||
await _databaseFFIService.closeGrid();
|
||||
await fieldController.dispose();
|
||||
}
|
||||
|
||||
Future<void> _loadGroups() async {
|
||||
final result = await _gridFFIService.loadGroups();
|
||||
final result = await _databaseFFIService.loadGroups();
|
||||
return Future(
|
||||
() => result.fold(
|
||||
(groups) {
|
||||
|
@ -3,10 +3,10 @@ import 'dart:typed_data';
|
||||
import 'package:app_flowy/core/grid_notification.dart';
|
||||
import 'package:flowy_infra/notifier.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/notification.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/notification.pb.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/group.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/group_changeset.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/group.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/group_changeset.pb.dart';
|
||||
|
||||
typedef GroupUpdateValue = Either<GroupViewChangesetPB, FlowyError>;
|
||||
typedef GroupByNewFieldValue = Either<List<GroupPB>, FlowyError>;
|
||||
@ -16,7 +16,7 @@ class BoardListener {
|
||||
PublishNotifier<GroupUpdateValue>? _groupUpdateNotifier = PublishNotifier();
|
||||
PublishNotifier<GroupByNewFieldValue>? _groupByNewFieldNotifier =
|
||||
PublishNotifier();
|
||||
GridNotificationListener? _listener;
|
||||
DatabaseNotificationListener? _listener;
|
||||
BoardListener(this.viewId);
|
||||
|
||||
void start({
|
||||
@ -25,25 +25,25 @@ class BoardListener {
|
||||
}) {
|
||||
_groupUpdateNotifier?.addPublishListener(onBoardChanged);
|
||||
_groupByNewFieldNotifier?.addPublishListener(onGroupByNewField);
|
||||
_listener = GridNotificationListener(
|
||||
_listener = DatabaseNotificationListener(
|
||||
objectId: viewId,
|
||||
handler: _handler,
|
||||
);
|
||||
}
|
||||
|
||||
void _handler(
|
||||
GridNotification ty,
|
||||
DatabaseNotification ty,
|
||||
Either<Uint8List, FlowyError> result,
|
||||
) {
|
||||
switch (ty) {
|
||||
case GridNotification.DidUpdateGroupView:
|
||||
case DatabaseNotification.DidUpdateGroupView:
|
||||
result.fold(
|
||||
(payload) => _groupUpdateNotifier?.value =
|
||||
left(GroupViewChangesetPB.fromBuffer(payload)),
|
||||
(error) => _groupUpdateNotifier?.value = right(error),
|
||||
);
|
||||
break;
|
||||
case GridNotification.DidGroupByNewField:
|
||||
case DatabaseNotification.DidGroupByNewField:
|
||||
result.fold(
|
||||
(payload) => _groupByNewFieldNotifier?.value =
|
||||
left(GroupViewChangesetPB.fromBuffer(payload).newGroups),
|
||||
|
@ -1,6 +1,6 @@
|
||||
import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart';
|
||||
import 'package:app_flowy/plugins/grid/application/field/field_controller.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/date_type_option_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/date_type_option_entities.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/select_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/url_type_option_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/url_type_option_entities.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
|
@ -3,7 +3,7 @@ import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_servic
|
||||
import 'package:app_flowy/plugins/grid/application/row/row_cache.dart';
|
||||
import 'package:app_flowy/plugins/grid/application/row/row_service.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/row_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/row_entities.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
@ -18,11 +18,11 @@ class BoardCardBloc extends Bloc<BoardCardEvent, BoardCardState> {
|
||||
|
||||
BoardCardBloc({
|
||||
required this.groupFieldId,
|
||||
required String gridId,
|
||||
required String viewId,
|
||||
required CardDataController dataController,
|
||||
required bool isEditing,
|
||||
}) : _rowService = RowFFIService(
|
||||
gridId: gridId,
|
||||
databaseId: viewId,
|
||||
),
|
||||
_dataController = dataController,
|
||||
super(
|
||||
@ -60,7 +60,7 @@ class BoardCardBloc extends Bloc<BoardCardEvent, BoardCardState> {
|
||||
|
||||
RowInfo rowInfo() {
|
||||
return RowInfo(
|
||||
gridId: _rowService.gridId,
|
||||
databaseId: _rowService.databaseId,
|
||||
fields: UnmodifiableListView(
|
||||
state.cells.map((cell) => cell.identifier.fieldInfo).toList(),
|
||||
),
|
||||
|
@ -3,7 +3,7 @@ import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_servic
|
||||
import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_field_notifier.dart';
|
||||
import 'package:app_flowy/plugins/grid/application/field/field_controller.dart';
|
||||
import 'package:app_flowy/plugins/grid/application/row/row_cache.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/row_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/row_entities.pb.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
typedef OnCardChanged = void Function(GridCellMap, RowsChangedReason);
|
||||
|
@ -1,10 +1,10 @@
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
|
||||
class BoardGroupService {
|
||||
final String gridId;
|
||||
final String viewId;
|
||||
FieldPB? groupField;
|
||||
|
||||
BoardGroupService(this.gridId);
|
||||
BoardGroupService(this.viewId);
|
||||
|
||||
void setGroupField(FieldPB field) {
|
||||
groupField = field;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import 'package:appflowy_backend/log.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/protobuf.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/protobuf.dart';
|
||||
import 'group_listener.dart';
|
||||
|
||||
typedef OnGroupError = void Function(FlowyError);
|
||||
@ -18,7 +18,7 @@ class GroupController {
|
||||
final GroupControllerDelegate delegate;
|
||||
|
||||
GroupController({
|
||||
required String gridId,
|
||||
required String databaseId,
|
||||
required this.group,
|
||||
required this.delegate,
|
||||
}) : _listener = GroupListener(group);
|
||||
|
@ -3,35 +3,35 @@ import 'dart:typed_data';
|
||||
import 'package:app_flowy/core/grid_notification.dart';
|
||||
import 'package:flowy_infra/notifier.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/notification.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/group.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/notification.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/group.pb.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/group_changeset.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/group_changeset.pb.dart';
|
||||
|
||||
typedef UpdateGroupNotifiedValue = Either<GroupRowsNotificationPB, FlowyError>;
|
||||
|
||||
class GroupListener {
|
||||
final GroupPB group;
|
||||
PublishNotifier<UpdateGroupNotifiedValue>? _groupNotifier = PublishNotifier();
|
||||
GridNotificationListener? _listener;
|
||||
DatabaseNotificationListener? _listener;
|
||||
GroupListener(this.group);
|
||||
|
||||
void start({
|
||||
required void Function(UpdateGroupNotifiedValue) onGroupChanged,
|
||||
}) {
|
||||
_groupNotifier?.addPublishListener(onGroupChanged);
|
||||
_listener = GridNotificationListener(
|
||||
_listener = DatabaseNotificationListener(
|
||||
objectId: group.groupId,
|
||||
handler: _handler,
|
||||
);
|
||||
}
|
||||
|
||||
void _handler(
|
||||
GridNotification ty,
|
||||
DatabaseNotification ty,
|
||||
Either<Uint8List, FlowyError> result,
|
||||
) {
|
||||
switch (ty) {
|
||||
case GridNotification.DidUpdateGroup:
|
||||
case DatabaseNotification.DidUpdateGroup:
|
||||
result.fold(
|
||||
(payload) => _groupNotifier?.value =
|
||||
left(GroupRowsNotificationPB.fromBuffer(payload)),
|
||||
|
@ -6,8 +6,8 @@ import 'package:dartz/dartz.dart';
|
||||
part 'board_setting_bloc.freezed.dart';
|
||||
|
||||
class BoardSettingBloc extends Bloc<BoardSettingEvent, BoardSettingState> {
|
||||
final String gridId;
|
||||
BoardSettingBloc({required this.gridId})
|
||||
final String databaseId;
|
||||
BoardSettingBloc({required this.databaseId})
|
||||
: super(BoardSettingState.initial()) {
|
||||
on<BoardSettingEvent>(
|
||||
(event, emit) async {
|
||||
|
@ -10,8 +10,8 @@ import 'package:app_flowy/plugins/grid/application/row/row_data_controller.dart'
|
||||
import 'package:app_flowy/plugins/grid/presentation/widgets/cell/cell_builder.dart';
|
||||
import 'package:app_flowy/plugins/grid/presentation/widgets/row/row_detail.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/row_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/row_entities.pb.dart';
|
||||
import 'package:appflowy_board/appflowy_board.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flowy_infra/image.dart';
|
||||
@ -227,7 +227,7 @@ class _BoardContentState extends State<BoardContent> {
|
||||
if (rowCache == null) return SizedBox(key: ObjectKey(groupItem));
|
||||
|
||||
final fieldController = context.read<BoardBloc>().fieldController;
|
||||
final gridId = context.read<BoardBloc>().gridId;
|
||||
final databaseId = context.read<BoardBloc>().databaseId;
|
||||
final cardController = CardDataController(
|
||||
fieldController: fieldController,
|
||||
rowCache: rowCache,
|
||||
@ -249,14 +249,14 @@ class _BoardContentState extends State<BoardContent> {
|
||||
margin: config.cardPadding,
|
||||
decoration: _makeBoxDecoration(context),
|
||||
child: BoardCard(
|
||||
gridId: gridId,
|
||||
viewId: databaseId,
|
||||
groupId: groupData.group.groupId,
|
||||
fieldId: groupItem.fieldInfo.id,
|
||||
isEditing: isEditing,
|
||||
cellBuilder: cellBuilder,
|
||||
dataController: cardController,
|
||||
openCard: (context) => _openCard(
|
||||
gridId,
|
||||
databaseId,
|
||||
fieldController,
|
||||
rowPB,
|
||||
rowCache,
|
||||
@ -292,14 +292,14 @@ class _BoardContentState extends State<BoardContent> {
|
||||
}
|
||||
|
||||
void _openCard(
|
||||
String gridId,
|
||||
String databaseId,
|
||||
GridFieldController fieldController,
|
||||
RowPB rowPB,
|
||||
GridRowCache rowCache,
|
||||
BuildContext context,
|
||||
) {
|
||||
final rowInfo = RowInfo(
|
||||
gridId: gridId,
|
||||
databaseId: databaseId,
|
||||
fields: UnmodifiableListView(fieldController.fieldInfos),
|
||||
rowPB: rowPB,
|
||||
);
|
||||
@ -331,7 +331,7 @@ class _ToolbarBlocAdaptor extends StatelessWidget {
|
||||
builder: (context, state) {
|
||||
final bloc = context.read<BoardBloc>();
|
||||
final toolbarContext = BoardToolbarContext(
|
||||
viewId: bloc.gridId,
|
||||
viewId: bloc.databaseId,
|
||||
fieldController: bloc.fieldController,
|
||||
);
|
||||
|
||||
|
@ -13,7 +13,7 @@ import 'container/accessory.dart';
|
||||
import 'container/card_container.dart';
|
||||
|
||||
class BoardCard extends StatefulWidget {
|
||||
final String gridId;
|
||||
final String viewId;
|
||||
final String groupId;
|
||||
final String fieldId;
|
||||
final bool isEditing;
|
||||
@ -24,7 +24,7 @@ class BoardCard extends StatefulWidget {
|
||||
final VoidCallback onEndEditing;
|
||||
|
||||
const BoardCard({
|
||||
required this.gridId,
|
||||
required this.viewId,
|
||||
required this.groupId,
|
||||
required this.fieldId,
|
||||
required this.isEditing,
|
||||
@ -50,7 +50,7 @@ class _BoardCardState extends State<BoardCard> {
|
||||
void initState() {
|
||||
rowNotifier = EditableRowNotifier(isEditing: widget.isEditing);
|
||||
_cardBloc = BoardCardBloc(
|
||||
gridId: widget.gridId,
|
||||
viewId: widget.viewId,
|
||||
groupFieldId: widget.fieldId,
|
||||
dataController: widget.dataController,
|
||||
isEditing: widget.isEditing,
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'board_cell.dart';
|
||||
|
@ -44,7 +44,7 @@ class BoardSettingList extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) => BoardSettingBloc(gridId: settingContext.viewId),
|
||||
create: (context) => BoardSettingBloc(databaseId: settingContext.viewId),
|
||||
child: BlocListener<BoardSettingBloc, BoardSettingState>(
|
||||
listenWhen: (previous, current) =>
|
||||
previous.selectedAction != current.selectedAction,
|
||||
@ -171,7 +171,7 @@ class _BoardSettingListPopoverState extends State<BoardSettingListPopover> {
|
||||
);
|
||||
case BoardSettingAction.properties:
|
||||
return GridPropertyList(
|
||||
gridId: widget.settingContext.viewId,
|
||||
databaseId: widget.settingContext.viewId,
|
||||
fieldController: widget.settingContext.fieldController,
|
||||
);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'package:app_flowy/core/grid_notification.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/notification.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/notification.pb.dart';
|
||||
import 'package:flowy_infra/notifier.dart';
|
||||
import 'dart:async';
|
||||
import 'dart:typed_data';
|
||||
@ -13,18 +13,18 @@ class CellListener {
|
||||
final String fieldId;
|
||||
PublishNotifier<UpdateFieldNotifiedValue>? _updateCellNotifier =
|
||||
PublishNotifier();
|
||||
GridNotificationListener? _listener;
|
||||
DatabaseNotificationListener? _listener;
|
||||
CellListener({required this.rowId, required this.fieldId});
|
||||
|
||||
void start({required void Function(UpdateFieldNotifiedValue) onCellChanged}) {
|
||||
_updateCellNotifier?.addPublishListener(onCellChanged);
|
||||
_listener = GridNotificationListener(
|
||||
_listener = DatabaseNotificationListener(
|
||||
objectId: "$rowId:$fieldId", handler: _handler);
|
||||
}
|
||||
|
||||
void _handler(GridNotification ty, Either<Uint8List, FlowyError> result) {
|
||||
void _handler(DatabaseNotification ty, Either<Uint8List, FlowyError> result) {
|
||||
switch (ty) {
|
||||
case GridNotification.DidUpdateCell:
|
||||
case DatabaseNotification.DidUpdateCell:
|
||||
result.fold(
|
||||
(payload) => _updateCellNotifier?.value = left(unit),
|
||||
(error) => _updateCellNotifier?.value = right(error),
|
||||
|
@ -25,12 +25,12 @@ class GridCellCacheKey {
|
||||
/// Read https://appflowy.gitbook.io/docs/essential-documentation/contribute-to-appflowy/architecture/frontend/grid
|
||||
/// for more information
|
||||
class GridCellCache {
|
||||
final String gridId;
|
||||
final String databaseId;
|
||||
|
||||
/// fieldId: {cacheKey: GridCell}
|
||||
final Map<String, Map<String, dynamic>> _cellDataByFieldId = {};
|
||||
GridCellCache({
|
||||
required this.gridId,
|
||||
required this.databaseId,
|
||||
});
|
||||
|
||||
void removeCellWithFieldId(String fieldId) {
|
||||
|
@ -152,7 +152,7 @@ class GridCellController<T, D> extends Equatable {
|
||||
_cellDataPersistence = cellDataPersistence,
|
||||
_fieldNotifier = fieldNotifier,
|
||||
_fieldService = FieldService(
|
||||
gridId: cellId.gridId,
|
||||
databaseId: cellId.databaseId,
|
||||
fieldId: cellId.fieldInfo.id,
|
||||
),
|
||||
_cacheKey = GridCellCacheKey(
|
||||
@ -160,7 +160,7 @@ class GridCellController<T, D> extends Equatable {
|
||||
fieldId: cellId.fieldInfo.id,
|
||||
);
|
||||
|
||||
String get gridId => cellId.gridId;
|
||||
String get databaseId => cellId.databaseId;
|
||||
|
||||
String get rowId => cellId.rowId;
|
||||
|
||||
|
@ -51,7 +51,7 @@ class DateCellDataPersistence implements GridCellDataPersistence<CalendarData> {
|
||||
payload.time = data.time!;
|
||||
}
|
||||
|
||||
return GridEventUpdateDateCell(payload).send().then((result) {
|
||||
return DatabaseEventUpdateDateCell(payload).send().then((result) {
|
||||
return result.fold(
|
||||
(l) => none(),
|
||||
(err) => Some(err),
|
||||
@ -62,7 +62,7 @@ class DateCellDataPersistence implements GridCellDataPersistence<CalendarData> {
|
||||
|
||||
CellPathPB _makeCellPath(GridCellIdentifier cellId) {
|
||||
return CellPathPB.create()
|
||||
..viewId = cellId.gridId
|
||||
..databaseId = cellId.databaseId
|
||||
..fieldId = cellId.fieldId
|
||||
..rowId = cellId.rowId;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ abstract class IGridCellFieldNotifier {
|
||||
void onCellDispose();
|
||||
}
|
||||
|
||||
/// GridPB's cell helper wrapper that enables each cell will get notified when the corresponding field was changed.
|
||||
/// DatabasePB's cell helper wrapper that enables each cell will get notified when the corresponding field was changed.
|
||||
/// You Register an onFieldChanged callback to listen to the cell changes, and unregister if you don't want to listen.
|
||||
class GridCellFieldNotifier {
|
||||
final IGridCellFieldNotifier notifier;
|
||||
|
@ -5,11 +5,11 @@ import 'package:equatable/equatable.dart';
|
||||
import 'package:appflowy_backend/dispatch/dispatch.dart';
|
||||
import 'package:appflowy_backend/log.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/cell_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/date_type_option_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/select_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/url_type_option_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/cell_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/date_type_option_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/url_type_option_entities.pb.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:app_flowy/plugins/grid/application/cell/cell_listener.dart';
|
||||
@ -35,30 +35,30 @@ class CellService {
|
||||
required String data,
|
||||
}) {
|
||||
final payload = CellChangesetPB.create()
|
||||
..gridId = cellId.gridId
|
||||
..databaseId = cellId.databaseId
|
||||
..fieldId = cellId.fieldId
|
||||
..rowId = cellId.rowId
|
||||
..typeCellData = data;
|
||||
return GridEventUpdateCell(payload).send();
|
||||
return DatabaseEventUpdateCell(payload).send();
|
||||
}
|
||||
|
||||
Future<Either<CellPB, FlowyError>> getCell({
|
||||
required GridCellIdentifier cellId,
|
||||
}) {
|
||||
final payload = CellPathPB.create()
|
||||
..viewId = cellId.gridId
|
||||
..databaseId = cellId.databaseId
|
||||
..fieldId = cellId.fieldId
|
||||
..rowId = cellId.rowId;
|
||||
return GridEventGetCell(payload).send();
|
||||
return DatabaseEventGetCell(payload).send();
|
||||
}
|
||||
}
|
||||
|
||||
/// Id of the cell
|
||||
/// We can locate the cell by using gridId + rowId + field.id.
|
||||
/// We can locate the cell by using database + rowId + field.id.
|
||||
@freezed
|
||||
class GridCellIdentifier with _$GridCellIdentifier {
|
||||
const factory GridCellIdentifier({
|
||||
required String gridId,
|
||||
required String databaseId,
|
||||
required String rowId,
|
||||
required FieldInfo fieldInfo,
|
||||
}) = _GridCellIdentifier;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:appflowy_backend/log.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/select_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
|
@ -3,7 +3,7 @@ import 'dart:async';
|
||||
import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:appflowy_backend/log.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/select_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
|
@ -5,8 +5,8 @@ import 'package:easy_localization/easy_localization.dart'
|
||||
import 'package:appflowy_backend/log.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/code.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/date_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/date_type_option_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/date_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/date_type_option_entities.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:table_calendar/table_calendar.dart';
|
||||
@ -175,7 +175,7 @@ class DateCalBloc extends Bloc<DateCalEvent, DateCalState> {
|
||||
});
|
||||
|
||||
final result = await FieldService.updateFieldTypeOption(
|
||||
gridId: cellController.gridId,
|
||||
databaseId: cellController.databaseId,
|
||||
fieldId: cellController.fieldInfo.id,
|
||||
typeOptionData: newDateTypeOption.writeToBuffer(),
|
||||
);
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:app_flowy/plugins/grid/application/field/field_controller.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/date_type_option_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/date_type_option_entities.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/select_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart';
|
||||
|
@ -2,7 +2,7 @@ import 'dart:async';
|
||||
import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:appflowy_backend/log.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/select_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'select_option_service.dart';
|
||||
|
@ -1,29 +1,29 @@
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:appflowy_backend/dispatch/dispatch.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/cell_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/cell_entities.pb.dart';
|
||||
import 'package:app_flowy/plugins/grid/application/field/type_option/type_option_service.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/select_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
||||
import 'cell_service/cell_service.dart';
|
||||
|
||||
class SelectOptionFFIService {
|
||||
final GridCellIdentifier cellId;
|
||||
SelectOptionFFIService({required this.cellId});
|
||||
|
||||
String get gridId => cellId.gridId;
|
||||
String get databaseId => cellId.databaseId;
|
||||
String get fieldId => cellId.fieldInfo.id;
|
||||
String get rowId => cellId.rowId;
|
||||
|
||||
Future<Either<Unit, FlowyError>> create(
|
||||
{required String name, bool isSelected = true}) {
|
||||
return TypeOptionFFIService(gridId: gridId, fieldId: fieldId)
|
||||
return TypeOptionFFIService(databaseId: databaseId, fieldId: fieldId)
|
||||
.newOption(name: name)
|
||||
.then(
|
||||
(result) {
|
||||
return result.fold(
|
||||
(option) {
|
||||
final cellIdentifier = CellPathPB.create()
|
||||
..viewId = gridId
|
||||
..databaseId = databaseId
|
||||
..fieldId = fieldId
|
||||
..rowId = rowId;
|
||||
final payload = SelectOptionChangesetPB.create()
|
||||
@ -34,7 +34,7 @@ class SelectOptionFFIService {
|
||||
} else {
|
||||
payload.updateOptions.add(option);
|
||||
}
|
||||
return GridEventUpdateSelectOption(payload).send();
|
||||
return DatabaseEventUpdateSelectOption(payload).send();
|
||||
},
|
||||
(r) => right(r),
|
||||
);
|
||||
@ -48,7 +48,7 @@ class SelectOptionFFIService {
|
||||
final payload = SelectOptionChangesetPB.create()
|
||||
..updateOptions.add(option)
|
||||
..cellIdentifier = _cellIdentifier();
|
||||
return GridEventUpdateSelectOption(payload).send();
|
||||
return DatabaseEventUpdateSelectOption(payload).send();
|
||||
}
|
||||
|
||||
Future<Either<Unit, FlowyError>> delete(
|
||||
@ -57,16 +57,16 @@ class SelectOptionFFIService {
|
||||
..deleteOptions.addAll(options)
|
||||
..cellIdentifier = _cellIdentifier();
|
||||
|
||||
return GridEventUpdateSelectOption(payload).send();
|
||||
return DatabaseEventUpdateSelectOption(payload).send();
|
||||
}
|
||||
|
||||
Future<Either<SelectOptionCellDataPB, FlowyError>> getOptionContext() {
|
||||
final payload = CellPathPB.create()
|
||||
..viewId = gridId
|
||||
..databaseId = databaseId
|
||||
..fieldId = fieldId
|
||||
..rowId = rowId;
|
||||
|
||||
return GridEventGetSelectOptionCellData(payload).send();
|
||||
return DatabaseEventGetSelectOptionCellData(payload).send();
|
||||
}
|
||||
|
||||
Future<Either<void, FlowyError>> select(
|
||||
@ -74,7 +74,7 @@ class SelectOptionFFIService {
|
||||
final payload = SelectOptionCellChangesetPB.create()
|
||||
..cellIdentifier = _cellIdentifier()
|
||||
..insertOptionIds.addAll(optionIds);
|
||||
return GridEventUpdateSelectOptionCell(payload).send();
|
||||
return DatabaseEventUpdateSelectOptionCell(payload).send();
|
||||
}
|
||||
|
||||
Future<Either<void, FlowyError>> unSelect(
|
||||
@ -82,12 +82,12 @@ class SelectOptionFFIService {
|
||||
final payload = SelectOptionCellChangesetPB.create()
|
||||
..cellIdentifier = _cellIdentifier()
|
||||
..deleteOptionIds.addAll(optionIds);
|
||||
return GridEventUpdateSelectOptionCell(payload).send();
|
||||
return DatabaseEventUpdateSelectOptionCell(payload).send();
|
||||
}
|
||||
|
||||
CellPathPB _cellIdentifier() {
|
||||
return CellPathPB.create()
|
||||
..viewId = gridId
|
||||
..databaseId = databaseId
|
||||
..fieldId = fieldId
|
||||
..rowId = rowId;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/url_type_option_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/url_type_option_entities.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/url_type_option_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/url_type_option_entities.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:appflowy_backend/log.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
@ -13,7 +13,7 @@ class FieldActionSheetBloc
|
||||
|
||||
FieldActionSheetBloc({required GridFieldCellContext fieldCellContext})
|
||||
: fieldService = FieldService(
|
||||
gridId: fieldCellContext.gridId,
|
||||
databaseId: fieldCellContext.databaseId,
|
||||
fieldId: fieldCellContext.field.id,
|
||||
),
|
||||
super(
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'package:app_flowy/plugins/grid/application/field/field_listener.dart';
|
||||
import 'package:app_flowy/plugins/grid/application/field/field_service.dart';
|
||||
import 'package:appflowy_backend/log.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
@ -16,7 +16,7 @@ class FieldCellBloc extends Bloc<FieldCellEvent, FieldCellState> {
|
||||
required GridFieldCellContext cellContext,
|
||||
}) : _fieldListener = SingleFieldListener(fieldId: cellContext.field.id),
|
||||
_fieldService = FieldService(
|
||||
gridId: cellContext.gridId, fieldId: cellContext.field.id),
|
||||
databaseId: cellContext.databaseId, fieldId: cellContext.field.id),
|
||||
super(FieldCellState.initial(cellContext)) {
|
||||
on<FieldCellEvent>(
|
||||
(event, emit) async {
|
||||
@ -73,14 +73,14 @@ class FieldCellEvent with _$FieldCellEvent {
|
||||
@freezed
|
||||
class FieldCellState with _$FieldCellState {
|
||||
const factory FieldCellState({
|
||||
required String gridId,
|
||||
required String databaseId,
|
||||
required FieldPB field,
|
||||
required double width,
|
||||
}) = _FieldCellState;
|
||||
|
||||
factory FieldCellState.initial(GridFieldCellContext cellContext) =>
|
||||
FieldCellState(
|
||||
gridId: cellContext.gridId,
|
||||
databaseId: cellContext.databaseId,
|
||||
field: cellContext.field,
|
||||
width: cellContext.field.width.toDouble(),
|
||||
);
|
||||
|
@ -9,15 +9,15 @@ import 'package:app_flowy/plugins/grid/application/sort/sort_listener.dart';
|
||||
import 'package:app_flowy/plugins/grid/application/sort/sort_service.dart';
|
||||
import 'package:app_flowy/plugins/grid/presentation/widgets/filter/filter_info.dart';
|
||||
import 'package:app_flowy/plugins/grid/presentation/widgets/sort/sort_info.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/filter_changeset.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/sort_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/filter_changeset.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/sort_entities.pb.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:appflowy_backend/log.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/group.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/setting_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/util.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/group.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/setting_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/util.pb.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import '../row/row_cache.dart';
|
||||
|
||||
@ -72,15 +72,15 @@ typedef OnReceiveFilters = void Function(List<FilterInfo>);
|
||||
typedef OnReceiveSorts = void Function(List<SortInfo>);
|
||||
|
||||
class GridFieldController {
|
||||
final String gridId;
|
||||
final String databaseId;
|
||||
// Listeners
|
||||
final GridFieldsListener _fieldListener;
|
||||
final SettingListener _settingListener;
|
||||
final DatabaseFieldsListener _fieldListener;
|
||||
final DatabaseSettingListener _settingListener;
|
||||
final FiltersListener _filtersListener;
|
||||
final SortsListener _sortsListener;
|
||||
|
||||
// FFI services
|
||||
final GridFFIService _gridFFIService;
|
||||
final DatabaseFFIService _gridFFIService;
|
||||
final SettingFFIService _settingFFIService;
|
||||
final FilterFFIService _filterFFIService;
|
||||
final SortFFIService _sortFFIService;
|
||||
@ -147,15 +147,15 @@ class GridFieldController {
|
||||
return sorts.first;
|
||||
}
|
||||
|
||||
GridFieldController({required this.gridId})
|
||||
: _fieldListener = GridFieldsListener(gridId: gridId),
|
||||
_settingListener = SettingListener(gridId: gridId),
|
||||
_filterFFIService = FilterFFIService(viewId: gridId),
|
||||
_filtersListener = FiltersListener(viewId: gridId),
|
||||
_gridFFIService = GridFFIService(gridId: gridId),
|
||||
_sortFFIService = SortFFIService(viewId: gridId),
|
||||
_sortsListener = SortsListener(viewId: gridId),
|
||||
_settingFFIService = SettingFFIService(viewId: gridId) {
|
||||
GridFieldController({required this.databaseId})
|
||||
: _fieldListener = DatabaseFieldsListener(databaseId: databaseId),
|
||||
_settingListener = DatabaseSettingListener(databaseId: databaseId),
|
||||
_filterFFIService = FilterFFIService(databaseId: databaseId),
|
||||
_filtersListener = FiltersListener(viewId: databaseId),
|
||||
_gridFFIService = DatabaseFFIService(databaseId: databaseId),
|
||||
_sortFFIService = SortFFIService(viewId: databaseId),
|
||||
_sortsListener = SortsListener(viewId: databaseId),
|
||||
_settingFFIService = SettingFFIService(viewId: databaseId) {
|
||||
//Listen on field's changes
|
||||
_listenOnFieldChanges();
|
||||
|
||||
@ -209,7 +209,7 @@ class GridFieldController {
|
||||
);
|
||||
if (fieldInfo != null) {
|
||||
_filterPBByFieldId[fieldInfo.id] = newFilter;
|
||||
filters.add(FilterInfo(gridId, newFilter, fieldInfo));
|
||||
filters.add(FilterInfo(databaseId, newFilter, fieldInfo));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -243,7 +243,7 @@ class GridFieldController {
|
||||
// Insert the filter with the position: filterIndex, otherwise,
|
||||
// append it to the end of the list.
|
||||
final filterInfo =
|
||||
FilterInfo(gridId, updatedFilter.filter, fieldInfo);
|
||||
FilterInfo(databaseId, updatedFilter.filter, fieldInfo);
|
||||
if (filterIndex != -1) {
|
||||
filters.insert(filterIndex, filterInfo);
|
||||
} else {
|
||||
@ -391,7 +391,7 @@ class GridFieldController {
|
||||
});
|
||||
}
|
||||
|
||||
void _updateSetting(GridSettingPB setting) {
|
||||
void _updateSetting(DatabaseViewSettingPB setting) {
|
||||
_groupConfigurationByFieldId.clear();
|
||||
for (final configuration in setting.groupConfigurations.items) {
|
||||
_groupConfigurationByFieldId[configuration.fieldId] = configuration;
|
||||
@ -476,7 +476,7 @@ class GridFieldController {
|
||||
fieldType: filterPB.fieldType,
|
||||
);
|
||||
if (fieldInfo != null) {
|
||||
final filterInfo = FilterInfo(gridId, filterPB, fieldInfo);
|
||||
final filterInfo = FilterInfo(databaseId, filterPB, fieldInfo);
|
||||
filters.add(filterInfo);
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,10 @@
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'dart:async';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'field_service.dart';
|
||||
import 'type_option/type_option_context.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
import 'type_option/type_option_data_controller.dart';
|
||||
|
||||
part 'field_editor_bloc.freezed.dart';
|
||||
@ -14,13 +13,13 @@ class FieldEditorBloc extends Bloc<FieldEditorEvent, FieldEditorState> {
|
||||
final TypeOptionDataController dataController;
|
||||
|
||||
FieldEditorBloc({
|
||||
required String gridId,
|
||||
required String databaseId,
|
||||
required String fieldName,
|
||||
required bool isGroupField,
|
||||
required IFieldTypeOptionLoader loader,
|
||||
}) : dataController =
|
||||
TypeOptionDataController(gridId: gridId, loader: loader),
|
||||
super(FieldEditorState.initial(gridId, fieldName, isGroupField)) {
|
||||
TypeOptionDataController(databaseId: databaseId, loader: loader),
|
||||
super(FieldEditorState.initial(databaseId, fieldName, isGroupField)) {
|
||||
on<FieldEditorEvent>(
|
||||
(event, emit) async {
|
||||
await event.when(
|
||||
@ -50,7 +49,7 @@ class FieldEditorBloc extends Bloc<FieldEditorEvent, FieldEditorState> {
|
||||
() => null,
|
||||
(field) {
|
||||
final fieldService = FieldService(
|
||||
gridId: gridId,
|
||||
databaseId: databaseId,
|
||||
fieldId: field.id,
|
||||
);
|
||||
fieldService.deleteField();
|
||||
@ -85,7 +84,7 @@ class FieldEditorEvent with _$FieldEditorEvent {
|
||||
@freezed
|
||||
class FieldEditorState with _$FieldEditorState {
|
||||
const factory FieldEditorState({
|
||||
required String gridId,
|
||||
required String databaseId,
|
||||
required String errorText,
|
||||
required String name,
|
||||
required Option<FieldPB> field,
|
||||
@ -94,12 +93,12 @@ class FieldEditorState with _$FieldEditorState {
|
||||
}) = _FieldEditorState;
|
||||
|
||||
factory FieldEditorState.initial(
|
||||
String gridId,
|
||||
String databaseId,
|
||||
String fieldName,
|
||||
bool isGroupField,
|
||||
) =>
|
||||
FieldEditorState(
|
||||
gridId: gridId,
|
||||
databaseId: databaseId,
|
||||
errorText: '',
|
||||
field: none(),
|
||||
canDelete: false,
|
||||
|
@ -1,11 +1,11 @@
|
||||
import 'package:app_flowy/core/grid_notification.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/notification.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/notification.pb.dart';
|
||||
import 'package:flowy_infra/notifier.dart';
|
||||
import 'dart:async';
|
||||
import 'dart:typed_data';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
|
||||
typedef UpdateFieldNotifiedValue = Either<FieldPB, FlowyError>;
|
||||
|
||||
@ -13,25 +13,25 @@ class SingleFieldListener {
|
||||
final String fieldId;
|
||||
PublishNotifier<UpdateFieldNotifiedValue>? _updateFieldNotifier =
|
||||
PublishNotifier();
|
||||
GridNotificationListener? _listener;
|
||||
DatabaseNotificationListener? _listener;
|
||||
|
||||
SingleFieldListener({required this.fieldId});
|
||||
|
||||
void start(
|
||||
{required void Function(UpdateFieldNotifiedValue) onFieldChanged}) {
|
||||
_updateFieldNotifier?.addPublishListener(onFieldChanged);
|
||||
_listener = GridNotificationListener(
|
||||
_listener = DatabaseNotificationListener(
|
||||
objectId: fieldId,
|
||||
handler: _handler,
|
||||
);
|
||||
}
|
||||
|
||||
void _handler(
|
||||
GridNotification ty,
|
||||
DatabaseNotification ty,
|
||||
Either<Uint8List, FlowyError> result,
|
||||
) {
|
||||
switch (ty) {
|
||||
case GridNotification.DidUpdateField:
|
||||
case DatabaseNotification.DidUpdateField:
|
||||
result.fold(
|
||||
(payload) =>
|
||||
_updateFieldNotifier?.value = left(FieldPB.fromBuffer(payload)),
|
||||
|
@ -1,8 +1,8 @@
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:appflowy_backend/dispatch/dispatch.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/grid_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/grid_entities.pb.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'field_service.freezed.dart';
|
||||
@ -10,21 +10,21 @@ part 'field_service.freezed.dart';
|
||||
/// FieldService consists of lots of event functions. We define the events in the backend(Rust),
|
||||
/// you can find the corresponding event implementation in event_map.rs of the corresponding crate.
|
||||
///
|
||||
/// You could check out the rust-lib/flowy-grid/event_map.rs for more information.
|
||||
/// You could check out the rust-lib/flowy-database/event_map.rs for more information.
|
||||
class FieldService {
|
||||
final String gridId;
|
||||
final String databaseId;
|
||||
final String fieldId;
|
||||
|
||||
FieldService({required this.gridId, required this.fieldId});
|
||||
FieldService({required this.databaseId, required this.fieldId});
|
||||
|
||||
Future<Either<Unit, FlowyError>> moveField(int fromIndex, int toIndex) {
|
||||
final payload = MoveFieldPayloadPB.create()
|
||||
..gridId = gridId
|
||||
..viewId = databaseId
|
||||
..fieldId = fieldId
|
||||
..fromIndex = fromIndex
|
||||
..toIndex = toIndex;
|
||||
|
||||
return GridEventMoveField(payload).send();
|
||||
return DatabaseEventMoveField(payload).send();
|
||||
}
|
||||
|
||||
Future<Either<Unit, FlowyError>> updateField({
|
||||
@ -35,7 +35,7 @@ class FieldService {
|
||||
double? width,
|
||||
}) {
|
||||
var payload = FieldChangesetPB.create()
|
||||
..gridId = gridId
|
||||
..databaseId = databaseId
|
||||
..fieldId = fieldId;
|
||||
|
||||
if (name != null) {
|
||||
@ -58,46 +58,46 @@ class FieldService {
|
||||
payload.width = width.toInt();
|
||||
}
|
||||
|
||||
return GridEventUpdateField(payload).send();
|
||||
return DatabaseEventUpdateField(payload).send();
|
||||
}
|
||||
|
||||
static Future<Either<Unit, FlowyError>> updateFieldTypeOption({
|
||||
required String gridId,
|
||||
required String databaseId,
|
||||
required String fieldId,
|
||||
required List<int> typeOptionData,
|
||||
}) {
|
||||
var payload = TypeOptionChangesetPB.create()
|
||||
..gridId = gridId
|
||||
..databaseId = databaseId
|
||||
..fieldId = fieldId
|
||||
..typeOptionData = typeOptionData;
|
||||
|
||||
return GridEventUpdateFieldTypeOption(payload).send();
|
||||
return DatabaseEventUpdateFieldTypeOption(payload).send();
|
||||
}
|
||||
|
||||
Future<Either<Unit, FlowyError>> deleteField() {
|
||||
final payload = DeleteFieldPayloadPB.create()
|
||||
..gridId = gridId
|
||||
..databaseId = databaseId
|
||||
..fieldId = fieldId;
|
||||
|
||||
return GridEventDeleteField(payload).send();
|
||||
return DatabaseEventDeleteField(payload).send();
|
||||
}
|
||||
|
||||
Future<Either<Unit, FlowyError>> duplicateField() {
|
||||
final payload = DuplicateFieldPayloadPB.create()
|
||||
..gridId = gridId
|
||||
..databaseId = databaseId
|
||||
..fieldId = fieldId;
|
||||
|
||||
return GridEventDuplicateField(payload).send();
|
||||
return DatabaseEventDuplicateField(payload).send();
|
||||
}
|
||||
|
||||
Future<Either<TypeOptionPB, FlowyError>> getFieldTypeOptionData({
|
||||
required FieldType fieldType,
|
||||
}) {
|
||||
final payload = TypeOptionPathPB.create()
|
||||
..gridId = gridId
|
||||
..databaseId = databaseId
|
||||
..fieldId = fieldId
|
||||
..fieldType = fieldType;
|
||||
return GridEventGetFieldTypeOption(payload).send().then((result) {
|
||||
return DatabaseEventGetFieldTypeOption(payload).send().then((result) {
|
||||
return result.fold(
|
||||
(data) => left(data),
|
||||
(err) => right(err),
|
||||
@ -109,7 +109,7 @@ class FieldService {
|
||||
@freezed
|
||||
class GridFieldCellContext with _$GridFieldCellContext {
|
||||
const factory GridFieldCellContext({
|
||||
required String gridId,
|
||||
required String databaseId,
|
||||
required FieldPB field,
|
||||
}) = _GridFieldCellContext;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
|
@ -1,36 +1,36 @@
|
||||
import 'package:app_flowy/core/grid_notification.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/notification.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/notification.pb.dart';
|
||||
import 'package:flowy_infra/notifier.dart';
|
||||
import 'dart:async';
|
||||
import 'dart:typed_data';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
|
||||
typedef UpdateFieldNotifiedValue = Either<GridFieldChangesetPB, FlowyError>;
|
||||
typedef UpdateFieldNotifiedValue = Either<DatabaseFieldChangesetPB, FlowyError>;
|
||||
|
||||
class GridFieldsListener {
|
||||
final String gridId;
|
||||
class DatabaseFieldsListener {
|
||||
final String databaseId;
|
||||
PublishNotifier<UpdateFieldNotifiedValue>? updateFieldsNotifier =
|
||||
PublishNotifier();
|
||||
GridNotificationListener? _listener;
|
||||
GridFieldsListener({required this.gridId});
|
||||
DatabaseNotificationListener? _listener;
|
||||
DatabaseFieldsListener({required this.databaseId});
|
||||
|
||||
void start(
|
||||
{required void Function(UpdateFieldNotifiedValue) onFieldsChanged}) {
|
||||
updateFieldsNotifier?.addPublishListener(onFieldsChanged);
|
||||
_listener = GridNotificationListener(
|
||||
objectId: gridId,
|
||||
_listener = DatabaseNotificationListener(
|
||||
objectId: databaseId,
|
||||
handler: _handler,
|
||||
);
|
||||
}
|
||||
|
||||
void _handler(GridNotification ty, Either<Uint8List, FlowyError> result) {
|
||||
void _handler(DatabaseNotification ty, Either<Uint8List, FlowyError> result) {
|
||||
switch (ty) {
|
||||
case GridNotification.DidUpdateGridFields:
|
||||
case DatabaseNotification.DidUpdateDatabaseFields:
|
||||
result.fold(
|
||||
(payload) => updateFieldsNotifier?.value =
|
||||
left(GridFieldChangesetPB.fromBuffer(payload)),
|
||||
left(DatabaseFieldChangesetPB.fromBuffer(payload)),
|
||||
(error) => updateFieldsNotifier?.value = right(error),
|
||||
);
|
||||
break;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/date_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/date_type_option_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/date_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/date_type_option_entities.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/select_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
|
@ -1,6 +1,6 @@
|
||||
import 'package:appflowy_backend/log.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/multi_select_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/select_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/multi_select_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
||||
import 'dart:async';
|
||||
import 'select_option_type_option_bloc.dart';
|
||||
import 'type_option_context.dart';
|
||||
@ -8,17 +8,17 @@ import 'type_option_service.dart';
|
||||
import 'package:protobuf/protobuf.dart';
|
||||
|
||||
class MultiSelectAction with ISelectOptionAction {
|
||||
final String gridId;
|
||||
final String databaseId;
|
||||
final String fieldId;
|
||||
final TypeOptionFFIService service;
|
||||
final MultiSelectTypeOptionContext typeOptionContext;
|
||||
|
||||
MultiSelectAction({
|
||||
required this.gridId,
|
||||
required this.databaseId,
|
||||
required this.fieldId,
|
||||
required this.typeOptionContext,
|
||||
}) : service = TypeOptionFFIService(
|
||||
gridId: gridId,
|
||||
databaseId: databaseId,
|
||||
fieldId: fieldId,
|
||||
);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/format.pbenum.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/number_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/format.pbenum.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/number_type_option.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/format.pbenum.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/format.pbenum.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/select_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
|
@ -1,6 +1,6 @@
|
||||
import 'package:appflowy_backend/log.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/select_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/single_select_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/single_select_type_option.pb.dart';
|
||||
import 'dart:async';
|
||||
import 'package:protobuf/protobuf.dart';
|
||||
import 'select_option_type_option_bloc.dart';
|
||||
@ -8,16 +8,16 @@ import 'type_option_context.dart';
|
||||
import 'type_option_service.dart';
|
||||
|
||||
class SingleSelectAction with ISelectOptionAction {
|
||||
final String gridId;
|
||||
final String databaseId;
|
||||
final String fieldId;
|
||||
final SingleSelectTypeOptionContext typeOptionContext;
|
||||
final TypeOptionFFIService service;
|
||||
|
||||
SingleSelectAction({
|
||||
required this.gridId,
|
||||
required this.databaseId,
|
||||
required this.fieldId,
|
||||
required this.typeOptionContext,
|
||||
}) : service = TypeOptionFFIService(gridId: gridId, fieldId: fieldId);
|
||||
}) : service = TypeOptionFFIService(databaseId: databaseId, fieldId: fieldId);
|
||||
|
||||
SingleSelectTypeOptionPB get typeOption => typeOptionContext.typeOption;
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
import 'package:appflowy_backend/dispatch/dispatch.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/checkbox_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/checklist_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/date_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/checkbox_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/checklist_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/date_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/multi_select_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/number_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/single_select_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/text_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/url_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/multi_select_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/number_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/single_select_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/text_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/url_type_option.pb.dart';
|
||||
import 'package:protobuf/protobuf.dart';
|
||||
|
||||
import 'type_option_data_controller.dart';
|
||||
@ -117,7 +117,7 @@ class TypeOptionContext<T extends GeneratedMessage> {
|
||||
required TypeOptionDataController dataController,
|
||||
}) : _dataController = dataController;
|
||||
|
||||
String get gridId => _dataController.gridId;
|
||||
String get databaseId => _dataController.databaseId;
|
||||
|
||||
String get fieldId => _dataController.field.id;
|
||||
|
||||
@ -155,17 +155,17 @@ abstract class TypeOptionFieldDelegate {
|
||||
}
|
||||
|
||||
abstract class IFieldTypeOptionLoader {
|
||||
String get gridId;
|
||||
String get databaseId;
|
||||
Future<Either<TypeOptionPB, FlowyError>> load();
|
||||
|
||||
Future<Either<Unit, FlowyError>> switchToField(
|
||||
String fieldId, FieldType fieldType) {
|
||||
final payload = EditFieldChangesetPB.create()
|
||||
..gridId = gridId
|
||||
..databaseId = databaseId
|
||||
..fieldId = fieldId
|
||||
..fieldType = fieldType;
|
||||
|
||||
return GridEventSwitchToField(payload).send();
|
||||
return DatabaseEventSwitchToField(payload).send();
|
||||
}
|
||||
}
|
||||
|
||||
@ -174,9 +174,9 @@ class NewFieldTypeOptionLoader extends IFieldTypeOptionLoader {
|
||||
TypeOptionPB? fieldTypeOption;
|
||||
|
||||
@override
|
||||
final String gridId;
|
||||
final String databaseId;
|
||||
NewFieldTypeOptionLoader({
|
||||
required this.gridId,
|
||||
required this.databaseId,
|
||||
});
|
||||
|
||||
/// Creates the field type option if the fieldTypeOption is null.
|
||||
@ -185,17 +185,17 @@ class NewFieldTypeOptionLoader extends IFieldTypeOptionLoader {
|
||||
Future<Either<TypeOptionPB, FlowyError>> load() {
|
||||
if (fieldTypeOption != null) {
|
||||
final payload = TypeOptionPathPB.create()
|
||||
..gridId = gridId
|
||||
..databaseId = databaseId
|
||||
..fieldId = fieldTypeOption!.field_2.id
|
||||
..fieldType = fieldTypeOption!.field_2.fieldType;
|
||||
|
||||
return GridEventGetFieldTypeOption(payload).send();
|
||||
return DatabaseEventGetFieldTypeOption(payload).send();
|
||||
} else {
|
||||
final payload = CreateFieldPayloadPB.create()
|
||||
..gridId = gridId
|
||||
..databaseId = databaseId
|
||||
..fieldType = FieldType.RichText;
|
||||
|
||||
return GridEventCreateFieldTypeOption(payload).send().then((result) {
|
||||
return DatabaseEventCreateFieldTypeOption(payload).send().then((result) {
|
||||
return result.fold(
|
||||
(newFieldTypeOption) {
|
||||
fieldTypeOption = newFieldTypeOption;
|
||||
@ -211,21 +211,21 @@ class NewFieldTypeOptionLoader extends IFieldTypeOptionLoader {
|
||||
/// Uses when editing a existing field
|
||||
class FieldTypeOptionLoader extends IFieldTypeOptionLoader {
|
||||
@override
|
||||
final String gridId;
|
||||
final String databaseId;
|
||||
final FieldPB field;
|
||||
|
||||
FieldTypeOptionLoader({
|
||||
required this.gridId,
|
||||
required this.databaseId,
|
||||
required this.field,
|
||||
});
|
||||
|
||||
@override
|
||||
Future<Either<TypeOptionPB, FlowyError>> load() {
|
||||
final payload = TypeOptionPathPB.create()
|
||||
..gridId = gridId
|
||||
..databaseId = databaseId
|
||||
..fieldId = field.id
|
||||
..fieldType = field.fieldType;
|
||||
|
||||
return GridEventGetFieldTypeOption(payload).send();
|
||||
return DatabaseEventGetFieldTypeOption(payload).send();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'package:app_flowy/plugins/grid/application/field/field_controller.dart';
|
||||
import 'package:flowy_infra/notifier.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
import 'package:app_flowy/plugins/grid/application/field/field_service.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:protobuf/protobuf.dart' hide FieldInfo;
|
||||
@ -10,7 +10,7 @@ import 'package:appflowy_backend/log.dart';
|
||||
import 'type_option_context.dart';
|
||||
|
||||
class TypeOptionDataController {
|
||||
final String gridId;
|
||||
final String databaseId;
|
||||
final IFieldTypeOptionLoader loader;
|
||||
late TypeOptionPB _data;
|
||||
final PublishNotifier<FieldPB> _fieldNotifier = PublishNotifier();
|
||||
@ -22,13 +22,13 @@ class TypeOptionDataController {
|
||||
/// is null
|
||||
///
|
||||
TypeOptionDataController({
|
||||
required this.gridId,
|
||||
required this.databaseId,
|
||||
required this.loader,
|
||||
FieldInfo? fieldInfo,
|
||||
}) {
|
||||
if (fieldInfo != null) {
|
||||
_data = TypeOptionPB.create()
|
||||
..gridId = gridId
|
||||
..databaseId = databaseId
|
||||
..field_2 = fieldInfo.field;
|
||||
}
|
||||
}
|
||||
@ -66,7 +66,8 @@ class TypeOptionDataController {
|
||||
|
||||
_fieldNotifier.value = _data.field_2;
|
||||
|
||||
FieldService(gridId: gridId, fieldId: field.id).updateField(name: name);
|
||||
FieldService(databaseId: databaseId, fieldId: field.id)
|
||||
.updateField(name: name);
|
||||
}
|
||||
|
||||
set typeOptionData(List<int> typeOptionData) {
|
||||
@ -77,7 +78,7 @@ class TypeOptionDataController {
|
||||
});
|
||||
|
||||
FieldService.updateFieldTypeOption(
|
||||
gridId: gridId,
|
||||
databaseId: databaseId,
|
||||
fieldId: field.id,
|
||||
typeOptionData: typeOptionData,
|
||||
);
|
||||
|
@ -1,15 +1,15 @@
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:appflowy_backend/dispatch/dispatch.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/cell_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/select_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/cell_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
||||
|
||||
class TypeOptionFFIService {
|
||||
final String gridId;
|
||||
final String databaseId;
|
||||
final String fieldId;
|
||||
|
||||
TypeOptionFFIService({
|
||||
required this.gridId,
|
||||
required this.databaseId,
|
||||
required this.fieldId,
|
||||
});
|
||||
|
||||
@ -18,9 +18,9 @@ class TypeOptionFFIService {
|
||||
}) {
|
||||
final payload = CreateSelectOptionPayloadPB.create()
|
||||
..optionName = name
|
||||
..gridId = gridId
|
||||
..databaseId = databaseId
|
||||
..fieldId = fieldId;
|
||||
|
||||
return GridEventNewSelectOption(payload).send();
|
||||
return DatabaseEventNewSelectOption(payload).send();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import 'package:app_flowy/plugins/grid/presentation/widgets/filter/filter_info.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/checkbox_filter.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/util.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/checkbox_filter.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/util.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
@ -16,7 +16,7 @@ class CheckboxFilterEditorBloc
|
||||
final FilterListener _listener;
|
||||
|
||||
CheckboxFilterEditorBloc({required this.filterInfo})
|
||||
: _ffiService = FilterFFIService(viewId: filterInfo.viewId),
|
||||
: _ffiService = FilterFFIService(databaseId: filterInfo.viewId),
|
||||
_listener = FilterListener(
|
||||
viewId: filterInfo.viewId,
|
||||
filterId: filterInfo.filter.id,
|
||||
|
@ -1,6 +1,6 @@
|
||||
import 'package:app_flowy/plugins/grid/presentation/widgets/filter/filter_info.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/checklist_filter.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/util.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/checklist_filter.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/util.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
@ -18,7 +18,7 @@ class ChecklistFilterEditorBloc
|
||||
|
||||
ChecklistFilterEditorBloc({
|
||||
required this.filterInfo,
|
||||
}) : _ffiService = FilterFFIService(viewId: filterInfo.viewId),
|
||||
}) : _ffiService = FilterFFIService(databaseId: filterInfo.viewId),
|
||||
// _selectOptionService =
|
||||
// SelectOptionFFIService(cellId: cellController.cellId)
|
||||
_listener = FilterListener(
|
||||
|
@ -1,13 +1,13 @@
|
||||
import 'package:app_flowy/plugins/grid/application/field/field_controller.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pbserver.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/checkbox_filter.pbenum.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/checklist_filter.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/date_filter.pbenum.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/number_filter.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/select_option_filter.pbenum.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/text_filter.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/checkbox_filter.pbenum.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/checklist_filter.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/date_filter.pbenum.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/number_filter.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/select_option_filter.pbenum.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/text_filter.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
@ -22,7 +22,7 @@ class GridCreateFilterBloc
|
||||
final GridFieldController fieldController;
|
||||
void Function(List<FieldInfo>)? _onFieldFn;
|
||||
GridCreateFilterBloc({required this.viewId, required this.fieldController})
|
||||
: _ffiService = FilterFFIService(viewId: viewId),
|
||||
: _ffiService = FilterFFIService(databaseId: viewId),
|
||||
super(GridCreateFilterState.initial(fieldController.fieldInfos)) {
|
||||
on<GridCreateFilterEvent>(
|
||||
(event, emit) async {
|
||||
|
@ -3,10 +3,10 @@ import 'dart:typed_data';
|
||||
import 'package:app_flowy/core/grid_notification.dart';
|
||||
import 'package:flowy_infra/notifier.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/notification.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/filter_changeset.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/notification.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/filter_changeset.pb.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/util.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/util.pb.dart';
|
||||
|
||||
typedef UpdateFilterNotifiedValue
|
||||
= Either<FilterChangesetNotificationPB, FlowyError>;
|
||||
@ -16,25 +16,25 @@ class FiltersListener {
|
||||
|
||||
PublishNotifier<UpdateFilterNotifiedValue>? _filterNotifier =
|
||||
PublishNotifier();
|
||||
GridNotificationListener? _listener;
|
||||
DatabaseNotificationListener? _listener;
|
||||
FiltersListener({required this.viewId});
|
||||
|
||||
void start({
|
||||
required void Function(UpdateFilterNotifiedValue) onFilterChanged,
|
||||
}) {
|
||||
_filterNotifier?.addPublishListener(onFilterChanged);
|
||||
_listener = GridNotificationListener(
|
||||
_listener = DatabaseNotificationListener(
|
||||
objectId: viewId,
|
||||
handler: _handler,
|
||||
);
|
||||
}
|
||||
|
||||
void _handler(
|
||||
GridNotification ty,
|
||||
DatabaseNotification ty,
|
||||
Either<Uint8List, FlowyError> result,
|
||||
) {
|
||||
switch (ty) {
|
||||
case GridNotification.DidUpdateFilter:
|
||||
case DatabaseNotification.DidUpdateFilter:
|
||||
result.fold(
|
||||
(payload) => _filterNotifier?.value =
|
||||
left(FilterChangesetNotificationPB.fromBuffer(payload)),
|
||||
@ -60,7 +60,7 @@ class FilterListener {
|
||||
PublishNotifier<FilterPB>? _onDeleteNotifier = PublishNotifier();
|
||||
PublishNotifier<FilterPB>? _onUpdateNotifier = PublishNotifier();
|
||||
|
||||
GridNotificationListener? _listener;
|
||||
DatabaseNotificationListener? _listener;
|
||||
FilterListener({required this.viewId, required this.filterId});
|
||||
|
||||
void start({
|
||||
@ -75,7 +75,7 @@ class FilterListener {
|
||||
onUpdated?.call(filter);
|
||||
});
|
||||
|
||||
_listener = GridNotificationListener(
|
||||
_listener = DatabaseNotificationListener(
|
||||
objectId: viewId,
|
||||
handler: _handler,
|
||||
);
|
||||
@ -100,11 +100,11 @@ class FilterListener {
|
||||
}
|
||||
|
||||
void _handler(
|
||||
GridNotification ty,
|
||||
DatabaseNotification ty,
|
||||
Either<Uint8List, FlowyError> result,
|
||||
) {
|
||||
switch (ty) {
|
||||
case GridNotification.DidUpdateFilter:
|
||||
case DatabaseNotification.DidUpdateFilter:
|
||||
result.fold(
|
||||
(payload) => handleChangeset(
|
||||
FilterChangesetNotificationPB.fromBuffer(payload)),
|
||||
|
@ -2,26 +2,26 @@ import 'package:dartz/dartz.dart';
|
||||
import 'package:appflowy_backend/dispatch/dispatch.dart';
|
||||
import 'package:appflowy_backend/log.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/checkbox_filter.pbserver.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/checklist_filter.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/date_filter.pbserver.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/grid_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/number_filter.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/select_option_filter.pbserver.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/setting_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/text_filter.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/util.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/checkbox_filter.pbserver.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/checklist_filter.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/date_filter.pbserver.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/grid_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/number_filter.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/select_option_filter.pbserver.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/setting_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/text_filter.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/util.pb.dart';
|
||||
import 'package:fixnum/fixnum.dart' as $fixnum;
|
||||
|
||||
class FilterFFIService {
|
||||
final String viewId;
|
||||
const FilterFFIService({required this.viewId});
|
||||
final String databaseId;
|
||||
const FilterFFIService({required this.databaseId});
|
||||
|
||||
Future<Either<List<FilterPB>, FlowyError>> getAllFilters() {
|
||||
final payload = GridIdPB()..value = viewId;
|
||||
final payload = DatabaseIdPB()..value = databaseId;
|
||||
|
||||
return GridEventGetAllFilters(payload).send().then((result) {
|
||||
return DatabaseEventGetAllFilters(payload).send().then((result) {
|
||||
return result.fold(
|
||||
(repeated) => left(repeated.items),
|
||||
(r) => right(r),
|
||||
@ -171,17 +171,17 @@ class FilterFFIService {
|
||||
var insertFilterPayload = AlterFilterPayloadPB.create()
|
||||
..fieldId = fieldId
|
||||
..fieldType = fieldType
|
||||
..viewId = viewId
|
||||
..viewId = databaseId
|
||||
..data = data;
|
||||
|
||||
if (filterId != null) {
|
||||
insertFilterPayload.filterId = filterId;
|
||||
}
|
||||
|
||||
final payload = GridSettingChangesetPB.create()
|
||||
..gridId = viewId
|
||||
final payload = DatabaseSettingChangesetPB.create()
|
||||
..databaseId = databaseId
|
||||
..alterFilter = insertFilterPayload;
|
||||
return GridEventUpdateGridSetting(payload).send().then((result) {
|
||||
return DatabaseEventUpdateDatabaseSetting(payload).send().then((result) {
|
||||
return result.fold(
|
||||
(l) => left(l),
|
||||
(err) {
|
||||
@ -200,14 +200,14 @@ class FilterFFIService {
|
||||
final deleteFilterPayload = DeleteFilterPayloadPB.create()
|
||||
..fieldId = fieldId
|
||||
..filterId = filterId
|
||||
..viewId = viewId
|
||||
..viewId = databaseId
|
||||
..fieldType = fieldType;
|
||||
|
||||
final payload = GridSettingChangesetPB.create()
|
||||
..gridId = viewId
|
||||
final payload = DatabaseSettingChangesetPB.create()
|
||||
..databaseId = databaseId
|
||||
..deleteFilter = deleteFilterPayload;
|
||||
|
||||
return GridEventUpdateGridSetting(payload).send().then((result) {
|
||||
return DatabaseEventUpdateDatabaseSetting(payload).send().then((result) {
|
||||
return result.fold(
|
||||
(l) => left(l),
|
||||
(err) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'package:app_flowy/plugins/grid/presentation/widgets/filter/choicechip/select_option/select_option_loader.dart';
|
||||
import 'package:app_flowy/plugins/grid/presentation/widgets/filter/filter_info.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/select_option_filter.pbserver.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/util.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/select_option_filter.pbserver.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/util.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
@ -20,7 +20,7 @@ class SelectOptionFilterEditorBloc
|
||||
SelectOptionFilterEditorBloc({
|
||||
required this.filterInfo,
|
||||
required this.delegate,
|
||||
}) : _ffiService = FilterFFIService(viewId: filterInfo.viewId),
|
||||
}) : _ffiService = FilterFFIService(databaseId: filterInfo.viewId),
|
||||
_listener = FilterListener(
|
||||
viewId: filterInfo.viewId,
|
||||
filterId: filterInfo.filter.id,
|
||||
|
@ -1,8 +1,8 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:app_flowy/plugins/grid/presentation/widgets/filter/choicechip/select_option/select_option_loader.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/select_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import 'package:app_flowy/plugins/grid/presentation/widgets/filter/filter_info.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/text_filter.pbserver.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/util.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/text_filter.pbserver.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/util.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
@ -16,7 +16,7 @@ class TextFilterEditorBloc
|
||||
final FilterListener _listener;
|
||||
|
||||
TextFilterEditorBloc({required this.filterInfo})
|
||||
: _ffiService = FilterFFIService(viewId: filterInfo.viewId),
|
||||
: _ffiService = FilterFFIService(databaseId: filterInfo.viewId),
|
||||
_listener = FilterListener(
|
||||
viewId: filterInfo.viewId,
|
||||
filterId: filterInfo.filter.id,
|
||||
|
@ -3,7 +3,7 @@ import 'package:dartz/dartz.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/protobuf.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/protobuf.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'field/field_controller.dart';
|
||||
@ -37,7 +37,7 @@ class GridBloc extends Bloc<GridEvent, GridState> {
|
||||
},
|
||||
deleteRow: (rowInfo) async {
|
||||
final rowService = RowFFIService(
|
||||
gridId: rowInfo.gridId,
|
||||
databaseId: rowInfo.databaseId,
|
||||
);
|
||||
await rowService.deleteRow(rowInfo.rowPB.id);
|
||||
},
|
||||
@ -124,15 +124,15 @@ class GridEvent with _$GridEvent {
|
||||
) = _DidReceiveFieldUpdate;
|
||||
|
||||
const factory GridEvent.didReceiveGridUpdate(
|
||||
GridPB grid,
|
||||
DatabasePB grid,
|
||||
) = _DidReceiveGridUpdate;
|
||||
}
|
||||
|
||||
@freezed
|
||||
class GridState with _$GridState {
|
||||
const factory GridState({
|
||||
required String gridId,
|
||||
required Option<GridPB> grid,
|
||||
required String databaseId,
|
||||
required Option<DatabasePB> grid,
|
||||
required GridFieldEquatable fields,
|
||||
required List<RowInfo> rowInfos,
|
||||
required int rowCount,
|
||||
@ -140,12 +140,12 @@ class GridState with _$GridState {
|
||||
required RowsChangedReason reason,
|
||||
}) = _GridState;
|
||||
|
||||
factory GridState.initial(String gridId) => GridState(
|
||||
factory GridState.initial(String databaseId) => GridState(
|
||||
fields: GridFieldEquatable(UnmodifiableListView([])),
|
||||
rowInfos: [],
|
||||
rowCount: 0,
|
||||
grid: none(),
|
||||
gridId: gridId,
|
||||
databaseId: databaseId,
|
||||
loadingState: const _Loading(),
|
||||
reason: const InitialListState(),
|
||||
);
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'package:app_flowy/plugins/grid/presentation/widgets/filter/filter_info.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/grid_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/grid_entities.pb.dart';
|
||||
import 'dart:async';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'view/grid_view_cache.dart';
|
||||
@ -11,7 +11,7 @@ import 'row/row_cache.dart';
|
||||
|
||||
typedef OnFieldsChanged = void Function(List<FieldInfo>);
|
||||
typedef OnFiltersChanged = void Function(List<FilterInfo>);
|
||||
typedef OnGridChanged = void Function(GridPB);
|
||||
typedef OnGridChanged = void Function(DatabasePB);
|
||||
|
||||
typedef OnRowsChanged = void Function(
|
||||
List<RowInfo> rowInfos,
|
||||
@ -20,10 +20,10 @@ typedef OnRowsChanged = void Function(
|
||||
typedef ListenOnRowChangedCondition = bool Function();
|
||||
|
||||
class GridController {
|
||||
final String gridId;
|
||||
final GridFFIService _gridFFIService;
|
||||
final String databaseId;
|
||||
final DatabaseFFIService _gridFFIService;
|
||||
final GridFieldController fieldController;
|
||||
late GridViewCache _viewCache;
|
||||
late DatabaseViewCache _viewCache;
|
||||
|
||||
OnRowsChanged? _onRowChanged;
|
||||
OnGridChanged? _onGridChanged;
|
||||
@ -31,11 +31,11 @@ class GridController {
|
||||
GridRowCache get rowCache => _viewCache.rowCache;
|
||||
|
||||
GridController({required ViewPB view})
|
||||
: gridId = view.id,
|
||||
_gridFFIService = GridFFIService(gridId: view.id),
|
||||
fieldController = GridFieldController(gridId: view.id) {
|
||||
_viewCache = GridViewCache(
|
||||
gridId: gridId,
|
||||
: databaseId = view.id,
|
||||
_gridFFIService = DatabaseFFIService(databaseId: view.id),
|
||||
fieldController = GridFieldController(databaseId: view.id) {
|
||||
_viewCache = DatabaseViewCache(
|
||||
databaseId: databaseId,
|
||||
fieldController: fieldController,
|
||||
);
|
||||
_viewCache.addListener(onRowsChanged: (reason) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import 'package:app_flowy/plugins/grid/application/field/field_service.dart';
|
||||
import 'package:appflowy_backend/log.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
@ -10,10 +10,10 @@ part 'grid_header_bloc.freezed.dart';
|
||||
|
||||
class GridHeaderBloc extends Bloc<GridHeaderEvent, GridHeaderState> {
|
||||
final GridFieldController fieldController;
|
||||
final String gridId;
|
||||
final String databaseId;
|
||||
|
||||
GridHeaderBloc({
|
||||
required this.gridId,
|
||||
required this.databaseId,
|
||||
required this.fieldController,
|
||||
}) : super(GridHeaderState.initial(fieldController.fieldInfos)) {
|
||||
on<GridHeaderEvent>(
|
||||
@ -45,7 +45,8 @@ class GridHeaderBloc extends Bloc<GridHeaderEvent, GridHeaderState> {
|
||||
fields.insert(value.toIndex, fields.removeAt(value.fromIndex));
|
||||
emit(state.copyWith(fields: fields));
|
||||
|
||||
final fieldService = FieldService(gridId: gridId, fieldId: value.field.id);
|
||||
final fieldService =
|
||||
FieldService(databaseId: databaseId, fieldId: value.field.id);
|
||||
final result = await fieldService.moveField(
|
||||
value.fromIndex,
|
||||
value.toIndex,
|
||||
|
@ -2,28 +2,28 @@ import 'package:dartz/dartz.dart';
|
||||
import 'package:appflowy_backend/dispatch/dispatch.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/grid_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/group.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/row_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/grid_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/group.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/row_entities.pb.dart';
|
||||
|
||||
class GridFFIService {
|
||||
final String gridId;
|
||||
GridFFIService({
|
||||
required this.gridId,
|
||||
class DatabaseFFIService {
|
||||
final String databaseId;
|
||||
DatabaseFFIService({
|
||||
required this.databaseId,
|
||||
});
|
||||
|
||||
Future<Either<GridPB, FlowyError>> openGrid() async {
|
||||
await FolderEventSetLatestView(ViewIdPB(value: gridId)).send();
|
||||
Future<Either<DatabasePB, FlowyError>> openGrid() async {
|
||||
await FolderEventSetLatestView(ViewIdPB(value: databaseId)).send();
|
||||
|
||||
final payload = GridIdPB(value: gridId);
|
||||
return GridEventGetGrid(payload).send();
|
||||
final payload = DatabaseIdPB(value: databaseId);
|
||||
return DatabaseEventGetDatabase(payload).send();
|
||||
}
|
||||
|
||||
Future<Either<RowPB, FlowyError>> createRow({Option<String>? startRowId}) {
|
||||
var payload = CreateTableRowPayloadPB.create()..gridId = gridId;
|
||||
var payload = CreateTableRowPayloadPB.create()..databaseId = databaseId;
|
||||
startRowId?.fold(() => null, (id) => payload.startRowId = id);
|
||||
return GridEventCreateTableRow(payload).send();
|
||||
return DatabaseEventCreateTableRow(payload).send();
|
||||
}
|
||||
|
||||
Future<Either<RowPB, FlowyError>> createBoardCard(
|
||||
@ -31,35 +31,35 @@ class GridFFIService {
|
||||
String? startRowId,
|
||||
) {
|
||||
CreateBoardCardPayloadPB payload = CreateBoardCardPayloadPB.create()
|
||||
..gridId = gridId
|
||||
..databaseId = databaseId
|
||||
..groupId = groupId;
|
||||
|
||||
if (startRowId != null) {
|
||||
payload.startRowId = startRowId;
|
||||
}
|
||||
|
||||
return GridEventCreateBoardCard(payload).send();
|
||||
return DatabaseEventCreateBoardCard(payload).send();
|
||||
}
|
||||
|
||||
Future<Either<List<FieldPB>, FlowyError>> getFields(
|
||||
{List<FieldIdPB>? fieldIds}) {
|
||||
var payload = GetFieldPayloadPB.create()..gridId = gridId;
|
||||
var payload = GetFieldPayloadPB.create()..databaseId = databaseId;
|
||||
|
||||
if (fieldIds != null) {
|
||||
payload.fieldIds = RepeatedFieldIdPB(items: fieldIds);
|
||||
}
|
||||
return GridEventGetFields(payload).send().then((result) {
|
||||
return DatabaseEventGetFields(payload).send().then((result) {
|
||||
return result.fold((l) => left(l.items), (r) => right(r));
|
||||
});
|
||||
}
|
||||
|
||||
Future<Either<Unit, FlowyError>> closeGrid() {
|
||||
final request = ViewIdPB(value: gridId);
|
||||
final request = ViewIdPB(value: databaseId);
|
||||
return FolderEventCloseView(request).send();
|
||||
}
|
||||
|
||||
Future<Either<RepeatedGroupPB, FlowyError>> loadGroups() {
|
||||
final payload = GridIdPB(value: gridId);
|
||||
return GridEventGetGroup(payload).send();
|
||||
final payload = DatabaseIdPB(value: databaseId);
|
||||
return DatabaseEventGetGroup(payload).send();
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ class RowActionSheetBloc
|
||||
final RowFFIService _rowService;
|
||||
|
||||
RowActionSheetBloc({required RowInfo rowInfo})
|
||||
: _rowService = RowFFIService(gridId: rowInfo.gridId),
|
||||
: _rowService = RowFFIService(databaseId: rowInfo.databaseId),
|
||||
super(RowActionSheetState.initial(rowInfo)) {
|
||||
on<RowActionSheetEvent>(
|
||||
(event, emit) async {
|
||||
|
@ -18,7 +18,7 @@ class RowBloc extends Bloc<RowEvent, RowState> {
|
||||
RowBloc({
|
||||
required RowInfo rowInfo,
|
||||
required RowDataController dataController,
|
||||
}) : _rowService = RowFFIService(gridId: rowInfo.gridId),
|
||||
}) : _rowService = RowFFIService(databaseId: rowInfo.databaseId),
|
||||
_dataController = dataController,
|
||||
super(RowState.initial(rowInfo, dataController.loadData())) {
|
||||
on<RowEvent>(
|
||||
|
@ -3,7 +3,7 @@ import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_servic
|
||||
import 'package:app_flowy/plugins/grid/application/field/field_controller.dart';
|
||||
import 'package:appflowy_backend/dispatch/dispatch.dart';
|
||||
import 'package:appflowy_backend/log.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/protobuf.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/protobuf.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
@ -28,7 +28,7 @@ abstract class RowCacheDelegate {
|
||||
/// Read https://appflowy.gitbook.io/docs/essential-documentation/contribute-to-appflowy/architecture/frontend/grid for more information.
|
||||
|
||||
class GridRowCache {
|
||||
final String gridId;
|
||||
final String databaseId;
|
||||
final List<RowPB> rows;
|
||||
|
||||
/// _rows containers the current block's rows
|
||||
@ -47,11 +47,11 @@ class GridRowCache {
|
||||
GridCellCache get cellCache => _cellCache;
|
||||
|
||||
GridRowCache({
|
||||
required this.gridId,
|
||||
required this.databaseId,
|
||||
required this.rows,
|
||||
required RowChangesetNotifierForward notifier,
|
||||
required RowCacheDelegate delegate,
|
||||
}) : _cellCache = GridCellCache(gridId: gridId),
|
||||
}) : _cellCache = GridCellCache(databaseId: databaseId),
|
||||
_rowChangeReasonNotifier = RowChangesetNotifier(),
|
||||
_delegate = delegate {
|
||||
//
|
||||
@ -74,13 +74,13 @@ class GridRowCache {
|
||||
await _cellCache.dispose();
|
||||
}
|
||||
|
||||
void applyRowsChanged(GridViewRowsChangesetPB changeset) {
|
||||
void applyRowsChanged(ViewRowsChangesetPB changeset) {
|
||||
_deleteRows(changeset.deletedRows);
|
||||
_insertRows(changeset.insertedRows);
|
||||
_updateRows(changeset.updatedRows);
|
||||
}
|
||||
|
||||
void applyRowsVisibility(GridRowsVisibilityChangesetPB changeset) {
|
||||
void applyRowsVisibility(ViewRowsVisibilityChangesetPB changeset) {
|
||||
_hideRows(changeset.invisibleRows);
|
||||
_showRows(changeset.visibleRows);
|
||||
}
|
||||
@ -216,10 +216,10 @@ class GridRowCache {
|
||||
|
||||
Future<void> _loadRow(String rowId) async {
|
||||
final payload = RowIdPB.create()
|
||||
..gridId = gridId
|
||||
..databaseId = databaseId
|
||||
..rowId = rowId;
|
||||
|
||||
final result = await GridEventGetRow(payload).send();
|
||||
final result = await DatabaseEventGetRow(payload).send();
|
||||
result.fold(
|
||||
(optionRow) => _refreshRow(optionRow),
|
||||
(err) => Log.error(err),
|
||||
@ -233,7 +233,7 @@ class GridRowCache {
|
||||
if (field.visibility) {
|
||||
cellDataMap[field.id] = GridCellIdentifier(
|
||||
rowId: rowId,
|
||||
gridId: gridId,
|
||||
databaseId: databaseId,
|
||||
fieldInfo: field,
|
||||
);
|
||||
}
|
||||
@ -267,7 +267,7 @@ class GridRowCache {
|
||||
|
||||
RowInfo buildGridRow(RowPB rowPB) {
|
||||
return RowInfo(
|
||||
gridId: gridId,
|
||||
databaseId: databaseId,
|
||||
fields: _delegate.fields,
|
||||
rowPB: rowPB,
|
||||
);
|
||||
@ -296,7 +296,7 @@ class RowChangesetNotifier extends ChangeNotifier {
|
||||
@unfreezed
|
||||
class RowInfo with _$RowInfo {
|
||||
factory RowInfo({
|
||||
required String gridId,
|
||||
required String databaseId,
|
||||
required UnmodifiableListView<FieldInfo> fields,
|
||||
required RowPB rowPB,
|
||||
}) = _RowInfo;
|
||||
|
@ -27,7 +27,7 @@ class RowDetailBloc extends Bloc<RowDetailEvent, RowDetailState> {
|
||||
},
|
||||
deleteField: (_DeleteField value) {
|
||||
final fieldService = FieldService(
|
||||
gridId: dataController.rowInfo.gridId,
|
||||
databaseId: dataController.rowInfo.databaseId,
|
||||
fieldId: value.fieldId,
|
||||
);
|
||||
fieldService.deleteField();
|
||||
|
@ -1,6 +1,6 @@
|
||||
import 'dart:collection';
|
||||
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/row_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/row_entities.pb.dart';
|
||||
|
||||
import 'row_cache.dart';
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
import 'package:app_flowy/core/grid_notification.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/notification.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/notification.pb.dart';
|
||||
import 'package:flowy_infra/notifier.dart';
|
||||
import 'dart:async';
|
||||
import 'dart:typed_data';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/row_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/row_entities.pb.dart';
|
||||
|
||||
typedef UpdateRowNotifiedValue = Either<RowPB, FlowyError>;
|
||||
typedef UpdateFieldNotifiedValue = Either<List<FieldPB>, FlowyError>;
|
||||
@ -15,17 +15,18 @@ class RowListener {
|
||||
final String rowId;
|
||||
PublishNotifier<UpdateRowNotifiedValue>? updateRowNotifier =
|
||||
PublishNotifier();
|
||||
GridNotificationListener? _listener;
|
||||
DatabaseNotificationListener? _listener;
|
||||
|
||||
RowListener({required this.rowId});
|
||||
|
||||
void start() {
|
||||
_listener = GridNotificationListener(objectId: rowId, handler: _handler);
|
||||
_listener =
|
||||
DatabaseNotificationListener(objectId: rowId, handler: _handler);
|
||||
}
|
||||
|
||||
void _handler(GridNotification ty, Either<Uint8List, FlowyError> result) {
|
||||
void _handler(DatabaseNotification ty, Either<Uint8List, FlowyError> result) {
|
||||
switch (ty) {
|
||||
case GridNotification.DidUpdateRow:
|
||||
case DatabaseNotification.DidUpdateRow:
|
||||
result.fold(
|
||||
(payload) =>
|
||||
updateRowNotifier?.value = left(RowPB.fromBuffer(payload)),
|
||||
|
@ -1,55 +1,55 @@
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:appflowy_backend/dispatch/dispatch.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/grid_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/group_changeset.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/row_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/grid_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/group_changeset.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/row_entities.pb.dart';
|
||||
|
||||
class RowFFIService {
|
||||
final String gridId;
|
||||
final String databaseId;
|
||||
|
||||
RowFFIService({
|
||||
required this.gridId,
|
||||
required this.databaseId,
|
||||
});
|
||||
|
||||
Future<Either<RowPB, FlowyError>> createRow(String rowId) {
|
||||
final payload = CreateTableRowPayloadPB.create()
|
||||
..gridId = gridId
|
||||
..databaseId = databaseId
|
||||
..startRowId = rowId;
|
||||
|
||||
return GridEventCreateTableRow(payload).send();
|
||||
return DatabaseEventCreateTableRow(payload).send();
|
||||
}
|
||||
|
||||
Future<Either<OptionalRowPB, FlowyError>> getRow(String rowId) {
|
||||
final payload = RowIdPB.create()
|
||||
..gridId = gridId
|
||||
..databaseId = databaseId
|
||||
..rowId = rowId;
|
||||
|
||||
return GridEventGetRow(payload).send();
|
||||
return DatabaseEventGetRow(payload).send();
|
||||
}
|
||||
|
||||
Future<Either<Unit, FlowyError>> deleteRow(String rowId) {
|
||||
final payload = RowIdPB.create()
|
||||
..gridId = gridId
|
||||
..databaseId = databaseId
|
||||
..rowId = rowId;
|
||||
|
||||
return GridEventDeleteRow(payload).send();
|
||||
return DatabaseEventDeleteRow(payload).send();
|
||||
}
|
||||
|
||||
Future<Either<Unit, FlowyError>> duplicateRow(String rowId) {
|
||||
final payload = RowIdPB.create()
|
||||
..gridId = gridId
|
||||
..databaseId = databaseId
|
||||
..rowId = rowId;
|
||||
|
||||
return GridEventDuplicateRow(payload).send();
|
||||
return DatabaseEventDuplicateRow(payload).send();
|
||||
}
|
||||
}
|
||||
|
||||
class MoveRowFFIService {
|
||||
final String gridId;
|
||||
final String viewId;
|
||||
|
||||
MoveRowFFIService({
|
||||
required this.gridId,
|
||||
required this.viewId,
|
||||
});
|
||||
|
||||
Future<Either<Unit, FlowyError>> moveRow({
|
||||
@ -57,11 +57,11 @@ class MoveRowFFIService {
|
||||
required String toRowId,
|
||||
}) {
|
||||
var payload = MoveRowPayloadPB.create()
|
||||
..viewId = gridId
|
||||
..viewId = viewId
|
||||
..fromRowId = fromRowId
|
||||
..toRowId = toRowId;
|
||||
|
||||
return GridEventMoveRow(payload).send();
|
||||
return DatabaseEventMoveRow(payload).send();
|
||||
}
|
||||
|
||||
Future<Either<Unit, FlowyError>> moveGroupRow({
|
||||
@ -70,7 +70,7 @@ class MoveRowFFIService {
|
||||
required String? toRowId,
|
||||
}) {
|
||||
var payload = MoveGroupRowPayloadPB.create()
|
||||
..viewId = gridId
|
||||
..viewId = viewId
|
||||
..fromRowId = fromRowId
|
||||
..toGroupId = toGroupId;
|
||||
|
||||
@ -78,7 +78,7 @@ class MoveRowFFIService {
|
||||
payload.toRowId = toRowId;
|
||||
}
|
||||
|
||||
return GridEventMoveGroupRow(payload).send();
|
||||
return DatabaseEventMoveGroupRow(payload).send();
|
||||
}
|
||||
|
||||
Future<Either<Unit, FlowyError>> moveGroup({
|
||||
@ -86,10 +86,10 @@ class MoveRowFFIService {
|
||||
required String toGroupId,
|
||||
}) {
|
||||
final payload = MoveGroupPayloadPB.create()
|
||||
..viewId = gridId
|
||||
..viewId = viewId
|
||||
..fromGroupId = fromGroupId
|
||||
..toGroupId = toGroupId;
|
||||
|
||||
return GridEventMoveGroup(payload).send();
|
||||
return DatabaseEventMoveGroup(payload).send();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:appflowy_backend/log.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
@ -74,14 +74,14 @@ class GridGroupEvent with _$GridGroupEvent {
|
||||
@freezed
|
||||
class GridGroupState with _$GridGroupState {
|
||||
const factory GridGroupState({
|
||||
required String gridId,
|
||||
required String databaseId,
|
||||
required List<FieldInfo> fieldContexts,
|
||||
}) = _GridGroupState;
|
||||
|
||||
factory GridGroupState.initial(
|
||||
String gridId, List<FieldInfo> fieldContexts) =>
|
||||
String databaseId, List<FieldInfo> fieldContexts) =>
|
||||
GridGroupState(
|
||||
gridId: gridId,
|
||||
databaseId: databaseId,
|
||||
fieldContexts: fieldContexts,
|
||||
);
|
||||
}
|
||||
|
@ -13,9 +13,11 @@ class GridPropertyBloc extends Bloc<GridPropertyEvent, GridPropertyState> {
|
||||
Function(List<FieldInfo>)? _onFieldsFn;
|
||||
|
||||
GridPropertyBloc(
|
||||
{required String gridId, required GridFieldController fieldController})
|
||||
{required String databaseId,
|
||||
required GridFieldController fieldController})
|
||||
: _fieldController = fieldController,
|
||||
super(GridPropertyState.initial(gridId, fieldController.fieldInfos)) {
|
||||
super(
|
||||
GridPropertyState.initial(databaseId, fieldController.fieldInfos)) {
|
||||
on<GridPropertyEvent>(
|
||||
(event, emit) async {
|
||||
await event.map(
|
||||
@ -24,7 +26,7 @@ class GridPropertyBloc extends Bloc<GridPropertyEvent, GridPropertyState> {
|
||||
},
|
||||
setFieldVisibility: (_SetFieldVisibility value) async {
|
||||
final fieldService =
|
||||
FieldService(gridId: gridId, fieldId: value.fieldId);
|
||||
FieldService(databaseId: databaseId, fieldId: value.fieldId);
|
||||
final result =
|
||||
await fieldService.updateField(visibility: value.visibility);
|
||||
result.fold(
|
||||
@ -76,16 +78,16 @@ class GridPropertyEvent with _$GridPropertyEvent {
|
||||
@freezed
|
||||
class GridPropertyState with _$GridPropertyState {
|
||||
const factory GridPropertyState({
|
||||
required String gridId,
|
||||
required String databaseId,
|
||||
required List<FieldInfo> fieldContexts,
|
||||
}) = _GridPropertyState;
|
||||
|
||||
factory GridPropertyState.initial(
|
||||
String gridId,
|
||||
String databaseId,
|
||||
List<FieldInfo> fieldContexts,
|
||||
) =>
|
||||
GridPropertyState(
|
||||
gridId: gridId,
|
||||
databaseId: databaseId,
|
||||
fieldContexts: fieldContexts,
|
||||
);
|
||||
}
|
||||
|
@ -6,8 +6,9 @@ import 'package:dartz/dartz.dart';
|
||||
part 'setting_bloc.freezed.dart';
|
||||
|
||||
class GridSettingBloc extends Bloc<GridSettingEvent, GridSettingState> {
|
||||
final String gridId;
|
||||
GridSettingBloc({required this.gridId}) : super(GridSettingState.initial()) {
|
||||
final String databaseId;
|
||||
GridSettingBloc({required this.databaseId})
|
||||
: super(GridSettingState.initial()) {
|
||||
on<GridSettingEvent>(
|
||||
(event, emit) async {
|
||||
event.map(performAction: (_PerformAction value) {
|
||||
|
@ -1,24 +1,24 @@
|
||||
import 'package:app_flowy/plugins/grid/application/setting/setting_service.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/setting_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/setting_entities.pb.dart';
|
||||
import 'setting_listener.dart';
|
||||
|
||||
typedef OnError = void Function(FlowyError);
|
||||
typedef OnSettingUpdated = void Function(GridSettingPB);
|
||||
typedef OnSettingUpdated = void Function(DatabaseViewSettingPB);
|
||||
|
||||
class SettingController {
|
||||
final String viewId;
|
||||
final SettingFFIService _ffiService;
|
||||
final SettingListener _listener;
|
||||
final DatabaseSettingListener _listener;
|
||||
OnSettingUpdated? _onSettingUpdated;
|
||||
OnError? _onError;
|
||||
GridSettingPB? _setting;
|
||||
GridSettingPB? get setting => _setting;
|
||||
DatabaseViewSettingPB? _setting;
|
||||
DatabaseViewSettingPB? get setting => _setting;
|
||||
|
||||
SettingController({
|
||||
required this.viewId,
|
||||
}) : _ffiService = SettingFFIService(viewId: viewId),
|
||||
_listener = SettingListener(gridId: viewId) {
|
||||
_listener = DatabaseSettingListener(databaseId: viewId) {
|
||||
// Load setting
|
||||
_ffiService.getSetting().then((result) {
|
||||
result.fold(
|
||||
@ -46,7 +46,7 @@ class SettingController {
|
||||
_onError = onError;
|
||||
}
|
||||
|
||||
void updateSetting(GridSettingPB newSetting) {
|
||||
void updateSetting(DatabaseViewSettingPB newSetting) {
|
||||
_setting = newSetting;
|
||||
_onSettingUpdated?.call(newSetting);
|
||||
}
|
||||
|
@ -4,32 +4,33 @@ import 'package:app_flowy/core/grid_notification.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_infra/notifier.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/notification.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/setting_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/notification.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/setting_entities.pb.dart';
|
||||
|
||||
typedef UpdateSettingNotifiedValue = Either<GridSettingPB, FlowyError>;
|
||||
typedef UpdateSettingNotifiedValue = Either<DatabaseViewSettingPB, FlowyError>;
|
||||
|
||||
class SettingListener {
|
||||
final String gridId;
|
||||
GridNotificationListener? _listener;
|
||||
class DatabaseSettingListener {
|
||||
final String databaseId;
|
||||
DatabaseNotificationListener? _listener;
|
||||
PublishNotifier<UpdateSettingNotifiedValue>? _updateSettingNotifier =
|
||||
PublishNotifier();
|
||||
|
||||
SettingListener({required this.gridId});
|
||||
DatabaseSettingListener({required this.databaseId});
|
||||
|
||||
void start({
|
||||
required void Function(UpdateSettingNotifiedValue) onSettingUpdated,
|
||||
}) {
|
||||
_updateSettingNotifier?.addPublishListener(onSettingUpdated);
|
||||
_listener = GridNotificationListener(objectId: gridId, handler: _handler);
|
||||
_listener =
|
||||
DatabaseNotificationListener(objectId: databaseId, handler: _handler);
|
||||
}
|
||||
|
||||
void _handler(GridNotification ty, Either<Uint8List, FlowyError> result) {
|
||||
void _handler(DatabaseNotification ty, Either<Uint8List, FlowyError> result) {
|
||||
switch (ty) {
|
||||
case GridNotification.DidUpdateGridSetting:
|
||||
case DatabaseNotification.DidUpdateDatabaseSetting:
|
||||
result.fold(
|
||||
(payload) => _updateSettingNotifier?.value = left(
|
||||
GridSettingPB.fromBuffer(payload),
|
||||
DatabaseViewSettingPB.fromBuffer(payload),
|
||||
),
|
||||
(error) => _updateSettingNotifier?.value = right(error),
|
||||
);
|
||||
|
@ -1,19 +1,19 @@
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:appflowy_backend/dispatch/dispatch.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/grid_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/group.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/setting_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/grid_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/group.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/setting_entities.pb.dart';
|
||||
|
||||
class SettingFFIService {
|
||||
final String viewId;
|
||||
|
||||
const SettingFFIService({required this.viewId});
|
||||
|
||||
Future<Either<GridSettingPB, FlowyError>> getSetting() {
|
||||
final payload = GridIdPB.create()..value = viewId;
|
||||
return GridEventGetGridSetting(payload).send();
|
||||
Future<Either<DatabaseViewSettingPB, FlowyError>> getSetting() {
|
||||
final payload = DatabaseIdPB.create()..value = viewId;
|
||||
return DatabaseEventGetDatabaseSetting(payload).send();
|
||||
}
|
||||
|
||||
Future<Either<Unit, FlowyError>> groupByField({
|
||||
@ -23,10 +23,10 @@ class SettingFFIService {
|
||||
final insertGroupPayload = InsertGroupPayloadPB.create()
|
||||
..fieldId = fieldId
|
||||
..fieldType = fieldType;
|
||||
final payload = GridSettingChangesetPB.create()
|
||||
..gridId = viewId
|
||||
final payload = DatabaseSettingChangesetPB.create()
|
||||
..databaseId = viewId
|
||||
..insertGroup = insertGroupPayload;
|
||||
|
||||
return GridEventUpdateGridSetting(payload).send();
|
||||
return DatabaseEventUpdateDatabaseSetting(payload).send();
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
import 'package:app_flowy/plugins/grid/application/field/field_controller.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pbserver.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/sort_entities.pbenum.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/sort_entities.pbserver.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/sort_entities.pbenum.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/sort_entities.pbserver.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
@ -84,7 +84,7 @@ class CreateSortBloc extends Bloc<CreateSortEvent, CreateSortState> {
|
||||
final result = await _ffiService.insertSort(
|
||||
fieldId: field.id,
|
||||
fieldType: field.fieldType,
|
||||
condition: GridSortConditionPB.Ascending);
|
||||
condition: SortConditionPB.Ascending);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
import 'package:app_flowy/plugins/grid/application/field/field_controller.dart';
|
||||
import 'package:app_flowy/plugins/grid/presentation/widgets/sort/sort_info.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/sort_entities.pbenum.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/sort_entities.pbenum.dart';
|
||||
import 'package:appflowy_backend/log.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/sort_entities.pbserver.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/sort_entities.pbserver.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
@ -40,8 +40,7 @@ class SortEditorBloc extends Bloc<SortEditorEvent, SortEditorState> {
|
||||
),
|
||||
);
|
||||
},
|
||||
setCondition:
|
||||
(SortInfo sortInfo, GridSortConditionPB condition) async {
|
||||
setCondition: (SortInfo sortInfo, SortConditionPB condition) async {
|
||||
final result = await _ffiService.updateSort(
|
||||
fieldId: sortInfo.fieldInfo.id,
|
||||
sortId: sortInfo.sortId,
|
||||
@ -102,7 +101,7 @@ class SortEditorEvent with _$SortEditorEvent {
|
||||
const factory SortEditorEvent.didReceiveSorts(List<SortInfo> sortInfos) =
|
||||
_DidReceiveSorts;
|
||||
const factory SortEditorEvent.setCondition(
|
||||
SortInfo sortInfo, GridSortConditionPB condition) = _SetCondition;
|
||||
SortInfo sortInfo, SortConditionPB condition) = _SetCondition;
|
||||
const factory SortEditorEvent.deleteSort(SortInfo sortInfo) = _DeleteSort;
|
||||
const factory SortEditorEvent.deleteAllSorts() = _DeleteAllSorts;
|
||||
}
|
||||
|
@ -4,15 +4,15 @@ import 'package:app_flowy/core/grid_notification.dart';
|
||||
import 'package:flowy_infra/notifier.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/notification.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/sort_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/notification.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/sort_entities.pb.dart';
|
||||
|
||||
typedef SortNotifiedValue = Either<SortChangesetNotificationPB, FlowyError>;
|
||||
|
||||
class SortsListener {
|
||||
final String viewId;
|
||||
PublishNotifier<SortNotifiedValue>? _notifier = PublishNotifier();
|
||||
GridNotificationListener? _listener;
|
||||
DatabaseNotificationListener? _listener;
|
||||
|
||||
SortsListener({required this.viewId});
|
||||
|
||||
@ -20,18 +20,18 @@ class SortsListener {
|
||||
required void Function(SortNotifiedValue) onSortChanged,
|
||||
}) {
|
||||
_notifier?.addPublishListener(onSortChanged);
|
||||
_listener = GridNotificationListener(
|
||||
_listener = DatabaseNotificationListener(
|
||||
objectId: viewId,
|
||||
handler: _handler,
|
||||
);
|
||||
}
|
||||
|
||||
void _handler(
|
||||
GridNotification ty,
|
||||
DatabaseNotification ty,
|
||||
Either<Uint8List, FlowyError> result,
|
||||
) {
|
||||
switch (ty) {
|
||||
case GridNotification.DidUpdateSort:
|
||||
case DatabaseNotification.DidUpdateSort:
|
||||
result.fold(
|
||||
(payload) => _notifier?.value =
|
||||
left(SortChangesetNotificationPB.fromBuffer(payload)),
|
||||
|
@ -2,10 +2,10 @@ import 'package:dartz/dartz.dart';
|
||||
import 'package:appflowy_backend/dispatch/dispatch.dart';
|
||||
import 'package:appflowy_backend/log.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/grid_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/setting_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/sort_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/grid_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/setting_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/sort_entities.pb.dart';
|
||||
|
||||
class SortFFIService {
|
||||
final String viewId;
|
||||
@ -13,9 +13,9 @@ class SortFFIService {
|
||||
SortFFIService({required this.viewId});
|
||||
|
||||
Future<Either<List<SortPB>, FlowyError>> getAllSorts() {
|
||||
final payload = GridIdPB()..value = viewId;
|
||||
final payload = DatabaseIdPB()..value = viewId;
|
||||
|
||||
return GridEventGetAllSorts(payload).send().then((result) {
|
||||
return DatabaseEventGetAllSorts(payload).send().then((result) {
|
||||
return result.fold(
|
||||
(repeated) => left(repeated.items),
|
||||
(r) => right(r),
|
||||
@ -27,7 +27,7 @@ class SortFFIService {
|
||||
required String fieldId,
|
||||
required String sortId,
|
||||
required FieldType fieldType,
|
||||
required GridSortConditionPB condition,
|
||||
required SortConditionPB condition,
|
||||
}) {
|
||||
var insertSortPayload = AlterSortPayloadPB.create()
|
||||
..fieldId = fieldId
|
||||
@ -36,10 +36,10 @@ class SortFFIService {
|
||||
..condition = condition
|
||||
..sortId = sortId;
|
||||
|
||||
final payload = GridSettingChangesetPB.create()
|
||||
..gridId = viewId
|
||||
final payload = DatabaseSettingChangesetPB.create()
|
||||
..databaseId = viewId
|
||||
..alterSort = insertSortPayload;
|
||||
return GridEventUpdateGridSetting(payload).send().then((result) {
|
||||
return DatabaseEventUpdateDatabaseSetting(payload).send().then((result) {
|
||||
return result.fold(
|
||||
(l) => left(l),
|
||||
(err) {
|
||||
@ -53,7 +53,7 @@ class SortFFIService {
|
||||
Future<Either<Unit, FlowyError>> insertSort({
|
||||
required String fieldId,
|
||||
required FieldType fieldType,
|
||||
required GridSortConditionPB condition,
|
||||
required SortConditionPB condition,
|
||||
}) {
|
||||
var insertSortPayload = AlterSortPayloadPB.create()
|
||||
..fieldId = fieldId
|
||||
@ -61,10 +61,10 @@ class SortFFIService {
|
||||
..viewId = viewId
|
||||
..condition = condition;
|
||||
|
||||
final payload = GridSettingChangesetPB.create()
|
||||
..gridId = viewId
|
||||
final payload = DatabaseSettingChangesetPB.create()
|
||||
..databaseId = viewId
|
||||
..alterSort = insertSortPayload;
|
||||
return GridEventUpdateGridSetting(payload).send().then((result) {
|
||||
return DatabaseEventUpdateDatabaseSetting(payload).send().then((result) {
|
||||
return result.fold(
|
||||
(l) => left(l),
|
||||
(err) {
|
||||
@ -86,11 +86,11 @@ class SortFFIService {
|
||||
..viewId = viewId
|
||||
..fieldType = fieldType;
|
||||
|
||||
final payload = GridSettingChangesetPB.create()
|
||||
..gridId = viewId
|
||||
final payload = DatabaseSettingChangesetPB.create()
|
||||
..databaseId = viewId
|
||||
..deleteSort = deleteFilterPayload;
|
||||
|
||||
return GridEventUpdateGridSetting(payload).send().then((result) {
|
||||
return DatabaseEventUpdateDatabaseSetting(payload).send().then((result) {
|
||||
return result.fold(
|
||||
(l) => left(l),
|
||||
(err) {
|
||||
@ -102,8 +102,8 @@ class SortFFIService {
|
||||
}
|
||||
|
||||
Future<Either<Unit, FlowyError>> deleteAllSorts() {
|
||||
final payload = GridIdPB(value: viewId);
|
||||
return GridEventDeleteAllSorts(payload).send().then((result) {
|
||||
final payload = DatabaseIdPB(value: viewId);
|
||||
return DatabaseEventDeleteAllSorts(payload).send().then((result) {
|
||||
return result.fold(
|
||||
(l) => left(l),
|
||||
(err) {
|
||||
|
@ -6,21 +6,21 @@ import '../field/field_controller.dart';
|
||||
import '../row/row_cache.dart';
|
||||
|
||||
/// Read https://appflowy.gitbook.io/docs/essential-documentation/contribute-to-appflowy/architecture/frontend/grid for more information
|
||||
class GridViewCache {
|
||||
final String gridId;
|
||||
class DatabaseViewCache {
|
||||
final String databaseId;
|
||||
late GridRowCache _rowCache;
|
||||
final GridViewListener _gridViewListener;
|
||||
|
||||
List<RowInfo> get rowInfos => _rowCache.visibleRows;
|
||||
GridRowCache get rowCache => _rowCache;
|
||||
|
||||
GridViewCache({
|
||||
required this.gridId,
|
||||
DatabaseViewCache({
|
||||
required this.databaseId,
|
||||
required GridFieldController fieldController,
|
||||
}) : _gridViewListener = GridViewListener(viewId: gridId) {
|
||||
}) : _gridViewListener = GridViewListener(viewId: databaseId) {
|
||||
final delegate = GridRowFieldNotifierImpl(fieldController);
|
||||
_rowCache = GridRowCache(
|
||||
gridId: gridId,
|
||||
databaseId: databaseId,
|
||||
rows: [],
|
||||
notifier: delegate,
|
||||
delegate: delegate,
|
||||
|
@ -1,17 +1,17 @@
|
||||
import 'dart:async';
|
||||
import 'dart:typed_data';
|
||||
import 'package:app_flowy/core/grid_notification.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/sort_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/sort_entities.pb.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_infra/notifier.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/notification.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/view_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/notification.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/view_entities.pb.dart';
|
||||
|
||||
typedef GridRowsVisibilityNotifierValue
|
||||
= Either<GridRowsVisibilityChangesetPB, FlowyError>;
|
||||
= Either<ViewRowsVisibilityChangesetPB, FlowyError>;
|
||||
|
||||
typedef GridViewRowsNotifierValue = Either<GridViewRowsChangesetPB, FlowyError>;
|
||||
typedef GridViewRowsNotifierValue = Either<ViewRowsChangesetPB, FlowyError>;
|
||||
typedef GridViewReorderAllRowsNotifierValue = Either<List<String>, FlowyError>;
|
||||
typedef GridViewSingleRowNotifierValue = Either<ReorderSingleRowPB, FlowyError>;
|
||||
|
||||
@ -25,7 +25,7 @@ class GridViewListener {
|
||||
PublishNotifier<GridRowsVisibilityNotifierValue>? _rowsVisibility =
|
||||
PublishNotifier();
|
||||
|
||||
GridNotificationListener? _listener;
|
||||
DatabaseNotificationListener? _listener;
|
||||
GridViewListener({required this.viewId});
|
||||
|
||||
void start({
|
||||
@ -40,7 +40,7 @@ class GridViewListener {
|
||||
_listener?.stop();
|
||||
}
|
||||
|
||||
_listener = GridNotificationListener(
|
||||
_listener = DatabaseNotificationListener(
|
||||
objectId: viewId,
|
||||
handler: _handler,
|
||||
);
|
||||
@ -51,30 +51,30 @@ class GridViewListener {
|
||||
_reorderSingleRow?.addPublishListener(onReorderSingleRow);
|
||||
}
|
||||
|
||||
void _handler(GridNotification ty, Either<Uint8List, FlowyError> result) {
|
||||
void _handler(DatabaseNotification ty, Either<Uint8List, FlowyError> result) {
|
||||
switch (ty) {
|
||||
case GridNotification.DidUpdateGridViewRowsVisibility:
|
||||
case DatabaseNotification.DidUpdateDatabaseViewRowsVisibility:
|
||||
result.fold(
|
||||
(payload) => _rowsVisibility?.value =
|
||||
left(GridRowsVisibilityChangesetPB.fromBuffer(payload)),
|
||||
left(ViewRowsVisibilityChangesetPB.fromBuffer(payload)),
|
||||
(error) => _rowsVisibility?.value = right(error),
|
||||
);
|
||||
break;
|
||||
case GridNotification.DidUpdateGridViewRows:
|
||||
case DatabaseNotification.DidUpdateDatabaseViewRows:
|
||||
result.fold(
|
||||
(payload) => _rowsNotifier?.value =
|
||||
left(GridViewRowsChangesetPB.fromBuffer(payload)),
|
||||
left(ViewRowsChangesetPB.fromBuffer(payload)),
|
||||
(error) => _rowsNotifier?.value = right(error),
|
||||
);
|
||||
break;
|
||||
case GridNotification.DidReorderRows:
|
||||
case DatabaseNotification.DidReorderRows:
|
||||
result.fold(
|
||||
(payload) => _reorderAllRows?.value =
|
||||
left(ReorderAllRowsPB.fromBuffer(payload).rowOrders),
|
||||
(error) => _reorderAllRows?.value = right(error),
|
||||
);
|
||||
break;
|
||||
case GridNotification.DidReorderSingleRow:
|
||||
case DatabaseNotification.DidReorderSingleRow:
|
||||
result.fold(
|
||||
(payload) => _reorderSingleRow?.value =
|
||||
left(ReorderSingleRowPB.fromBuffer(payload)),
|
||||
|
@ -70,7 +70,7 @@ class _GridPageState extends State<GridPage> {
|
||||
)..add(const SortMenuEvent.initial()),
|
||||
),
|
||||
BlocProvider<GridSettingBloc>(
|
||||
create: (context) => GridSettingBloc(gridId: widget.view.id),
|
||||
create: (context) => GridSettingBloc(databaseId: widget.view.id),
|
||||
),
|
||||
],
|
||||
child: BlocBuilder<GridBloc, GridState>(
|
||||
@ -146,8 +146,8 @@ class _FlowyGridState extends State<FlowyGrid> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const GridToolbar(),
|
||||
GridAccessoryMenu(viewId: state.gridId),
|
||||
_gridHeader(context, state.gridId),
|
||||
GridAccessoryMenu(viewId: state.databaseId),
|
||||
_gridHeader(context, state.databaseId),
|
||||
Flexible(child: child),
|
||||
const RowCountBadge(),
|
||||
],
|
||||
@ -188,11 +188,11 @@ class _FlowyGridState extends State<FlowyGrid> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _gridHeader(BuildContext context, String gridId) {
|
||||
Widget _gridHeader(BuildContext context, String viewId) {
|
||||
final fieldController =
|
||||
context.read<GridBloc>().gridController.fieldController;
|
||||
return GridHeaderSliverAdaptor(
|
||||
gridId: gridId,
|
||||
viewId: viewId,
|
||||
fieldController: fieldController,
|
||||
anchorScrollController: headerScrollController,
|
||||
);
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -16,7 +16,7 @@ import 'package:flowy_infra_ui/widget/rounded_input_field.dart';
|
||||
import 'package:flowy_infra_ui/widget/spacing.dart';
|
||||
import 'package:appflowy_backend/log.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pbserver.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/date_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/date_type_option.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:table_calendar/table_calendar.dart';
|
||||
|
@ -4,7 +4,7 @@ import 'package:flowy_infra/size.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/hover.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/icon_button.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/text.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/select_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:app_flowy/generated/locale_keys.g.dart';
|
||||
|
@ -5,7 +5,7 @@ import 'package:appflowy_popover/appflowy_popover.dart';
|
||||
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||
// ignore: unused_import
|
||||
import 'package:appflowy_backend/log.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/select_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
|
@ -10,7 +10,7 @@ import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/icon_button.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/scrolling/styled_list.dart';
|
||||
import 'package:flowy_infra_ui/widget/spacing.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/select_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'dart:collection';
|
||||
|
||||
import 'package:flowy_infra/size.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/select_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
|
@ -9,7 +9,7 @@ import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flowy_infra/image.dart';
|
||||
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||
import 'package:flowy_infra_ui/widget/spacing.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/checkbox_filter.pbenum.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/checkbox_filter.pbenum.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
|
@ -8,7 +8,7 @@ import 'package:appflowy_popover/appflowy_popover.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||
import 'package:flowy_infra_ui/widget/spacing.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/checklist_filter.pbenum.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/checklist_filter.pbenum.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../choicechip.dart';
|
||||
|
@ -5,8 +5,8 @@ import 'package:app_flowy/workspace/presentation/widgets/pop_up_action.dart';
|
||||
import 'package:appflowy_popover/appflowy_popover.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flowy_infra/image.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/select_option_filter.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/select_option_filter.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SelectOptionFilterConditionList extends StatelessWidget {
|
||||
|
@ -5,8 +5,8 @@ import 'package:app_flowy/plugins/grid/presentation/widgets/filter/filter_info.d
|
||||
import 'package:flowy_infra/image.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/scrolling/styled_list.dart';
|
||||
import 'package:flowy_infra_ui/widget/spacing.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pbenum.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/select_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pbenum.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
|
@ -5,8 +5,8 @@ import 'package:appflowy_popover/appflowy_popover.dart';
|
||||
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/scrolling/styled_list.dart';
|
||||
import 'package:flowy_infra_ui/widget/spacing.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/select_option_filter.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/select_option_filter.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
|
@ -2,7 +2,7 @@ import 'package:app_flowy/plugins/grid/application/field/type_option/type_option
|
||||
import 'package:app_flowy/plugins/grid/presentation/widgets/filter/filter_info.dart';
|
||||
import 'package:app_flowy/plugins/grid/presentation/widgets/header/type_option/builder.dart';
|
||||
import 'package:appflowy_backend/log.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/select_type_option.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
||||
|
||||
abstract class SelectOptionFilterDelegate {
|
||||
Future<List<SelectOptionPB>> loadOptions();
|
||||
@ -14,7 +14,7 @@ class SingleSelectOptionFilterDelegateImpl
|
||||
|
||||
SingleSelectOptionFilterDelegateImpl(FilterInfo filterInfo)
|
||||
: typeOptionContext = makeSingleSelectTypeOptionContext(
|
||||
gridId: filterInfo.viewId,
|
||||
databaseId: filterInfo.viewId,
|
||||
fieldPB: filterInfo.fieldInfo.field,
|
||||
);
|
||||
|
||||
@ -34,7 +34,7 @@ class MultiSelectOptionFilterDelegateImpl
|
||||
|
||||
MultiSelectOptionFilterDelegateImpl(FilterInfo filterInfo)
|
||||
: typeOptionContext = makeMultiSelectTypeOptionContext(
|
||||
gridId: filterInfo.viewId,
|
||||
databaseId: filterInfo.viewId,
|
||||
fieldPB: filterInfo.fieldInfo.field,
|
||||
);
|
||||
|
||||
|
@ -9,7 +9,7 @@ import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flowy_infra/image.dart';
|
||||
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||
import 'package:flowy_infra_ui/widget/spacing.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/text_filter.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/text_filter.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'choicechip.dart';
|
||||
|
@ -1,11 +1,11 @@
|
||||
import 'package:app_flowy/plugins/grid/application/field/field_controller.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/checkbox_filter.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/checklist_filter.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/date_filter.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/select_option_filter.pbserver.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/text_filter.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/util.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/checkbox_filter.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/checklist_filter.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/date_filter.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/select_option_filter.pbserver.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/text_filter.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/util.pb.dart';
|
||||
|
||||
class FilterInfo {
|
||||
final String viewId;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pbenum.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pbenum.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'choicechip/checkbox.dart';
|
||||
|
@ -4,7 +4,7 @@ import 'package:flowy_infra/theme_extension.dart';
|
||||
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/button.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/hover.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-grid/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
|
@ -35,10 +35,10 @@ class _GridFieldCellActionSheetState extends State<GridFieldCellActionSheet> {
|
||||
return SizedBox(
|
||||
width: 400,
|
||||
child: FieldEditor(
|
||||
gridId: widget.cellContext.gridId,
|
||||
databaseId: widget.cellContext.databaseId,
|
||||
fieldName: field.name,
|
||||
typeOptionLoader: FieldTypeOptionLoader(
|
||||
gridId: widget.cellContext.gridId,
|
||||
databaseId: widget.cellContext.databaseId,
|
||||
field: field,
|
||||
),
|
||||
),
|
||||
@ -206,7 +206,7 @@ extension _FieldActionExtension on FieldAction {
|
||||
PopoverContainer.of(context).close();
|
||||
|
||||
FieldService(
|
||||
gridId: fieldInfo.gridId,
|
||||
databaseId: fieldInfo.databaseId,
|
||||
fieldId: fieldInfo.field.id,
|
||||
).duplicateField();
|
||||
|
||||
@ -218,7 +218,7 @@ extension _FieldActionExtension on FieldAction {
|
||||
title: LocaleKeys.grid_field_deleteFieldPromptMessage.tr(),
|
||||
confirm: () {
|
||||
FieldService(
|
||||
gridId: fieldInfo.gridId,
|
||||
databaseId: fieldInfo.databaseId,
|
||||
fieldId: fieldInfo.field.id,
|
||||
).deleteField();
|
||||
},
|
||||
|
@ -15,14 +15,14 @@ import 'package:app_flowy/generated/locale_keys.g.dart';
|
||||
import 'field_type_option_editor.dart';
|
||||
|
||||
class FieldEditor extends StatefulWidget {
|
||||
final String gridId;
|
||||
final String databaseId;
|
||||
final String fieldName;
|
||||
final bool isGroupField;
|
||||
final Function(String)? onDeleted;
|
||||
final IFieldTypeOptionLoader typeOptionLoader;
|
||||
|
||||
const FieldEditor({
|
||||
required this.gridId,
|
||||
required this.databaseId,
|
||||
this.fieldName = "",
|
||||
required this.typeOptionLoader,
|
||||
this.isGroupField = false,
|
||||
@ -59,7 +59,7 @@ class _FieldEditorState extends State<FieldEditor> {
|
||||
];
|
||||
return BlocProvider(
|
||||
create: (context) => FieldEditorBloc(
|
||||
gridId: widget.gridId,
|
||||
databaseId: widget.databaseId,
|
||||
fieldName: widget.fieldName,
|
||||
isGroupField: widget.isGroupField,
|
||||
loader: widget.typeOptionLoader,
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user