Skip to content

Commit 19da42f

Browse files
committed
chore: add date cell handler
1 parent a2dfc8b commit 19da42f

File tree

38 files changed

+993
-506
lines changed

38 files changed

+993
-506
lines changed

frontend/app_flowy/lib/workspace/application/grid/cell/cell_service.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ class CellService {
344344
..gridId = gridId
345345
..fieldId = fieldId
346346
..rowId = rowId
347-
..data = data;
347+
..cellContentChangeset = data;
348348
return GridEventUpdateCell(payload).send();
349349
}
350350

frontend/app_flowy/lib/workspace/application/grid/cell/date_cal_bloc.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ class DateCalBloc extends Bloc<DateCalEvent, DateCalState> {
5151
setTimeFormat: (_TimeFormat value) async {
5252
await _updateTypeOption(emit, timeFormat: value.timeFormat);
5353
},
54-
setTime: (_Time value) {},
54+
setTime: (_Time value) {
55+
//
56+
},
5557
);
5658
},
5759
);

frontend/app_flowy/lib/workspace/application/grid/cell/select_option_service.dart

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,27 +60,18 @@ class SelectOptionService {
6060
Future<Either<Unit, FlowyError>> update({
6161
required SelectOption option,
6262
}) {
63-
final cellIdentifier = CellIdentifierPayload.create()
64-
..gridId = gridId
65-
..fieldId = fieldId
66-
..rowId = rowId;
6763
final payload = SelectOptionChangesetPayload.create()
6864
..updateOption = option
69-
..cellIdentifier = cellIdentifier;
65+
..cellIdentifier = _cellIdentifier();
7066
return GridEventUpdateSelectOption(payload).send();
7167
}
7268

7369
Future<Either<Unit, FlowyError>> delete({
7470
required SelectOption option,
7571
}) {
76-
final cellIdentifier = CellIdentifierPayload.create()
77-
..gridId = gridId
78-
..fieldId = fieldId
79-
..rowId = rowId;
80-
8172
final payload = SelectOptionChangesetPayload.create()
8273
..deleteOption = option
83-
..cellIdentifier = cellIdentifier;
74+
..cellIdentifier = _cellIdentifier();
8475

8576
return GridEventUpdateSelectOption(payload).send();
8677
}
@@ -96,19 +87,22 @@ class SelectOptionService {
9687

9788
Future<Either<void, FlowyError>> select({required String optionId}) {
9889
final payload = SelectOptionCellChangesetPayload.create()
99-
..gridId = gridId
100-
..fieldId = fieldId
101-
..rowId = rowId
90+
..cellIdentifier = _cellIdentifier()
10291
..insertOptionId = optionId;
103-
return GridEventUpdateCellSelectOption(payload).send();
92+
return GridEventUpdateSelectOptionCell(payload).send();
10493
}
10594

10695
Future<Either<void, FlowyError>> unSelect({required String optionId}) {
10796
final payload = SelectOptionCellChangesetPayload.create()
97+
..cellIdentifier = _cellIdentifier()
98+
..deleteOptionId = optionId;
99+
return GridEventUpdateSelectOptionCell(payload).send();
100+
}
101+
102+
CellIdentifierPayload _cellIdentifier() {
103+
return CellIdentifierPayload.create()
108104
..gridId = gridId
109105
..fieldId = fieldId
110-
..rowId = rowId
111-
..deleteOptionId = optionId;
112-
return GridEventUpdateCellSelectOption(payload).send();
106+
..rowId = rowId;
113107
}
114108
}

frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/date_cell/calendar.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ class _CalDateTimeSetting extends StatefulWidget {
309309
identifier: _CalDateTimeSetting.identifier(),
310310
anchorContext: context,
311311
anchorDirection: AnchorDirection.rightWithCenterAligned,
312+
anchorOffset: const Offset(20, 0),
312313
);
313314
}
314315
}
@@ -369,7 +370,7 @@ class _CalDateTimeSettingState extends State<_CalDateTimeSetting> {
369370
anchorContext: context,
370371
anchorDirection: AnchorDirection.rightWithCenterAligned,
371372
style: FlowyOverlayStyle(blur: false),
372-
anchorOffset: const Offset(-20, 0),
373+
anchorOffset: const Offset(20, 0),
373374
);
374375
}
375376
}

frontend/app_flowy/packages/flowy_sdk/lib/dispatch/dart_event/flowy-grid/dart_event.dart

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,30 @@ class GridEventUpdateCell {
358358
}
359359
}
360360

361-
class GridEventUpdateCellSelectOption {
361+
class GridEventUpdateSelectOptionCell {
362362
SelectOptionCellChangesetPayload request;
363-
GridEventUpdateCellSelectOption(this.request);
363+
GridEventUpdateSelectOptionCell(this.request);
364364

365365
Future<Either<Unit, FlowyError>> send() {
366366
final request = FFIRequest.create()
367-
..event = GridEvent.UpdateCellSelectOption.toString()
367+
..event = GridEvent.UpdateSelectOptionCell.toString()
368+
..payload = requestToBytes(this.request);
369+
370+
return Dispatch.asyncRequest(request)
371+
.then((bytesResult) => bytesResult.fold(
372+
(bytes) => left(unit),
373+
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
374+
));
375+
}
376+
}
377+
378+
class GridEventUpdateDateCell {
379+
DateChangesetPayload request;
380+
GridEventUpdateDateCell(this.request);
381+
382+
Future<Either<Unit, FlowyError>> send() {
383+
final request = FFIRequest.create()
384+
..event = GridEvent.UpdateDateCell.toString()
368385
..payload = requestToBytes(this.request);
369386

370387
return Dispatch.asyncRequest(request)

frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-grid-data-model/grid.pb.dart

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-grid-data-model/grid.pbjson.dart

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-grid/date_type_option.pb.dart

Lines changed: 105 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-grid/date_type_option.pbjson.dart

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-grid/event_map.pbenum.dart

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)