mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
This commit is contained in:
parent
0c0bd54f52
commit
9b7ee4b978
@ -0,0 +1,37 @@
|
|||||||
|
import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart';
|
||||||
|
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:integration_test/integration_test.dart';
|
||||||
|
|
||||||
|
import '../../shared/database_test_op.dart';
|
||||||
|
import '../../shared/util.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
|
group('board field test', () {
|
||||||
|
testWidgets('change field type whithin card #5360', (tester) async {
|
||||||
|
await tester.initializeAppFlowy();
|
||||||
|
await tester.tapAnonymousSignInButton();
|
||||||
|
|
||||||
|
await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Board);
|
||||||
|
const name = 'Card 1';
|
||||||
|
final card1 = find.text(name);
|
||||||
|
await tester.tapButton(card1);
|
||||||
|
|
||||||
|
const fieldName = "test change field";
|
||||||
|
await tester.createField(
|
||||||
|
FieldType.RichText,
|
||||||
|
fieldName,
|
||||||
|
layout: ViewLayoutPB.Board,
|
||||||
|
);
|
||||||
|
await tester.tapButton(card1);
|
||||||
|
await tester.changeFieldTypeOfFieldWithName(
|
||||||
|
fieldName,
|
||||||
|
FieldType.Checkbox,
|
||||||
|
layout: ViewLayoutPB.Board,
|
||||||
|
);
|
||||||
|
await tester.hoverOnWidget(find.text('Card 2'));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
@ -661,10 +661,13 @@ extension AppFlowyDatabaseTest on WidgetTester {
|
|||||||
|
|
||||||
Future<void> changeFieldTypeOfFieldWithName(
|
Future<void> changeFieldTypeOfFieldWithName(
|
||||||
String name,
|
String name,
|
||||||
FieldType type,
|
FieldType type, {
|
||||||
) async {
|
ViewLayoutPB layout = ViewLayoutPB.Grid,
|
||||||
|
}) async {
|
||||||
await tapGridFieldWithName(name);
|
await tapGridFieldWithName(name);
|
||||||
await tapEditFieldButton();
|
if (layout == ViewLayoutPB.Grid) {
|
||||||
|
await tapEditFieldButton();
|
||||||
|
}
|
||||||
|
|
||||||
await tapSwitchFieldTypeButton();
|
await tapSwitchFieldTypeButton();
|
||||||
await selectFieldType(type);
|
await selectFieldType(type);
|
||||||
@ -881,8 +884,14 @@ extension AppFlowyDatabaseTest on WidgetTester {
|
|||||||
await tapButtonWithName(LocaleKeys.grid_row_delete.tr());
|
await tapButtonWithName(LocaleKeys.grid_row_delete.tr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> createField(FieldType fieldType, String name) async {
|
Future<void> createField(
|
||||||
await scrollToRight(find.byType(GridPage));
|
FieldType fieldType,
|
||||||
|
String name, {
|
||||||
|
ViewLayoutPB layout = ViewLayoutPB.Grid,
|
||||||
|
}) async {
|
||||||
|
if (layout == ViewLayoutPB.Grid) {
|
||||||
|
await scrollToRight(find.byType(GridPage));
|
||||||
|
}
|
||||||
await tapNewPropertyButton();
|
await tapNewPropertyButton();
|
||||||
await renameField(name);
|
await renameField(name);
|
||||||
await tapSwitchFieldTypeButton();
|
await tapSwitchFieldTypeButton();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import 'package:appflowy/plugins/database/application/cell/cell_controller.dart';
|
|
||||||
import 'package:appflowy/plugins/database/widgets/card/card.dart';
|
import 'package:appflowy/plugins/database/widgets/card/card.dart';
|
||||||
|
import 'package:appflowy/plugins/database/widgets/card/card_bloc.dart';
|
||||||
import 'package:appflowy/plugins/database/widgets/cell/card_cell_builder.dart';
|
import 'package:appflowy/plugins/database/widgets/cell/card_cell_builder.dart';
|
||||||
import 'package:appflowy/plugins/database/widgets/cell/card_cell_style_maps/mobile_board_card_cell_style.dart';
|
import 'package:appflowy/plugins/database/widgets/cell/card_cell_style_maps/mobile_board_card_cell_style.dart';
|
||||||
import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart';
|
import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart';
|
||||||
@ -16,7 +16,7 @@ class MobileCardContent extends StatelessWidget {
|
|||||||
|
|
||||||
final RowMetaPB rowMeta;
|
final RowMetaPB rowMeta;
|
||||||
final CardCellBuilder cellBuilder;
|
final CardCellBuilder cellBuilder;
|
||||||
final List<CellContext> cells;
|
final List<CellMeta> cells;
|
||||||
final RowCardStyleConfiguration styleConfiguration;
|
final RowCardStyleConfiguration styleConfiguration;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -26,9 +26,9 @@ class MobileCardContent extends StatelessWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: cells.map(
|
children: cells.map(
|
||||||
(cellContext) {
|
(cellMeta) {
|
||||||
return cellBuilder.build(
|
return cellBuilder.build(
|
||||||
cellContext: cellContext,
|
cellContext: cellMeta.cellContext(),
|
||||||
styleMap: mobileBoardCardCellStyleMap(context),
|
styleMap: mobileBoardCardCellStyleMap(context),
|
||||||
hasNotes: !rowMeta.isDocumentEmpty,
|
hasNotes: !rowMeta.isDocumentEmpty,
|
||||||
);
|
);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import 'package:appflowy/generated/flowy_svgs.g.dart';
|
import 'package:appflowy/generated/flowy_svgs.g.dart';
|
||||||
import 'package:appflowy/mobile/presentation/database/card/card.dart';
|
import 'package:appflowy/mobile/presentation/database/card/card.dart';
|
||||||
import 'package:appflowy/plugins/database/application/cell/cell_controller.dart';
|
|
||||||
import 'package:appflowy/plugins/database/application/field/field_controller.dart';
|
import 'package:appflowy/plugins/database/application/field/field_controller.dart';
|
||||||
import 'package:appflowy/plugins/database/application/row/row_cache.dart';
|
import 'package:appflowy/plugins/database/application/row/row_cache.dart';
|
||||||
import 'package:appflowy/plugins/database/grid/presentation/widgets/row/action.dart';
|
import 'package:appflowy/plugins/database/grid/presentation/widgets/row/action.dart';
|
||||||
@ -186,7 +185,7 @@ class _CardContent extends StatelessWidget {
|
|||||||
|
|
||||||
final RowMetaPB rowMeta;
|
final RowMetaPB rowMeta;
|
||||||
final CardCellBuilder cellBuilder;
|
final CardCellBuilder cellBuilder;
|
||||||
final List<CellContext> cells;
|
final List<CellMeta> cells;
|
||||||
final RowCardStyleConfiguration styleConfiguration;
|
final RowCardStyleConfiguration styleConfiguration;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -210,9 +209,9 @@ class _CardContent extends StatelessWidget {
|
|||||||
List<Widget> _makeCells(
|
List<Widget> _makeCells(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
RowMetaPB rowMeta,
|
RowMetaPB rowMeta,
|
||||||
List<CellContext> cells,
|
List<CellMeta> cells,
|
||||||
) {
|
) {
|
||||||
return cells.mapIndexed((int index, CellContext cellContext) {
|
return cells.mapIndexed((int index, CellMeta cellMeta) {
|
||||||
EditableCardNotifier? cellNotifier;
|
EditableCardNotifier? cellNotifier;
|
||||||
|
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
@ -225,7 +224,7 @@ class _CardContent extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return cellBuilder.build(
|
return cellBuilder.build(
|
||||||
cellContext: cellContext,
|
cellContext: cellMeta.cellContext(),
|
||||||
cellNotifier: cellNotifier,
|
cellNotifier: cellNotifier,
|
||||||
styleMap: styleConfiguration.cellStyleMap,
|
styleMap: styleConfiguration.cellStyleMap,
|
||||||
hasNotes: !rowMeta.isDocumentEmpty,
|
hasNotes: !rowMeta.isDocumentEmpty,
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:appflowy/plugins/database/application/row/row_service.dart';
|
||||||
|
import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
import 'package:appflowy/plugins/database/application/cell/cell_controller.dart';
|
import 'package:appflowy/plugins/database/application/cell/cell_controller.dart';
|
||||||
@ -7,7 +9,6 @@ import 'package:appflowy/plugins/database/application/field/field_controller.dar
|
|||||||
import 'package:appflowy/plugins/database/application/row/row_cache.dart';
|
import 'package:appflowy/plugins/database/application/row/row_cache.dart';
|
||||||
import 'package:appflowy/plugins/database/domain/row_listener.dart';
|
import 'package:appflowy/plugins/database/domain/row_listener.dart';
|
||||||
import 'package:appflowy/plugins/database/widgets/setting/field_visibility_extension.dart';
|
import 'package:appflowy/plugins/database/widgets/setting/field_visibility_extension.dart';
|
||||||
import 'package:appflowy_backend/protobuf/flowy-database2/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';
|
||||||
|
|
||||||
@ -104,7 +105,7 @@ class CardBloc extends Bloc<CardEvent, CardState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<CellContext> _makeCells(
|
List<CellMeta> _makeCells(
|
||||||
FieldController fieldController,
|
FieldController fieldController,
|
||||||
String? groupFieldId,
|
String? groupFieldId,
|
||||||
List<CellContext> cellContexts,
|
List<CellContext> cellContexts,
|
||||||
@ -116,7 +117,15 @@ List<CellContext> _makeCells(
|
|||||||
!(fieldInfo.visibility?.isVisibleState() ?? false) ||
|
!(fieldInfo.visibility?.isVisibleState() ?? false) ||
|
||||||
(groupFieldId != null && cellContext.fieldId == groupFieldId);
|
(groupFieldId != null && cellContext.fieldId == groupFieldId);
|
||||||
});
|
});
|
||||||
return cellContexts.toList();
|
return cellContexts
|
||||||
|
.map(
|
||||||
|
(cellCtx) => CellMeta(
|
||||||
|
fieldId: cellCtx.fieldId,
|
||||||
|
rowId: cellCtx.rowId,
|
||||||
|
fieldType: fieldController.getField(cellCtx.fieldId)!.fieldType,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
@ -124,17 +133,30 @@ class CardEvent with _$CardEvent {
|
|||||||
const factory CardEvent.initial() = _InitialRow;
|
const factory CardEvent.initial() = _InitialRow;
|
||||||
const factory CardEvent.setIsEditing(bool isEditing) = _IsEditing;
|
const factory CardEvent.setIsEditing(bool isEditing) = _IsEditing;
|
||||||
const factory CardEvent.didReceiveCells(
|
const factory CardEvent.didReceiveCells(
|
||||||
List<CellContext> cells,
|
List<CellMeta> cells,
|
||||||
ChangedReason reason,
|
ChangedReason reason,
|
||||||
) = _DidReceiveCells;
|
) = _DidReceiveCells;
|
||||||
const factory CardEvent.didUpdateRowMeta(RowMetaPB rowMeta) =
|
const factory CardEvent.didUpdateRowMeta(RowMetaPB rowMeta) =
|
||||||
_DidUpdateRowMeta;
|
_DidUpdateRowMeta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class CellMeta with _$CellMeta {
|
||||||
|
const CellMeta._();
|
||||||
|
|
||||||
|
const factory CellMeta({
|
||||||
|
required String fieldId,
|
||||||
|
required RowId rowId,
|
||||||
|
required FieldType fieldType,
|
||||||
|
}) = _DatabaseCellMeta;
|
||||||
|
|
||||||
|
CellContext cellContext() => CellContext(fieldId: fieldId, rowId: rowId);
|
||||||
|
}
|
||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
class CardState with _$CardState {
|
class CardState with _$CardState {
|
||||||
const factory CardState({
|
const factory CardState({
|
||||||
required List<CellContext> cells,
|
required List<CellMeta> cells,
|
||||||
required RowMetaPB rowMeta,
|
required RowMetaPB rowMeta,
|
||||||
required bool isEditing,
|
required bool isEditing,
|
||||||
ChangedReason? changeReason,
|
ChangedReason? changeReason,
|
||||||
@ -142,7 +164,7 @@ class CardState with _$CardState {
|
|||||||
|
|
||||||
factory CardState.initial(
|
factory CardState.initial(
|
||||||
RowMetaPB rowMeta,
|
RowMetaPB rowMeta,
|
||||||
List<CellContext> cells,
|
List<CellMeta> cells,
|
||||||
bool isEditing,
|
bool isEditing,
|
||||||
) =>
|
) =>
|
||||||
CardState(
|
CardState(
|
||||||
|
Loading…
Reference in New Issue
Block a user