mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
Refactor/update type options (#1265)
* chore: add documentation * chore: update type option data after switching to a new field type * chore: insert yes/no option when switch from checkbox to single/multi select Co-authored-by: nathan <nathan@appflowy.io>
This commit is contained in:
@ -76,7 +76,7 @@ impl GridFieldTest {
|
||||
} => {
|
||||
let field_revs = self.editor.get_field_revs(None).await.unwrap();
|
||||
let field_rev = field_revs[field_index].as_ref();
|
||||
let type_option_data = field_rev.get_type_option_str(field_rev.ty.clone()).unwrap();
|
||||
let type_option_data = field_rev.get_type_option_str(field_rev.ty).unwrap();
|
||||
assert_eq!(type_option_data, expected_type_option_data);
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ use crate::grid::field_test::util::*;
|
||||
use flowy_grid::entities::FieldChangesetParams;
|
||||
use flowy_grid::services::field::selection_type_option::SelectOptionPB;
|
||||
use flowy_grid::services::field::SingleSelectTypeOptionPB;
|
||||
use flowy_grid_data_model::revision::TypeOptionDataFormat;
|
||||
use flowy_grid_data_model::revision::TypeOptionDataSerializer;
|
||||
|
||||
#[tokio::test]
|
||||
async fn grid_create_field() {
|
||||
@ -15,7 +15,7 @@ async fn grid_create_field() {
|
||||
CreateField { params },
|
||||
AssertFieldTypeOptionEqual {
|
||||
field_index: test.field_count(),
|
||||
expected_type_option_data: field_rev.get_type_option_str(field_rev.ty.clone()).unwrap(),
|
||||
expected_type_option_data: field_rev.get_type_option_str(field_rev.ty).unwrap(),
|
||||
},
|
||||
];
|
||||
test.run_scripts(scripts).await;
|
||||
@ -25,7 +25,7 @@ async fn grid_create_field() {
|
||||
CreateField { params },
|
||||
AssertFieldTypeOptionEqual {
|
||||
field_index: test.field_count(),
|
||||
expected_type_option_data: field_rev.get_type_option_str(field_rev.ty.clone()).unwrap(),
|
||||
expected_type_option_data: field_rev.get_type_option_str(field_rev.ty).unwrap(),
|
||||
},
|
||||
];
|
||||
test.run_scripts(scripts).await;
|
||||
@ -63,7 +63,7 @@ async fn grid_update_field_with_empty_change() {
|
||||
UpdateField { changeset },
|
||||
AssertFieldTypeOptionEqual {
|
||||
field_index: create_field_index,
|
||||
expected_type_option_data: field_rev.get_type_option_str(field_rev.ty.clone()).unwrap(),
|
||||
expected_type_option_data: field_rev.get_type_option_str(field_rev.ty).unwrap(),
|
||||
},
|
||||
];
|
||||
test.run_scripts(scripts).await;
|
||||
@ -100,9 +100,7 @@ async fn grid_update_field() {
|
||||
UpdateField { changeset },
|
||||
AssertFieldTypeOptionEqual {
|
||||
field_index: create_field_index,
|
||||
expected_type_option_data: expected_field_rev
|
||||
.get_type_option_str(expected_field_rev.ty.clone())
|
||||
.unwrap(),
|
||||
expected_type_option_data: expected_field_rev.get_type_option_str(expected_field_rev.ty).unwrap(),
|
||||
},
|
||||
];
|
||||
test.run_scripts(scripts).await;
|
||||
|
@ -18,7 +18,7 @@ pub fn create_text_field(grid_id: &str) -> (CreateFieldParams, FieldRevision) {
|
||||
.to_vec();
|
||||
|
||||
let type_option_builder = type_option_builder_from_bytes(type_option_data.clone(), &field_rev.ty.into());
|
||||
field_rev.insert_type_option(type_option_builder.data_format());
|
||||
field_rev.insert_type_option(type_option_builder.serializer());
|
||||
|
||||
let params = CreateFieldParams {
|
||||
grid_id: grid_id.to_owned(),
|
||||
@ -42,7 +42,7 @@ pub fn create_single_select_field(grid_id: &str) -> (CreateFieldParams, FieldRev
|
||||
.to_vec();
|
||||
|
||||
let type_option_builder = type_option_builder_from_bytes(type_option_data.clone(), &field_rev.ty.into());
|
||||
field_rev.insert_type_option(type_option_builder.data_format());
|
||||
field_rev.insert_type_option(type_option_builder.serializer());
|
||||
|
||||
let params = CreateFieldParams {
|
||||
grid_id: grid_id.to_owned(),
|
||||
|
Reference in New Issue
Block a user