refactor: fetch all select options from field type option instead of cell (#5122)

* refactor: fetch all options from type option

* chore: rustfmt

* ci: fix rust ci

* chore: fix clippy
This commit is contained in:
Richard Shiue
2024-04-13 01:08:47 +08:00
committed by GitHub
parent 0ebcca63bb
commit 891fd16a0c
10 changed files with 74 additions and 73 deletions

View File

@ -103,16 +103,10 @@ impl From<SelectOptionColorPB> for SelectOptionColor {
}
}
/// [SelectOptionCellDataPB] contains a list of user's selected options and a list of all the options
/// that the cell can use.
/// [SelectOptionCellDataPB] contains a list of user's selected options
#[derive(Clone, Debug, Default, ProtoBuf)]
pub struct SelectOptionCellDataPB {
/// The available options that the cell can use.
#[pb(index = 1)]
pub options: Vec<SelectOptionPB>,
/// The selected options for the cell.
#[pb(index = 2)]
pub select_options: Vec<SelectOptionPB>,
}

View File

@ -47,18 +47,12 @@ pub enum SelectOptionColor {
#[derive(Debug)]
pub struct SelectOptionCellData {
pub options: Vec<SelectOption>,
pub select_options: Vec<SelectOption>,
}
impl From<SelectOptionCellData> for SelectOptionCellDataPB {
fn from(data: SelectOptionCellData) -> Self {
SelectOptionCellDataPB {
options: data
.options
.into_iter()
.map(|option| option.into())
.collect(),
select_options: data
.select_options
.into_iter()

View File

@ -58,10 +58,7 @@ pub trait SelectTypeOptionSharedAction: Send + Sync {
select_options.truncate(number_of_max_options);
},
}
SelectOptionCellData {
options: self.options().clone(),
select_options,
}
SelectOptionCellData { select_options }
}
fn to_type_option_data(&self) -> TypeOptionData;