|
@@ -2,7 +2,8 @@ use crate::entities::{CellChangesetPB, FieldType, GridCellIdPB, GridCellIdParams
|
|
use crate::services::cell::{
|
|
use crate::services::cell::{
|
|
CellBytes, CellBytesParser, CellData, CellDataIsEmpty, CellDisplayable, FromCellChangeset, FromCellString,
|
|
CellBytes, CellBytesParser, CellData, CellDataIsEmpty, CellDisplayable, FromCellChangeset, FromCellString,
|
|
};
|
|
};
|
|
-use crate::services::field::{MultiSelectTypeOptionPB, SingleSelectTypeOptionPB, CHECK, UNCHECK};
|
|
|
|
|
|
+use crate::services::field::selection_type_option::type_option_transform::SelectOptionTypeOptionTransformer;
|
|
|
|
+use crate::services::field::{MultiSelectTypeOptionPB, SingleSelectTypeOptionPB};
|
|
use bytes::Bytes;
|
|
use bytes::Bytes;
|
|
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
|
|
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
|
|
use flowy_error::{internal_error, ErrorCode, FlowyResult};
|
|
use flowy_error::{internal_error, ErrorCode, FlowyResult};
|
|
@@ -119,25 +120,6 @@ pub trait SelectTypeOptionSharedAction: TypeOptionDataSerializer + Send + Sync {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- fn transform_type_option(&mut self, field_type: &FieldType, _type_option_data: String) {
|
|
|
|
- match field_type {
|
|
|
|
- FieldType::Checkbox => {
|
|
|
|
- //add Yes and No options if it does not exist.
|
|
|
|
- if !self.options().iter().any(|option| option.name == CHECK) {
|
|
|
|
- let check_option = SelectOptionPB::with_color(CHECK, SelectOptionColorPB::Green);
|
|
|
|
- self.mut_options().push(check_option);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if !self.options().iter().any(|option| option.name == UNCHECK) {
|
|
|
|
- let uncheck_option = SelectOptionPB::with_color(UNCHECK, SelectOptionColorPB::Yellow);
|
|
|
|
- self.mut_options().push(uncheck_option);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- FieldType::MultiSelect => {}
|
|
|
|
- _ => {}
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
fn transform_cell_data(
|
|
fn transform_cell_data(
|
|
&self,
|
|
&self,
|
|
cell_data: CellData<SelectOptionIds>,
|
|
cell_data: CellData<SelectOptionIds>,
|
|
@@ -189,7 +171,12 @@ where
|
|
decoded_field_type: &FieldType,
|
|
decoded_field_type: &FieldType,
|
|
field_rev: &FieldRevision,
|
|
field_rev: &FieldRevision,
|
|
) -> FlowyResult<CellBytes> {
|
|
) -> FlowyResult<CellBytes> {
|
|
- self.transform_cell_data(cell_data, decoded_field_type, field_rev)
|
|
|
|
|
|
+ SelectOptionTypeOptionTransformer::transform_type_option_cell_data(
|
|
|
|
+ self,
|
|
|
|
+ cell_data,
|
|
|
|
+ decoded_field_type,
|
|
|
|
+ field_rev,
|
|
|
|
+ )
|
|
}
|
|
}
|
|
|
|
|
|
fn displayed_cell_string(
|
|
fn displayed_cell_string(
|