|
@@ -1,10 +1,12 @@
|
|
use crate::entities::FieldType;
|
|
use crate::entities::FieldType;
|
|
use crate::services::cell::{CellBytes, CellData};
|
|
use crate::services::cell::{CellBytes, CellData};
|
|
use crate::services::field::{
|
|
use crate::services::field::{
|
|
- SelectOptionColorPB, SelectOptionIds, SelectOptionPB, SelectTypeOptionSharedAction, CHECK, UNCHECK,
|
|
|
|
|
|
+ MultiSelectTypeOptionPB, SelectOptionColorPB, SelectOptionIds, SelectOptionPB, SelectTypeOptionSharedAction,
|
|
|
|
+ SingleSelectTypeOptionPB, CHECK, UNCHECK,
|
|
};
|
|
};
|
|
use flowy_error::FlowyResult;
|
|
use flowy_error::FlowyResult;
|
|
use grid_rev_model::FieldRevision;
|
|
use grid_rev_model::FieldRevision;
|
|
|
|
+use serde_json;
|
|
|
|
|
|
/// Handles how to transform the cell data when switching between different field types
|
|
/// Handles how to transform the cell data when switching between different field types
|
|
pub struct SelectOptionTypeOptionTransformer();
|
|
pub struct SelectOptionTypeOptionTransformer();
|
|
@@ -33,7 +35,22 @@ impl SelectOptionTypeOptionTransformer {
|
|
shared.mut_options().push(uncheck_option);
|
|
shared.mut_options().push(uncheck_option);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- FieldType::MultiSelect => {}
|
|
|
|
|
|
+ FieldType::MultiSelect => {
|
|
|
|
+ let option_pb: MultiSelectTypeOptionPB = serde_json::from_str(_type_option_data.as_str()).unwrap();
|
|
|
|
+ option_pb.options.iter().for_each(|new_option| {
|
|
|
|
+ if !shared.options().iter().any(|option| option.name == new_option.name) {
|
|
|
|
+ shared.mut_options().push(new_option.clone());
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ FieldType::SingleSelect => {
|
|
|
|
+ let option_pb: SingleSelectTypeOptionPB = serde_json::from_str(_type_option_data.as_str()).unwrap();
|
|
|
|
+ option_pb.options.iter().for_each(|new_option| {
|
|
|
|
+ if !shared.options().iter().any(|option| option.name == new_option.name) {
|
|
|
|
+ shared.mut_options().push(new_option.clone());
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
_ => {}
|
|
_ => {}
|
|
}
|
|
}
|
|
}
|
|
}
|