mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: disable edit update or create field (#2657)
* feat: enable hide the grid property in row detail page * feat: disable update the updatedAt or createdAt cell
This commit is contained in:
@ -34,11 +34,17 @@ class GridCellBuilder {
|
|||||||
key: key,
|
key: key,
|
||||||
);
|
);
|
||||||
case FieldType.DateTime:
|
case FieldType.DateTime:
|
||||||
|
return GridDateCell(
|
||||||
|
cellControllerBuilder: cellControllerBuilder,
|
||||||
|
key: key,
|
||||||
|
style: style,
|
||||||
|
);
|
||||||
case FieldType.UpdatedAt:
|
case FieldType.UpdatedAt:
|
||||||
case FieldType.CreatedAt:
|
case FieldType.CreatedAt:
|
||||||
return GridDateCell(
|
return GridDateCell(
|
||||||
cellControllerBuilder: cellControllerBuilder,
|
cellControllerBuilder: cellControllerBuilder,
|
||||||
key: key,
|
key: key,
|
||||||
|
editable: false,
|
||||||
style: style,
|
style: style,
|
||||||
);
|
);
|
||||||
case FieldType.SingleSelect:
|
case FieldType.SingleSelect:
|
||||||
|
@ -21,12 +21,14 @@ abstract class GridCellDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class GridDateCell extends GridCellWidget {
|
class GridDateCell extends GridCellWidget {
|
||||||
|
final bool editable;
|
||||||
final CellControllerBuilder cellControllerBuilder;
|
final CellControllerBuilder cellControllerBuilder;
|
||||||
late final DateCellStyle? cellStyle;
|
late final DateCellStyle? cellStyle;
|
||||||
|
|
||||||
GridDateCell({
|
GridDateCell({
|
||||||
GridCellStyle? style,
|
GridCellStyle? style,
|
||||||
required this.cellControllerBuilder,
|
required this.cellControllerBuilder,
|
||||||
|
this.editable = true,
|
||||||
Key? key,
|
Key? key,
|
||||||
}) : super(key: key) {
|
}) : super(key: key) {
|
||||||
if (style != null) {
|
if (style != null) {
|
||||||
@ -63,35 +65,41 @@ class _DateCellState extends GridCellState<GridDateCell> {
|
|||||||
value: _cellBloc,
|
value: _cellBloc,
|
||||||
child: BlocBuilder<DateCellBloc, DateCellState>(
|
child: BlocBuilder<DateCellBloc, DateCellState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return AppFlowyPopover(
|
Widget dateTextWidget = SizedBox.expand(
|
||||||
controller: _popover,
|
child: Align(
|
||||||
triggerActions: PopoverTriggerFlags.none,
|
alignment: alignment,
|
||||||
direction: PopoverDirection.bottomWithLeftAligned,
|
child: Padding(
|
||||||
constraints: BoxConstraints.loose(const Size(260, 500)),
|
padding: GridSize.cellContentInsets,
|
||||||
margin: EdgeInsets.zero,
|
child: FlowyText.medium(
|
||||||
child: SizedBox.expand(
|
state.dateStr,
|
||||||
child: Align(
|
overflow: TextOverflow.ellipsis,
|
||||||
alignment: alignment,
|
|
||||||
child: Padding(
|
|
||||||
padding: GridSize.cellContentInsets,
|
|
||||||
child: FlowyText.medium(
|
|
||||||
state.dateStr,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
popupBuilder: (BuildContext popoverContent) {
|
|
||||||
return DateCellEditor(
|
|
||||||
cellController:
|
|
||||||
widget.cellControllerBuilder.build() as DateCellController,
|
|
||||||
onDismissed: () => widget.onCellEditing.value = false,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
onClose: () {
|
|
||||||
widget.onCellEditing.value = false;
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// If the cell is editable, wrap it in a popover.
|
||||||
|
if (widget.editable) {
|
||||||
|
dateTextWidget = AppFlowyPopover(
|
||||||
|
controller: _popover,
|
||||||
|
triggerActions: PopoverTriggerFlags.none,
|
||||||
|
direction: PopoverDirection.bottomWithLeftAligned,
|
||||||
|
constraints: BoxConstraints.loose(const Size(260, 500)),
|
||||||
|
margin: EdgeInsets.zero,
|
||||||
|
child: dateTextWidget,
|
||||||
|
popupBuilder: (BuildContext popoverContent) {
|
||||||
|
return DateCellEditor(
|
||||||
|
cellController: widget.cellControllerBuilder.build()
|
||||||
|
as DateCellController,
|
||||||
|
onDismissed: () => widget.onCellEditing.value = false,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
onClose: () {
|
||||||
|
widget.onCellEditing.value = false;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return dateTextWidget;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -106,7 +114,10 @@ class _DateCellState extends GridCellState<GridDateCell> {
|
|||||||
@override
|
@override
|
||||||
void requestBeginFocus() {
|
void requestBeginFocus() {
|
||||||
_popover.show();
|
_popover.show();
|
||||||
widget.onCellEditing.value = true;
|
|
||||||
|
if (widget.editable) {
|
||||||
|
widget.onCellEditing.value = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -53,8 +53,8 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: "29ee7a3"
|
ref: "9732d30"
|
||||||
resolved-ref: "29ee7a343f4ded8a15bc74ea0df6a458e70cb231"
|
resolved-ref: "9732d30e852ccb832785d6fff3923966452ffcf4"
|
||||||
url: "https://github.com/AppFlowy-IO/appflowy-editor.git"
|
url: "https://github.com/AppFlowy-IO/appflowy-editor.git"
|
||||||
source: git
|
source: git
|
||||||
version: "0.1.12"
|
version: "0.1.12"
|
||||||
|
Reference in New Issue
Block a user