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