diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_controller.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_controller.dart index 6a5d55b813..b37e990f21 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_controller.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_controller.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'package:appflowy/plugins/database_view/application/field/field_info.dart'; import 'package:appflowy/plugins/database_view/application/field/field_listener.dart'; import 'package:appflowy/plugins/database_view/application/row/row_meta_listener.dart'; import 'package:appflowy/plugins/database_view/application/row/row_service.dart'; @@ -8,7 +9,6 @@ import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart'; import 'package:dartz/dartz.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/foundation.dart'; -import '../field/field_controller.dart'; import '../field/field_service.dart'; import '../field/type_option/type_option_context.dart'; import 'cell_listener.dart'; @@ -104,7 +104,7 @@ class CellController extends Equatable { ); // Only the primary can listen on the row meta changes. - if (_cellContext.fieldInfo.isPrimary) { + if (_cellContext.fieldInfo.field.isPrimary) { _rowMetaListener?.start( callback: (newRowMeta) { _cellContext = _cellContext.copyWith(rowMeta: newRowMeta); diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_service.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_service.dart index 31e46a5189..4809d4afc8 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_service.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_service.dart @@ -15,7 +15,7 @@ import 'package:flutter/foundation.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'dart:convert' show utf8; -import '../field/field_controller.dart'; +import '../field/field_info.dart'; import '../row/row_service.dart'; part 'cell_service.freezed.dart'; part 'cell_data_loader.dart'; @@ -62,14 +62,14 @@ class DatabaseCellContext with _$DatabaseCellContext { String get rowId => rowMeta.id; - String get fieldId => fieldInfo.id; + String get fieldId => fieldInfo.field.id; - FieldType get fieldType => fieldInfo.fieldType; + FieldType get fieldType => fieldInfo.field.fieldType; ValueKey key() { - return ValueKey("${rowMeta.id}$fieldId${fieldInfo.fieldType}"); + return ValueKey("${rowMeta.id}$fieldId${fieldInfo.field.fieldType}"); } /// Only the primary field can have an emoji. - String? get emoji => fieldInfo.isPrimary ? rowMeta.icon : null; + String? get emoji => fieldInfo.field.isPrimary ? rowMeta.icon : null; } diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/database_controller.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/database_controller.dart index 7a46808b02..2df72b84f4 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/database_controller.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/database_controller.dart @@ -16,6 +16,7 @@ import 'package:dartz/dartz.dart'; import 'package:flutter/material.dart'; import 'database_view_service.dart'; import 'defines.dart'; +import 'field/field_info.dart'; import 'layout/layout_service.dart'; import 'layout/layout_setting_listener.dart'; import 'row/row_cache.dart'; diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/defines.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/defines.dart index e2d531038b..09f49ab869 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/defines.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/defines.dart @@ -7,7 +7,7 @@ import 'package:dartz/dartz.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import '../grid/presentation/widgets/filter/filter_info.dart'; -import 'field/field_controller.dart'; +import 'field/field_info.dart'; import 'row/row_cache.dart'; import 'row/row_service.dart'; diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/field/field_controller.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/field/field_controller.dart index 237f38a4fa..b6c8d024f3 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/field/field_controller.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/field/field_controller.dart @@ -19,6 +19,7 @@ import '../setting/setting_listener.dart'; import '../setting/setting_service.dart'; import '../sort/sort_listener.dart'; import '../sort/sort_service.dart'; +import 'field_info.dart'; import 'field_listener.dart'; class _GridFieldNotifier extends ChangeNotifier { @@ -438,12 +439,18 @@ class FieldController { } void _updateFieldInfos() { + final List newFieldInfos = []; for (final field in _fieldNotifier.fieldInfos) { - field._isGroupField = _groupConfigurationByFieldId[field.id] != null; - field._hasFilter = _filterPBByFieldId[field.id] != null; - field._hasSort = _sortPBByFieldId[field.id] != null; + newFieldInfos.add( + field.copyWith( + isGroupField: _groupConfigurationByFieldId[field.id] != null, + hasFilter: _filterPBByFieldId[field.id] != null, + hasSort: _sortPBByFieldId[field.id] != null, + ), + ); } - _fieldNotifier.notify(); + + _fieldNotifier.fieldInfos = newFieldInfos; } Future dispose() async { @@ -488,7 +495,7 @@ class FieldController { } _fieldNotifier.fieldInfos = - newFields.map((field) => FieldInfo(field: field)).toList(); + newFields.map((field) => FieldInfo.initial(field)).toList(); _loadFilters(); _loadSorts(); _updateFieldInfos(); @@ -652,7 +659,7 @@ class FieldController { } final List newFieldInfos = fieldInfos; for (final indexField in insertedFields) { - final fieldInfo = FieldInfo(field: indexField.field_1); + final fieldInfo = FieldInfo.initial(indexField.field_1); if (newFieldInfos.length > indexField.index) { newFieldInfos.insert(indexField.index, fieldInfo); } else { @@ -674,7 +681,7 @@ class FieldController { newFields.indexWhere((field) => field.id == updatedFieldPB.id); if (index != -1) { newFields.removeAt(index); - final fieldInfo = FieldInfo(field: updatedFieldPB); + final fieldInfo = FieldInfo.initial(updatedFieldPB); newFields.insert(index, fieldInfo); updatedFields.add(fieldInfo); } @@ -693,7 +700,7 @@ class RowCacheDependenciesImpl extends RowFieldsDelegate with RowLifeCycle { RowCacheDependenciesImpl(FieldController cache) : _fieldController = cache; @override - UnmodifiableListView get fields => + UnmodifiableListView get fieldInfos => UnmodifiableListView(_fieldController.fieldInfos); @override @@ -729,75 +736,3 @@ FieldInfo? _findFieldInfo({ return null; } } - -class FieldInfo { - final FieldPB _field; - bool _isGroupField = false; - - bool _hasFilter = false; - - bool _hasSort = false; - - String get id => _field.id; - - FieldType get fieldType => _field.fieldType; - - bool get visibility => _field.visibility; - - double get width => _field.width.toDouble(); - - bool get isPrimary => _field.isPrimary; - - String get name => _field.name; - - FieldPB get field => _field; - - bool get isGroupField => _isGroupField; - - bool get hasFilter => _hasFilter; - - bool get canBeGroup { - switch (_field.fieldType) { - case FieldType.URL: - case FieldType.Checkbox: - case FieldType.MultiSelect: - case FieldType.SingleSelect: - return true; - default: - return false; - } - } - - bool get canCreateFilter { - if (hasFilter) return false; - - switch (_field.fieldType) { - case FieldType.Checkbox: - case FieldType.MultiSelect: - case FieldType.RichText: - case FieldType.SingleSelect: - case FieldType.Checklist: - return true; - default: - return false; - } - } - - bool get canCreateSort { - if (_hasSort) return false; - - switch (_field.fieldType) { - case FieldType.RichText: - case FieldType.Checkbox: - case FieldType.Number: - case FieldType.DateTime: - case FieldType.SingleSelect: - case FieldType.MultiSelect: - return true; - default: - return false; - } - } - - FieldInfo({required FieldPB field}) : _field = field; -} diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/field/field_info.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/field/field_info.dart new file mode 100644 index 0000000000..54d79a24f8 --- /dev/null +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/field/field_info.dart @@ -0,0 +1,71 @@ +import 'package:appflowy_backend/protobuf/flowy-database2/field_entities.pb.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +part 'field_info.freezed.dart'; + +@freezed +class FieldInfo with _$FieldInfo { + const FieldInfo._(); + + const factory FieldInfo({ + required FieldPB field, + required bool isGroupField, + required bool hasFilter, + required bool hasSort, + }) = _FieldInfo; + + String get id => field.id; + + FieldType get fieldType => field.fieldType; + + String get name => field.name; + + factory FieldInfo.initial(FieldPB field) => FieldInfo( + field: field, + hasFilter: false, + hasSort: false, + isGroupField: false, + ); + + bool get canBeGroup { + switch (field.fieldType) { + case FieldType.URL: + case FieldType.Checkbox: + case FieldType.MultiSelect: + case FieldType.SingleSelect: + return true; + default: + return false; + } + } + + bool get canCreateFilter { + if (hasFilter) return false; + + switch (field.fieldType) { + case FieldType.Checkbox: + case FieldType.MultiSelect: + case FieldType.RichText: + case FieldType.SingleSelect: + case FieldType.Checklist: + return true; + default: + return false; + } + } + + bool get canCreateSort { + if (hasSort) return false; + + switch (field.fieldType) { + case FieldType.RichText: + case FieldType.Checkbox: + case FieldType.Number: + case FieldType.DateTime: + case FieldType.SingleSelect: + case FieldType.MultiSelect: + return true; + default: + return false; + } + } +} diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/field/type_option/type_option_data_controller.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/field/type_option/type_option_data_controller.dart index e793b72f8e..941c8f23b2 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/field/type_option/type_option_data_controller.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/field/type_option/type_option_data_controller.dart @@ -1,4 +1,3 @@ -import 'package:appflowy/plugins/database_view/application/field/field_controller.dart'; import 'package:appflowy_backend/dispatch/dispatch.dart'; import 'package:flowy_infra/notifier.dart'; import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart'; diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_cache.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_cache.dart index 63173c4c98..31a9bc37eb 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_cache.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_cache.dart @@ -1,4 +1,5 @@ import 'dart:collection'; +import 'package:appflowy/plugins/database_view/application/field/field_info.dart'; import 'package:appflowy_backend/dispatch/dispatch.dart'; import 'package:appflowy_backend/log.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart'; @@ -6,7 +7,6 @@ import 'package:flutter/foundation.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import '../cell/cell_service.dart'; -import '../field/field_controller.dart'; import 'row_list.dart'; import 'row_service.dart'; part 'row_cache.freezed.dart'; @@ -15,7 +15,7 @@ typedef RowUpdateCallback = void Function(); /// A delegate that provides the fields of the row. abstract class RowFieldsDelegate { - UnmodifiableListView get fields; + UnmodifiableListView get fieldInfos; void onFieldsChanged(void Function(List) callback); } @@ -244,12 +244,12 @@ class RowCache { CellContextByFieldId _makeCells(RowMetaPB rowMeta) { // ignore: prefer_collection_literals final cellContextMap = CellContextByFieldId(); - for (final field in _fieldDelegate.fields) { - if (field.visibility) { - cellContextMap[field.id] = DatabaseCellContext( + for (final fieldInfo in _fieldDelegate.fieldInfos) { + if (fieldInfo.field.visibility) { + cellContextMap[fieldInfo.id] = DatabaseCellContext( rowMeta: rowMeta, viewId: viewId, - fieldInfo: field, + fieldInfo: fieldInfo, ); } } @@ -259,7 +259,7 @@ class RowCache { RowInfo buildGridRow(RowMetaPB rowMetaPB) { return RowInfo( viewId: viewId, - fields: _fieldDelegate.fields, + fields: _fieldDelegate.fieldInfos, rowId: rowMetaPB.id, rowMeta: rowMetaPB, ); diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/setting/group_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/setting/group_bloc.dart index 93a7df4e11..16333fe5db 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/setting/group_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/setting/group_bloc.dart @@ -1,4 +1,5 @@ import 'package:appflowy/plugins/database_view/application/field/field_controller.dart'; +import 'package:appflowy/plugins/database_view/application/field/field_info.dart'; import 'package:appflowy_backend/log.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/field_entities.pb.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -26,8 +27,8 @@ class DatabaseGroupBloc extends Bloc { initial: () { _startListening(); }, - didReceiveFieldUpdate: (fieldContexts) { - emit(state.copyWith(fieldContexts: fieldContexts)); + didReceiveFieldUpdate: (fieldInfos) { + emit(state.copyWith(fieldInfos: fieldInfos)); }, setGroupByField: (String fieldId, FieldType fieldType) async { final result = await _groupBackendSvc.groupByField( @@ -50,8 +51,8 @@ class DatabaseGroupBloc extends Bloc { } void _startListening() { - _onFieldsFn = (fieldContexts) => - add(DatabaseGroupEvent.didReceiveFieldUpdate(fieldContexts)); + _onFieldsFn = (fieldInfos) => + add(DatabaseGroupEvent.didReceiveFieldUpdate(fieldInfos)); _fieldController.addListener( onReceiveFields: _onFieldsFn, listenWhen: () => !isClosed, @@ -75,15 +76,15 @@ class DatabaseGroupEvent with _$DatabaseGroupEvent { class DatabaseGroupState with _$DatabaseGroupState { const factory DatabaseGroupState({ required String viewId, - required List fieldContexts, + required List fieldInfos, }) = _DatabaseGroupState; factory DatabaseGroupState.initial( String viewId, - List fieldContexts, + List fieldInfos, ) => DatabaseGroupState( viewId: viewId, - fieldContexts: fieldContexts, + fieldInfos: fieldInfos, ); } diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/setting/property_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/setting/property_bloc.dart index 1791e32d68..31554c652c 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/application/setting/property_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/setting/property_bloc.dart @@ -1,4 +1,5 @@ import 'package:appflowy/plugins/database_view/application/field/field_controller.dart'; +import 'package:appflowy/plugins/database_view/application/field/field_info.dart'; import 'package:appflowy_backend/log.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/board/application/board_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/board/application/board_bloc.dart index 4c0c69c932..986aeb983b 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/board/application/board_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/board/application/board_bloc.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'dart:collection'; import 'package:appflowy/plugins/database_view/application/defines.dart'; +import 'package:appflowy/plugins/database_view/application/field/field_info.dart'; import 'package:appflowy/plugins/database_view/application/row/row_service.dart'; import 'package:appflowy_board/appflowy_board.dart'; import 'package:dartz/dartz.dart'; diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/calendar/application/calendar_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/calendar/application/calendar_bloc.dart index 1141d39fc1..309a0c9156 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/calendar/application/calendar_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/calendar/application/calendar_bloc.dart @@ -1,6 +1,7 @@ import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart'; import 'package:appflowy/plugins/database_view/application/defines.dart'; import 'package:appflowy/plugins/database_view/application/field/field_controller.dart'; +import 'package:appflowy/plugins/database_view/application/field/field_info.dart'; import 'package:appflowy/plugins/database_view/application/row/row_service.dart'; import 'package:appflowy_backend/dispatch/dispatch.dart'; import 'package:appflowy_backend/log.dart'; diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/calendar/application/unschedule_event_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/calendar/application/unschedule_event_bloc.dart index de7ef21652..6f119690e4 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/calendar/application/unschedule_event_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/calendar/application/unschedule_event_bloc.dart @@ -1,5 +1,6 @@ import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart'; import 'package:appflowy/plugins/database_view/application/field/field_controller.dart'; +import 'package:appflowy/plugins/database_view/application/field/field_info.dart'; import 'package:appflowy/plugins/database_view/application/row/row_service.dart'; import 'package:appflowy_backend/dispatch/dispatch.dart'; import 'package:appflowy_backend/log.dart'; diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/filter_create_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/filter_create_bloc.dart index 96d3d9e563..098d51fb7d 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/filter_create_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/filter_create_bloc.dart @@ -1,4 +1,5 @@ import 'package:appflowy/plugins/database_view/application/field/field_controller.dart'; +import 'package:appflowy/plugins/database_view/application/field/field_info.dart'; import 'package:appflowy/plugins/database_view/application/filter/filter_service.dart'; import 'package:dartz/dartz.dart'; import 'package:appflowy_backend/protobuf/flowy-error/errors.pbserver.dart'; diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/filter_menu_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/filter_menu_bloc.dart index 76b135db1d..06852369c9 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/filter_menu_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/filter/filter_menu_bloc.dart @@ -1,4 +1,5 @@ import 'package:appflowy/plugins/database_view/application/field/field_controller.dart'; +import 'package:appflowy/plugins/database_view/application/field/field_info.dart'; import 'package:appflowy/plugins/database_view/grid/presentation/widgets/filter/filter_info.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/grid_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/grid_bloc.dart index bb011a7f74..d5fef3b3c7 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/grid_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/grid_bloc.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'package:appflowy/plugins/database_view/application/defines.dart'; +import 'package:appflowy/plugins/database_view/application/field/field_info.dart'; import 'package:appflowy/plugins/database_view/application/row/row_cache.dart'; import 'package:appflowy/plugins/database_view/application/row/row_service.dart'; import 'package:appflowy/plugins/database_view/grid/presentation/widgets/filter/filter_info.dart'; @@ -10,7 +11,6 @@ import 'package:appflowy_backend/protobuf/flowy-folder2/view.pb.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; -import '../../application/field/field_controller.dart'; import '../../application/database_controller.dart'; import 'dart:collection'; @@ -200,24 +200,25 @@ class GridState with _$GridState { } class GridFieldEquatable extends Equatable { - final List _fields; + final List _fieldInfos; const GridFieldEquatable( - List fields, - ) : _fields = fields; + List fieldInfos, + ) : _fieldInfos = fieldInfos; @override List get props { - if (_fields.isEmpty) { + if (_fieldInfos.isEmpty) { return []; } return [ - _fields.length, - _fields - .map((field) => field.width) + _fieldInfos.length, + _fieldInfos + .map((fieldInfo) => fieldInfo.field.width) .reduce((value, element) => value + element), ]; } - UnmodifiableListView get value => UnmodifiableListView(_fields); + UnmodifiableListView get value => + UnmodifiableListView(_fieldInfos); } diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/grid_header_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/grid_header_bloc.dart index c057486b77..e1c9a363fe 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/grid_header_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/grid_header_bloc.dart @@ -1,4 +1,5 @@ import 'package:appflowy/plugins/database_view/application/field/field_controller.dart'; +import 'package:appflowy/plugins/database_view/application/field/field_info.dart'; import 'package:appflowy_backend/log.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/field_entities.pb.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -26,7 +27,7 @@ class GridHeaderBloc extends Bloc { emit( state.copyWith( fields: value.fields - .where((element) => element.visibility) + .where((element) => element.field.visibility) .toList(), ), ); diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/row/row_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/row/row_bloc.dart index 35c514a715..63247328fe 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/row/row_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/row/row_bloc.dart @@ -1,4 +1,5 @@ import 'dart:collection'; +import 'package:appflowy/plugins/database_view/application/field/field_info.dart'; import 'package:appflowy/plugins/database_view/application/row/row_listener.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart'; import 'package:equatable/equatable.dart'; @@ -7,7 +8,6 @@ import 'package:freezed_annotation/freezed_annotation.dart'; import 'dart:async'; import '../../../application/cell/cell_service.dart'; -import '../../../application/field/field_controller.dart'; import '../../../application/row/row_cache.dart'; import '../../../application/row/row_controller.dart'; import '../../../application/row/row_service.dart'; @@ -119,16 +119,16 @@ class RowState with _$RowState { } class GridCellEquatable extends Equatable { - final FieldInfo _fieldContext; + final FieldInfo _fieldInfo; - const GridCellEquatable(FieldInfo field) : _fieldContext = field; + const GridCellEquatable(FieldInfo field) : _fieldInfo = field; @override List get props => [ - _fieldContext.id, - _fieldContext.fieldType, - _fieldContext.visibility, - _fieldContext.width, + _fieldInfo.id, + _fieldInfo.fieldType, + _fieldInfo.field.visibility, + _fieldInfo.field.width, ]; } diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/sort/sort_create_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/sort/sort_create_bloc.dart index f189972722..0f8e9bf6d0 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/sort/sort_create_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/sort/sort_create_bloc.dart @@ -1,3 +1,4 @@ +import 'package:appflowy/plugins/database_view/application/field/field_info.dart'; import 'package:dartz/dartz.dart'; import 'package:appflowy_backend/protobuf/flowy-error/errors.pbserver.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/sort_entities.pbenum.dart'; diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/sort/sort_editor_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/sort/sort_editor_bloc.dart index bd36dc8dfd..7222b42242 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/sort/sort_editor_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/sort/sort_editor_bloc.dart @@ -1,4 +1,5 @@ import 'package:appflowy/plugins/database_view/application/field/field_controller.dart'; +import 'package:appflowy/plugins/database_view/application/field/field_info.dart'; import 'package:appflowy/plugins/database_view/application/sort/sort_service.dart'; import 'package:appflowy/plugins/database_view/grid/presentation/widgets/sort/sort_info.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/sort_entities.pbenum.dart'; diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/sort/sort_menu_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/sort/sort_menu_bloc.dart index 3b039be5b3..fe0bcb683e 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/sort/sort_menu_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/sort/sort_menu_bloc.dart @@ -1,3 +1,4 @@ +import 'package:appflowy/plugins/database_view/application/field/field_info.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'dart:async'; diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/sort/util.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/sort/util.dart index 1189427515..7eb9718bc1 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/sort/util.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/sort/util.dart @@ -1,4 +1,4 @@ -import '../../../application/field/field_controller.dart'; +import 'package:appflowy/plugins/database_view/application/field/field_info.dart'; List getCreatableSorts(List fieldInfos) { final List creatableFields = List.from(fieldInfos); diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/layout/layout.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/layout/layout.dart index 1cb17c8ebe..29acb595d1 100755 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/layout/layout.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/layout/layout.dart @@ -1,4 +1,4 @@ -import 'package:appflowy/plugins/database_view/application/field/field_controller.dart'; +import 'package:appflowy/plugins/database_view/application/field/field_info.dart'; import 'sizes.dart'; class GridLayout { @@ -6,7 +6,7 @@ class GridLayout { if (fields.isEmpty) return 0; final fieldsWidth = fields - .map((field) => field.width.toDouble()) + .map((fieldInfo) => fieldInfo.field.width.toDouble()) .reduce((value, element) => value + element); return fieldsWidth + diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/checkbox.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/checkbox.dart index 23e3ef2b7b..c6bd3707b1 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/checkbox.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/checkbox.dart @@ -109,7 +109,7 @@ class _CheckboxFilterEditorState extends State { children: [ Expanded( child: FlowyText( - state.filterInfo.fieldInfo.name, + state.filterInfo.fieldInfo.field.name, overflow: TextOverflow.ellipsis, ), ), diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/checklist/checklist.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/checklist/checklist.dart index c8706f85e3..5319fdff83 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/checklist/checklist.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/checklist/checklist.dart @@ -93,7 +93,7 @@ class ChecklistState extends State { children: [ Expanded( child: FlowyText( - state.filterInfo.fieldInfo.name, + state.filterInfo.fieldInfo.field.name, overflow: TextOverflow.ellipsis, ), ), diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/choicechip.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/choicechip.dart index 144839220b..9446c16ec8 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/choicechip.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/choicechip.dart @@ -39,7 +39,7 @@ class ChoiceChipButton extends StatelessWidget { decoration: decoration, useIntrinsicWidth: true, text: FlowyText( - filterInfo.fieldInfo.name, + filterInfo.fieldInfo.field.name, color: AFThemeExtension.of(context).textColor, ), margin: const EdgeInsets.symmetric(horizontal: 8, vertical: 2), diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/select_option/select_option.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/select_option/select_option.dart index 419ee988a4..bc1e43054f 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/select_option/select_option.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/choicechip/select_option/select_option.dart @@ -144,7 +144,7 @@ class _SelectOptionFilterEditorState extends State { children: [ Expanded( child: FlowyText( - state.filterInfo.fieldInfo.name, + state.filterInfo.fieldInfo.field.name, overflow: TextOverflow.ellipsis, ), ), diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/create_filter_list.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/create_filter_list.dart index e9c377b5f7..157d75a111 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/create_filter_list.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/create_filter_list.dart @@ -1,4 +1,5 @@ import 'package:appflowy/generated/locale_keys.g.dart'; +import 'package:appflowy/plugins/database_view/application/field/field_info.dart'; import 'package:appflowy/plugins/database_view/grid/presentation/layout/sizes.dart'; import 'package:appflowy/plugins/database_view/grid/presentation/widgets/header/field_type_extension.dart'; import 'package:easy_localization/easy_localization.dart'; @@ -161,7 +162,7 @@ class GridFilterPropertyCell extends StatelessWidget { return FlowyButton( hoverColor: AFThemeExtension.of(context).lightGreyHover, text: FlowyText.medium( - fieldInfo.name, + fieldInfo.field.name, color: AFThemeExtension.of(context).textColor, ), onTap: () => onTap(fieldInfo), diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/filter_info.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/filter_info.dart index f8a6091cbf..1059abffed 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/filter_info.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/filter/filter_info.dart @@ -1,4 +1,4 @@ -import 'package:appflowy/plugins/database_view/application/field/field_controller.dart'; +import 'package:appflowy/plugins/database_view/application/field/field_info.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/checkbox_filter.pb.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/checklist_filter.pb.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/date_filter.pb.dart'; diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/grid_header.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/grid_header.dart index b04440cede..15de7f897f 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/grid_header.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/grid_header.dart @@ -96,7 +96,7 @@ class _GridHeaderState extends State<_GridHeader> { buildWhen: (previous, current) => previous.fields != current.fields, builder: (context, state) { final cells = state.fields - .where((field) => field.visibility) + .where((fieldInfo) => fieldInfo.field.visibility) .map( (field) => FieldContext( viewId: widget.viewId, diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/type_option/builder.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/type_option/builder.dart index 1047031a4f..3de4ecd6fa 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/type_option/builder.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/type_option/builder.dart @@ -1,6 +1,6 @@ import 'dart:typed_data'; -import 'package:appflowy/plugins/database_view/application/field/field_controller.dart'; +import 'package:appflowy/plugins/database_view/application/field/field_info.dart'; import 'package:appflowy/plugins/database_view/application/field/type_option/type_option_context.dart'; import 'package:appflowy/plugins/database_view/application/field/type_option/type_option_data_controller.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/checkbox_entities.pb.dart'; diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/row/row.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/row/row.dart index 9776728bd6..954bc12584 100755 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/row/row.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/row/row.dart @@ -276,13 +276,13 @@ class RowContent extends StatelessWidget { final GridCellWidget child = builder.build(cellId); return CellContainer( - width: cellId.fieldInfo.width.toDouble(), - isPrimary: cellId.fieldInfo.isPrimary, + width: cellId.fieldInfo.field.width.toDouble(), + isPrimary: cellId.fieldInfo.field.isPrimary, cellContainerNotifier: CellContainerNotifier(child), accessoryBuilder: (buildContext) { final builder = child.accessoryBuilder; final List accessories = []; - if (cellId.fieldInfo.isPrimary) { + if (cellId.fieldInfo.field.isPrimary) { accessories.add( GridCellAccessoryBuilder( builder: (key) => PrimaryCellAccessory( diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/sort/create_sort_list.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/sort/create_sort_list.dart index b9c6d2468a..a23e651cdc 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/sort/create_sort_list.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/sort/create_sort_list.dart @@ -1,5 +1,6 @@ import 'package:appflowy/generated/locale_keys.g.dart'; import 'package:appflowy/plugins/database_view/application/field/field_controller.dart'; +import 'package:appflowy/plugins/database_view/application/field/field_info.dart'; import 'package:appflowy/plugins/database_view/grid/application/sort/sort_create_bloc.dart'; import 'package:appflowy/plugins/database_view/grid/presentation/layout/sizes.dart'; import 'package:appflowy/plugins/database_view/grid/presentation/widgets/header/field_type_extension.dart'; diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/sort/sort_info.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/sort/sort_info.dart index ff19e8794b..21185b3014 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/sort/sort_info.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/sort/sort_info.dart @@ -1,4 +1,4 @@ -import 'package:appflowy/plugins/database_view/application/field/field_controller.dart'; +import 'package:appflowy/plugins/database_view/application/field/field_info.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/sort_entities.pb.dart'; class SortInfo { diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/bloc/date_card_cell_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/bloc/date_card_cell_bloc.dart index d852892bf8..40ddc24438 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/bloc/date_card_cell_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/bloc/date_card_cell_bloc.dart @@ -1,10 +1,10 @@ +import 'package:appflowy/plugins/database_view/application/field/field_info.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/date_entities.pb.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'dart:async'; import '../../../application/cell/cell_controller_builder.dart'; -import '../../../application/field/field_controller.dart'; part 'date_card_cell_bloc.freezed.dart'; class DateCardCellBloc extends Bloc { diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/field/grid_property.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/field/grid_property.dart index 10a3985a9a..9d063ec5a1 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/field/grid_property.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/field/grid_property.dart @@ -1,4 +1,5 @@ import 'package:appflowy/plugins/database_view/application/field/field_controller.dart'; +import 'package:appflowy/plugins/database_view/application/field/field_info.dart'; import 'package:appflowy/plugins/database_view/application/field/type_option/type_option_context.dart'; import 'package:appflowy/plugins/database_view/application/setting/property_bloc.dart'; import 'package:appflowy/plugins/database_view/grid/presentation/widgets/header/field_type_extension.dart'; @@ -95,7 +96,7 @@ class _GridPropertyCellState extends State<_GridPropertyCell> { @override Widget build(BuildContext context) { final checkmark = svgWidget( - widget.fieldInfo.visibility ? 'home/show' : 'home/hide', + widget.fieldInfo.field.visibility ? 'home/show' : 'home/hide', color: Theme.of(context).iconTheme.color, ); @@ -130,7 +131,7 @@ class _GridPropertyCellState extends State<_GridPropertyCell> { context.read().add( DatabasePropertyEvent.setFieldVisibility( widget.fieldInfo.id, - !widget.fieldInfo.visibility, + !widget.fieldInfo.field.visibility, ), ); }, diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/group/database_group.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/group/database_group.dart index a85616e51c..ef8a452ac6 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/group/database_group.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/group/database_group.dart @@ -1,4 +1,5 @@ import 'package:appflowy/plugins/database_view/application/field/field_controller.dart'; +import 'package:appflowy/plugins/database_view/application/field/field_info.dart'; import 'package:appflowy/plugins/database_view/application/setting/group_bloc.dart'; import 'package:appflowy/plugins/database_view/grid/presentation/layout/sizes.dart'; import 'package:appflowy/plugins/database_view/grid/presentation/widgets/header/field_type_extension.dart'; @@ -30,8 +31,9 @@ class DatabaseGroupList extends StatelessWidget { fieldController: fieldController, )..add(const DatabaseGroupEvent.initial()), child: BlocBuilder( + buildWhen: (previous, current) => true, builder: (context, state) { - final cells = state.fieldContexts.map((fieldInfo) { + final cells = state.fieldInfos.map((fieldInfo) { Widget cell = _GridGroupCell( fieldInfo: fieldInfo, onSelected: () => onDismissed(), diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/date_cell/date_cell_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/date_cell/date_cell_bloc.dart index 5ce1e87cc0..e967ebbb81 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/date_cell/date_cell_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/date_cell/date_cell_bloc.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart'; -import 'package:appflowy/plugins/database_view/application/field/field_controller.dart'; +import 'package:appflowy/plugins/database_view/application/field/field_info.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/date_entities.pb.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/row_property.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/row_property.dart index b982239e40..738d9c84bf 100644 --- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/row_property.dart +++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/row_property.dart @@ -44,7 +44,7 @@ class RowPropertyList extends StatelessWidget { // The rest of the fields are displayed in the order of the field // list ...state.cells - .where((element) => !element.fieldInfo.isPrimary) + .where((element) => !element.fieldInfo.field.isPrimary) .map( (cell) => _PropertyCell( cellContext: cell, diff --git a/frontend/appflowy_flutter/test/bloc_test/board_test/util.dart b/frontend/appflowy_flutter/test/bloc_test/board_test/util.dart index f293829ec5..74ffaf31ee 100644 --- a/frontend/appflowy_flutter/test/bloc_test/board_test/util.dart +++ b/frontend/appflowy_flutter/test/bloc_test/board_test/util.dart @@ -2,6 +2,7 @@ import 'package:appflowy/plugins/database_view/application/cell/cell_controller. import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart'; import 'package:appflowy/plugins/database_view/application/field/field_controller.dart'; import 'package:appflowy/plugins/database_view/application/field/field_editor_bloc.dart'; +import 'package:appflowy/plugins/database_view/application/field/field_info.dart'; import 'package:appflowy/plugins/database_view/application/field/field_service.dart'; import 'package:appflowy/plugins/database_view/application/field/type_option/type_option_context.dart'; import 'package:appflowy/plugins/database_view/application/row/row_cache.dart'; diff --git a/frontend/appflowy_flutter/test/bloc_test/grid_test/util.dart b/frontend/appflowy_flutter/test/bloc_test/grid_test/util.dart index accb4aa7cf..b3cb4df4ab 100644 --- a/frontend/appflowy_flutter/test/bloc_test/grid_test/util.dart +++ b/frontend/appflowy_flutter/test/bloc_test/grid_test/util.dart @@ -2,6 +2,7 @@ import 'package:appflowy/plugins/database_view/application/cell/cell_controller. import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart'; import 'package:appflowy/plugins/database_view/application/field/field_controller.dart'; import 'package:appflowy/plugins/database_view/application/field/field_editor_bloc.dart'; +import 'package:appflowy/plugins/database_view/application/field/field_info.dart'; import 'package:appflowy/plugins/database_view/application/field/field_service.dart'; import 'package:appflowy/plugins/database_view/application/field/type_option/type_option_context.dart'; import 'package:appflowy/plugins/database_view/application/field/type_option/type_option_service.dart'; @@ -149,7 +150,7 @@ Future createFieldEditor({ field: data.field_2, ); return FieldEditorBloc( - isGroupField: FieldInfo(field: data.field_2).isGroupField, + isGroupField: FieldInfo.initial(data.field_2).isGroupField, loader: loader, field: data.field_2, ); diff --git a/frontend/appflowy_tauri/src-tauri/Cargo.toml b/frontend/appflowy_tauri/src-tauri/Cargo.toml index 164ca6e044..bffc8a3fc7 100644 --- a/frontend/appflowy_tauri/src-tauri/Cargo.toml +++ b/frontend/appflowy_tauri/src-tauri/Cargo.toml @@ -34,13 +34,13 @@ default = ["custom-protocol"] custom-protocol = ["tauri/custom-protocol"] [patch.crates-io] -collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "aac4e56" } -collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "aac4e56" } -collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "aac4e56" } -collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "aac4e56" } -collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "aac4e56" } -appflowy-integrate = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "aac4e56" } -collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "aac4e56" } +collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ba963f" } +collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ba963f" } +collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ba963f" } +collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ba963f" } +collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ba963f" } +appflowy-integrate = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ba963f" } +collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ba963f" } #collab = { path = "../../../../AppFlowy-Collab/collab" } #collab-folder = { path = "../../../../AppFlowy-Collab/collab-folder" } diff --git a/frontend/rust-lib/Cargo.lock b/frontend/rust-lib/Cargo.lock index a4572fc85a..99949c314e 100644 --- a/frontend/rust-lib/Cargo.lock +++ b/frontend/rust-lib/Cargo.lock @@ -96,7 +96,7 @@ checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" [[package]] name = "appflowy-integrate" version = "0.1.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=aac4e56#aac4e56bdb6a61598697283582d369a7af85d9c8" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ba963f#ba963fa299d294e5b2cafd940b9eaa8520280b7b" dependencies = [ "anyhow", "collab", @@ -925,7 +925,7 @@ dependencies = [ [[package]] name = "collab" version = "0.1.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=aac4e56#aac4e56bdb6a61598697283582d369a7af85d9c8" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ba963f#ba963fa299d294e5b2cafd940b9eaa8520280b7b" dependencies = [ "anyhow", "bytes", @@ -943,7 +943,7 @@ dependencies = [ [[package]] name = "collab-client-ws" version = "0.1.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=aac4e56#aac4e56bdb6a61598697283582d369a7af85d9c8" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ba963f#ba963fa299d294e5b2cafd940b9eaa8520280b7b" dependencies = [ "bytes", "collab-sync", @@ -961,7 +961,7 @@ dependencies = [ [[package]] name = "collab-database" version = "0.1.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=aac4e56#aac4e56bdb6a61598697283582d369a7af85d9c8" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ba963f#ba963fa299d294e5b2cafd940b9eaa8520280b7b" dependencies = [ "anyhow", "async-trait", @@ -988,7 +988,7 @@ dependencies = [ [[package]] name = "collab-derive" version = "0.1.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=aac4e56#aac4e56bdb6a61598697283582d369a7af85d9c8" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ba963f#ba963fa299d294e5b2cafd940b9eaa8520280b7b" dependencies = [ "proc-macro2", "quote", @@ -1000,7 +1000,7 @@ dependencies = [ [[package]] name = "collab-document" version = "0.1.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=aac4e56#aac4e56bdb6a61598697283582d369a7af85d9c8" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ba963f#ba963fa299d294e5b2cafd940b9eaa8520280b7b" dependencies = [ "anyhow", "collab", @@ -1019,7 +1019,7 @@ dependencies = [ [[package]] name = "collab-folder" version = "0.1.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=aac4e56#aac4e56bdb6a61598697283582d369a7af85d9c8" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ba963f#ba963fa299d294e5b2cafd940b9eaa8520280b7b" dependencies = [ "anyhow", "chrono", @@ -1039,7 +1039,7 @@ dependencies = [ [[package]] name = "collab-persistence" version = "0.1.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=aac4e56#aac4e56bdb6a61598697283582d369a7af85d9c8" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ba963f#ba963fa299d294e5b2cafd940b9eaa8520280b7b" dependencies = [ "bincode", "chrono", @@ -1059,7 +1059,7 @@ dependencies = [ [[package]] name = "collab-plugins" version = "0.1.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=aac4e56#aac4e56bdb6a61598697283582d369a7af85d9c8" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ba963f#ba963fa299d294e5b2cafd940b9eaa8520280b7b" dependencies = [ "anyhow", "async-trait", @@ -1089,7 +1089,7 @@ dependencies = [ [[package]] name = "collab-sync" version = "0.1.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=aac4e56#aac4e56bdb6a61598697283582d369a7af85d9c8" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ba963f#ba963fa299d294e5b2cafd940b9eaa8520280b7b" dependencies = [ "bytes", "collab", diff --git a/frontend/rust-lib/Cargo.toml b/frontend/rust-lib/Cargo.toml index 4395a999a0..a34388ed57 100644 --- a/frontend/rust-lib/Cargo.toml +++ b/frontend/rust-lib/Cargo.toml @@ -38,17 +38,17 @@ opt-level = 3 incremental = false [patch.crates-io] -collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "aac4e56" } -collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "aac4e56" } -collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "aac4e56" } -collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "aac4e56" } -appflowy-integrate = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "aac4e56" } -collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "aac4e56" } -# -#collab = { path = "../../../AppFlowy-Collab/collab" } -#collab-folder = { path = "../../../AppFlowy-Collab/collab-folder" } -#collab-database= { path = "../../../AppFlowy-Collab/collab-database" } -#collab-document = { path = "../../../AppFlowy-Collab/collab-document" } -#collab-plugins = { path = "../../../AppFlowy-Collab/collab-plugins" } -#appflowy-integrate = { path = "../../../AppFlowy-Collab/appflowy-integrate" } +collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ba963f" } +collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ba963f" } +collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ba963f" } +collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ba963f" } +appflowy-integrate = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ba963f" } +collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ba963f" } + +#collab = { path = "../AppFlowy-Collab/collab" } +#collab-folder = { path = "../AppFlowy-Collab/collab-folder" } +#collab-database= { path = "../AppFlowy-Collab/collab-database" } +#collab-document = { path = "../AppFlowy-Collab/collab-document" } +#collab-plugins = { path = "../AppFlowy-Collab/collab-plugins" } +#appflowy-integrate = { path = "../AppFlowy-Collab/appflowy-integrate" } diff --git a/frontend/rust-lib/flowy-database2/src/services/database/database_editor.rs b/frontend/rust-lib/flowy-database2/src/services/database/database_editor.rs index d986c85d4e..d67b0ebdc0 100644 --- a/frontend/rust-lib/flowy-database2/src/services/database/database_editor.rs +++ b/frontend/rust-lib/flowy-database2/src/services/database/database_editor.rs @@ -134,7 +134,9 @@ impl DatabaseEditor { let field = database.fields.get_field(field_id); if let Some(field) = field { let group_setting = default_group_setting(&field); - database.insert_group_setting(view_id, group_setting); + database.views.update_database_view(view_id, |view| { + view.set_groups(vec![group_setting.into()]); + }); } }