From 4de0008e443f15c6039053e81992556526fecf66 Mon Sep 17 00:00:00 2001 From: appflowy Date: Mon, 5 Sep 2022 17:13:52 +0800 Subject: [PATCH] chore: disable group field that does not support grouping --- .../application/field/field_controller.dart | 21 +++++++++++++++++++ .../widgets/toolbar/grid_group.dart | 7 ++++++- frontend/app_flowy/pubspec.lock | 2 +- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/frontend/app_flowy/lib/plugins/grid/application/field/field_controller.dart b/frontend/app_flowy/lib/plugins/grid/application/field/field_controller.dart index 7eb20a8a06..73127ed6df 100644 --- a/frontend/app_flowy/lib/plugins/grid/application/field/field_controller.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/field/field_controller.dart @@ -290,5 +290,26 @@ class GridFieldContext { bool get isGroupField => _isGroupField; + bool get canGroup { + switch (_field.fieldType) { + case FieldType.Checkbox: + return true; + case FieldType.DateTime: + return false; + case FieldType.MultiSelect: + return true; + case FieldType.Number: + return false; + case FieldType.RichText: + return false; + case FieldType.SingleSelect: + return true; + case FieldType.URL: + return false; + } + + return false; + } + GridFieldContext({required FieldPB field}) : _field = field; } diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_group.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_group.dart index 0a82eef4bb..b400cda0fe 100644 --- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_group.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_group.dart @@ -31,10 +31,15 @@ class GridGroupList extends StatelessWidget { child: BlocBuilder( builder: (context, state) { final cells = state.fieldContexts.map((fieldContext) { - return _GridGroupCell( + Widget cell = _GridGroupCell( fieldContext: fieldContext, key: ValueKey(fieldContext.id), ); + + if (!fieldContext.canGroup) { + cell = IgnorePointer(child: Opacity(opacity: 0.3, child: cell)); + } + return cell; }).toList(); return ListView.separated( diff --git a/frontend/app_flowy/pubspec.lock b/frontend/app_flowy/pubspec.lock index bb8391eee9..8b8b9cfb05 100644 --- a/frontend/app_flowy/pubspec.lock +++ b/frontend/app_flowy/pubspec.lock @@ -35,7 +35,7 @@ packages: path: "packages/appflowy_editor" relative: true source: path - version: "0.0.3" + version: "0.0.4" args: dependency: transitive description: