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

This commit is contained in:
Kelvin 2023-01-02 14:47:21 +08:00 committed by GitHub
parent 17def1ffab
commit 273aaeec75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 {