Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

feat: switching from text type to checkbox type (#1626)

Kelvin273aaeec7551
diff --git a/frontend/rust-lib/flowy-grid/src/services/field/type_options/checkbox_type_option/checkbox_type_option.rs b/frontend/rust-lib/flowy-grid/src/services/field/type_options/checkbox_type_option/checkbox_type_option.rs
index 9d6732c4ea..a51b231ae5 100644
--- a/frontend/rust-lib/flowy-grid/src/services/field/type_options/checkbox_type_option/checkbox_type_option.rs
+++ b/frontend/rust-lib/flowy-grid/src/services/field/type_options/checkbox_type_option/checkbox_type_option.rs
@@ -49,7 +49,29 @@ impl TypeOption for CheckboxTypeOptionPB {
type CellFilter = CheckboxFilterPB;
}
-impl TypeOptionTransform for CheckboxTypeOptionPB {}
+impl TypeOptionTransform for CheckboxTypeOptionPB {
+ fn transformable(&self) -> bool {
+ true
+ }
+
+ fn transform_type_option(&mut self, _old_type_option_field_type: FieldType, _old_type_option_data: String) {}
+
+ fn transform_type_option_cell_str(
+ &self,
+ cell_str: &str,
+ decoded_field_type: &FieldType,
+ _field_rev: &FieldRevision,
+ ) -> Option<<Self as TypeOption>::CellData> {
+ if decoded_field_type.is_text() {
+ match CheckboxCellData::from_str(&cell_str) {
+ Ok(cell_data) => Some(cell_data),
+ Err(_) => None,
+ }
+ } else {
+ None
+ }
+ }
+}
impl TypeOptionCellData for CheckboxTypeOptionPB {
fn convert_to_protobuf(&self, cell_data: <Self as TypeOption>::CellData) -> <Self as TypeOption>::CellProtobufType {