mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-04-24 22:57:12 -04:00
fix: FieldEditor not refresh its type-option data after switching to a new field (#1285)
Co-authored-by: nathan <nathan@appflowy.io>
This commit is contained in:
parent
63111927cc
commit
eb970a6b7a
4 changed files with 29 additions and 18 deletions
|
@ -80,7 +80,12 @@ class TypeOptionDataController {
|
||||||
Future<void> switchToField(FieldType newFieldType) {
|
Future<void> switchToField(FieldType newFieldType) {
|
||||||
return loader.switchToField(field.id, newFieldType).then((result) {
|
return loader.switchToField(field.id, newFieldType).then((result) {
|
||||||
return result.fold(
|
return result.fold(
|
||||||
(_) {},
|
(_) {
|
||||||
|
// Should load the type-option data after switching to a new field.
|
||||||
|
// After loading the type-option data, the editor widget that uses
|
||||||
|
// the type-option data will be rebuild.
|
||||||
|
loadTypeOptionData();
|
||||||
|
},
|
||||||
(err) => Log.error(err),
|
(err) => Log.error(err),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:app_flowy/plugins/grid/application/field/field_editor_bloc.dart';
|
import 'package:app_flowy/plugins/grid/application/field/field_editor_bloc.dart';
|
||||||
import 'package:app_flowy/plugins/grid/application/field/type_option/type_option_context.dart';
|
import 'package:app_flowy/plugins/grid/application/field/type_option/type_option_context.dart';
|
||||||
|
import 'package:app_flowy/plugins/grid/presentation/layout/sizes.dart';
|
||||||
import 'package:appflowy_popover/appflowy_popover.dart';
|
import 'package:appflowy_popover/appflowy_popover.dart';
|
||||||
import 'package:dartz/dartz.dart' show none;
|
import 'package:dartz/dartz.dart' show none;
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
@ -58,6 +59,8 @@ class _FieldEditorState extends State<FieldEditor> {
|
||||||
isGroupField: widget.isGroupField,
|
isGroupField: widget.isGroupField,
|
||||||
loader: widget.typeOptionLoader,
|
loader: widget.typeOptionLoader,
|
||||||
)..add(const FieldEditorEvent.initial()),
|
)..add(const FieldEditorEvent.initial()),
|
||||||
|
child: Padding(
|
||||||
|
padding: GridSize.typeOptionContentInsets,
|
||||||
child: ListView(
|
child: ListView(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
children: [
|
children: [
|
||||||
|
@ -72,6 +75,7 @@ class _FieldEditorState extends State<FieldEditor> {
|
||||||
_FieldTypeOptionCell(popoverMutex: popoverMutex),
|
_FieldTypeOptionCell(popoverMutex: popoverMutex),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,11 +31,13 @@ impl TypeOptionBuilder for RichTextTypeOptionBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// For the moment, the `RichTextTypeOptionPB` is empty. The `data` property is not
|
||||||
|
/// used yet.
|
||||||
#[derive(Debug, Clone, Default, Serialize, Deserialize, ProtoBuf)]
|
#[derive(Debug, Clone, Default, Serialize, Deserialize, ProtoBuf)]
|
||||||
pub struct RichTextTypeOptionPB {
|
pub struct RichTextTypeOptionPB {
|
||||||
#[pb(index = 1)]
|
#[pb(index = 1)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
data: String, //It's not used yet
|
data: String,
|
||||||
}
|
}
|
||||||
impl_type_option!(RichTextTypeOptionPB, FieldType::RichText);
|
impl_type_option!(RichTextTypeOptionPB, FieldType::RichText);
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,8 @@ impl GridRevisionEditor {
|
||||||
///
|
///
|
||||||
/// * `grid_id`: the id of the grid
|
/// * `grid_id`: the id of the grid
|
||||||
/// * `field_id`: the id of the field
|
/// * `field_id`: the id of the field
|
||||||
/// * `type_option_data`: the updated type-option data.
|
/// * `type_option_data`: the updated type-option data. The `type-option` data might be empty
|
||||||
|
/// if there is no type-option config for that field. For example, the `RichTextTypeOptionPB`.
|
||||||
///
|
///
|
||||||
pub async fn update_field_type_option(
|
pub async fn update_field_type_option(
|
||||||
&self,
|
&self,
|
||||||
|
@ -108,7 +109,6 @@ impl GridRevisionEditor {
|
||||||
field_id: &str,
|
field_id: &str,
|
||||||
type_option_data: Vec<u8>,
|
type_option_data: Vec<u8>,
|
||||||
) -> FlowyResult<()> {
|
) -> FlowyResult<()> {
|
||||||
debug_assert!(!type_option_data.is_empty());
|
|
||||||
if type_option_data.is_empty() {
|
if type_option_data.is_empty() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue