From aead4dd0689485d08d32bb72fbd353491600baa3 Mon Sep 17 00:00:00 2001 From: He Linming Date: Mon, 17 Oct 2022 13:10:44 +0800 Subject: [PATCH] feat: transform checkbox to select value (#1274) Co-authored-by: Nathan.fooo <86001920+appflowy@users.noreply.github.com> --- .../selection_type_option/select_type_option.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/frontend/rust-lib/flowy-grid/src/services/field/type_options/selection_type_option/select_type_option.rs b/frontend/rust-lib/flowy-grid/src/services/field/type_options/selection_type_option/select_type_option.rs index a99b1e48b0..1fc668e11d 100644 --- a/frontend/rust-lib/flowy-grid/src/services/field/type_options/selection_type_option/select_type_option.rs +++ b/frontend/rust-lib/flowy-grid/src/services/field/type_options/selection_type_option/select_type_option.rs @@ -150,6 +150,21 @@ pub trait SelectTypeOptionSharedAction: TypeOptionDataSerializer + Send + Sync { } FieldType::Checkbox => { // transform the cell data to the option id + let mut transformed_ids = Vec::new(); + let options = self.options(); + cell_data.0.iter().for_each(|ids| { + ids.0.iter().for_each(|name| { + let id = options + .iter() + .find(|option| option.name == name.clone()) + .unwrap() + .id + .clone(); + transformed_ids.push(id); + }) + }); + + return CellBytes::from(self.get_selected_options(CellData(Some(SelectOptionIds(transformed_ids))))); } _ => { return Ok(CellBytes::default());