mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: refactor multi-select type option and add GroupPB
This commit is contained in:
1
frontend/rust-lib/Cargo.lock
generated
1
frontend/rust-lib/Cargo.lock
generated
@ -981,6 +981,7 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_repr",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -11,33 +11,33 @@ use std::convert::TryInto;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Eq, PartialEq, ProtoBuf, Debug, Default, Clone)]
|
||||
pub struct GridFilter {
|
||||
pub struct GridFilterConfiguration {
|
||||
#[pb(index = 1)]
|
||||
pub id: String,
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, ProtoBuf, Debug, Default, Clone)]
|
||||
pub struct RepeatedGridFilterPB {
|
||||
pub struct RepeatedGridConfigurationFilterPB {
|
||||
#[pb(index = 1)]
|
||||
pub items: Vec<GridFilter>,
|
||||
pub items: Vec<GridFilterConfiguration>,
|
||||
}
|
||||
|
||||
impl std::convert::From<&GridFilterRevision> for GridFilter {
|
||||
impl std::convert::From<&GridFilterRevision> for GridFilterConfiguration {
|
||||
fn from(rev: &GridFilterRevision) -> Self {
|
||||
Self { id: rev.id.clone() }
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<Vec<Arc<GridFilterRevision>>> for RepeatedGridFilterPB {
|
||||
impl std::convert::From<Vec<Arc<GridFilterRevision>>> for RepeatedGridConfigurationFilterPB {
|
||||
fn from(revs: Vec<Arc<GridFilterRevision>>) -> Self {
|
||||
RepeatedGridFilterPB {
|
||||
RepeatedGridConfigurationFilterPB {
|
||||
items: revs.into_iter().map(|rev| rev.as_ref().into()).collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<Vec<GridFilter>> for RepeatedGridFilterPB {
|
||||
fn from(items: Vec<GridFilter>) -> Self {
|
||||
impl std::convert::From<Vec<GridFilterConfiguration>> for RepeatedGridConfigurationFilterPB {
|
||||
fn from(items: Vec<GridFilterConfiguration>) -> Self {
|
||||
Self { items }
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::entities::FieldType;
|
||||
use crate::entities::{FieldType, GridRowPB};
|
||||
use flowy_derive::ProtoBuf;
|
||||
use flowy_error::ErrorCode;
|
||||
use flowy_grid_data_model::parser::NotEmptyStr;
|
||||
@ -8,7 +8,7 @@ use std::convert::TryInto;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Eq, PartialEq, ProtoBuf, Debug, Default, Clone)]
|
||||
pub struct GridGroupPB {
|
||||
pub struct GridGroupConfigurationPB {
|
||||
#[pb(index = 1)]
|
||||
pub id: String,
|
||||
|
||||
@ -19,9 +19,9 @@ pub struct GridGroupPB {
|
||||
pub sub_group_field_id: Option<String>,
|
||||
}
|
||||
|
||||
impl std::convert::From<&GridGroupRevision> for GridGroupPB {
|
||||
impl std::convert::From<&GridGroupRevision> for GridGroupConfigurationPB {
|
||||
fn from(rev: &GridGroupRevision) -> Self {
|
||||
GridGroupPB {
|
||||
GridGroupConfigurationPB {
|
||||
id: rev.id.clone(),
|
||||
group_field_id: rev.field_id.clone(),
|
||||
sub_group_field_id: rev.sub_field_id.clone(),
|
||||
@ -29,21 +29,39 @@ impl std::convert::From<&GridGroupRevision> for GridGroupPB {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, ProtoBuf, Debug, Default, Clone)]
|
||||
#[derive(ProtoBuf, Debug, Default, Clone)]
|
||||
pub struct RepeatedGridGroupPB {
|
||||
#[pb(index = 1)]
|
||||
pub items: Vec<GridGroupPB>,
|
||||
groups: Vec<GroupPB>,
|
||||
}
|
||||
|
||||
impl std::convert::From<Vec<GridGroupPB>> for RepeatedGridGroupPB {
|
||||
fn from(items: Vec<GridGroupPB>) -> Self {
|
||||
#[derive(ProtoBuf, Debug, Default, Clone)]
|
||||
pub struct GroupPB {
|
||||
#[pb(index = 1)]
|
||||
pub group_id: String,
|
||||
|
||||
#[pb(index = 2)]
|
||||
pub desc: String,
|
||||
|
||||
#[pb(index = 3)]
|
||||
pub rows: Vec<GridRowPB>,
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, ProtoBuf, Debug, Default, Clone)]
|
||||
pub struct RepeatedGridGroupConfigurationPB {
|
||||
#[pb(index = 1)]
|
||||
pub items: Vec<GridGroupConfigurationPB>,
|
||||
}
|
||||
|
||||
impl std::convert::From<Vec<GridGroupConfigurationPB>> for RepeatedGridGroupConfigurationPB {
|
||||
fn from(items: Vec<GridGroupConfigurationPB>) -> Self {
|
||||
Self { items }
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<Vec<Arc<GridGroupRevision>>> for RepeatedGridGroupPB {
|
||||
impl std::convert::From<Vec<Arc<GridGroupRevision>>> for RepeatedGridGroupConfigurationPB {
|
||||
fn from(revs: Vec<Arc<GridGroupRevision>>) -> Self {
|
||||
RepeatedGridGroupPB {
|
||||
RepeatedGridGroupConfigurationPB {
|
||||
items: revs.iter().map(|rev| rev.as_ref().into()).collect(),
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::entities::{
|
||||
CreateGridFilterPayloadPB, CreateGridGroupPayloadPB, CreateGridSortPayloadPB, DeleteFilterPayloadPB,
|
||||
DeleteGroupPayloadPB, RepeatedGridFilterPB, RepeatedGridGroupPB, RepeatedGridSortPB,
|
||||
DeleteGroupPayloadPB, RepeatedGridConfigurationFilterPB, RepeatedGridGroupConfigurationPB, RepeatedGridSortPB,
|
||||
};
|
||||
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
|
||||
use flowy_error::ErrorCode;
|
||||
@ -22,10 +22,10 @@ pub struct GridSettingPB {
|
||||
pub current_layout_type: GridLayoutType,
|
||||
|
||||
#[pb(index = 3)]
|
||||
pub filters_by_field_id: HashMap<String, RepeatedGridFilterPB>,
|
||||
pub filter_configuration_by_field_id: HashMap<String, RepeatedGridConfigurationFilterPB>,
|
||||
|
||||
#[pb(index = 4)]
|
||||
pub groups_by_field_id: HashMap<String, RepeatedGridGroupPB>,
|
||||
pub group_configuration_by_field_id: HashMap<String, RepeatedGridGroupConfigurationPB>,
|
||||
|
||||
#[pb(index = 5)]
|
||||
pub sorts_by_field_id: HashMap<String, RepeatedGridSortPB>,
|
||||
|
@ -405,3 +405,14 @@ pub(crate) async fn update_date_cell_handler(
|
||||
let _ = editor.update_cell(params.into()).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "trace", skip_all, err)]
|
||||
pub(crate) async fn get_group_handler(
|
||||
data: Data<GridIdPB>,
|
||||
manager: AppData<Arc<GridManager>>,
|
||||
) -> DataResult<RepeatedGridGroupPB, FlowyError> {
|
||||
let params: GridIdPB = data.into_inner();
|
||||
let editor = manager.get_grid_editor(¶ms.value)?;
|
||||
let group = editor.get_group().await?;
|
||||
data_result(group)
|
||||
}
|
||||
|
@ -37,7 +37,9 @@ pub fn create(grid_manager: Arc<GridManager>) -> Module {
|
||||
.event(GridEvent::GetSelectOptionCellData, get_select_option_handler)
|
||||
.event(GridEvent::UpdateSelectOptionCell, update_select_option_cell_handler)
|
||||
// Date
|
||||
.event(GridEvent::UpdateDateCell, update_date_cell_handler);
|
||||
.event(GridEvent::UpdateDateCell, update_date_cell_handler)
|
||||
// Group
|
||||
.event(GridEvent::GetGroup, update_date_cell_handler);
|
||||
|
||||
module
|
||||
}
|
||||
@ -204,4 +206,7 @@ pub enum GridEvent {
|
||||
/// will be used by the `update_cell` function.
|
||||
#[event(input = "DateChangesetPayloadPB")]
|
||||
UpdateDateCell = 80,
|
||||
|
||||
#[event(input = "GridIdPB", output = "RepeatedGridGroupPB")]
|
||||
GetGroup = 100,
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ pub fn apply_cell_data_changeset<C: ToString, T: AsRef<FieldRevision>>(
|
||||
FieldType::SingleSelect => {
|
||||
SingleSelectTypeOptionPB::from(field_rev).apply_changeset(changeset.into(), cell_rev)
|
||||
}
|
||||
FieldType::MultiSelect => MultiSelectTypeOption::from(field_rev).apply_changeset(changeset.into(), cell_rev),
|
||||
FieldType::MultiSelect => MultiSelectTypeOptionPB::from(field_rev).apply_changeset(changeset.into(), cell_rev),
|
||||
FieldType::Checkbox => CheckboxTypeOption::from(field_rev).apply_changeset(changeset.into(), cell_rev),
|
||||
FieldType::URL => URLTypeOption::from(field_rev).apply_changeset(changeset.into(), cell_rev),
|
||||
}?;
|
||||
@ -109,7 +109,7 @@ pub fn try_decode_cell_data(
|
||||
.get_type_option_entry::<SingleSelectTypeOptionPB>(field_type)?
|
||||
.decode_cell_data(cell_data.into(), s_field_type, field_rev),
|
||||
FieldType::MultiSelect => field_rev
|
||||
.get_type_option_entry::<MultiSelectTypeOption>(field_type)?
|
||||
.get_type_option_entry::<MultiSelectTypeOptionPB>(field_type)?
|
||||
.decode_cell_data(cell_data.into(), s_field_type, field_rev),
|
||||
FieldType::Checkbox => field_rev
|
||||
.get_type_option_entry::<CheckboxTypeOption>(field_type)?
|
||||
|
@ -94,7 +94,7 @@ pub fn default_type_option_builder_from_type(field_type: &FieldType) -> Box<dyn
|
||||
FieldType::Number => NumberTypeOption::default().into(),
|
||||
FieldType::DateTime => DateTypeOption::default().into(),
|
||||
FieldType::SingleSelect => SingleSelectTypeOptionPB::default().into(),
|
||||
FieldType::MultiSelect => MultiSelectTypeOption::default().into(),
|
||||
FieldType::MultiSelect => MultiSelectTypeOptionPB::default().into(),
|
||||
FieldType::Checkbox => CheckboxTypeOption::default().into(),
|
||||
FieldType::URL => URLTypeOption::default().into(),
|
||||
};
|
||||
|
@ -14,16 +14,16 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
// Multiple select
|
||||
#[derive(Clone, Debug, Default, Serialize, Deserialize, ProtoBuf)]
|
||||
pub struct MultiSelectTypeOption {
|
||||
pub struct MultiSelectTypeOptionPB {
|
||||
#[pb(index = 1)]
|
||||
pub options: Vec<SelectOptionPB>,
|
||||
|
||||
#[pb(index = 2)]
|
||||
pub disable_color: bool,
|
||||
}
|
||||
impl_type_option!(MultiSelectTypeOption, FieldType::MultiSelect);
|
||||
impl_type_option!(MultiSelectTypeOptionPB, FieldType::MultiSelect);
|
||||
|
||||
impl SelectOptionOperation for MultiSelectTypeOption {
|
||||
impl SelectOptionOperation for MultiSelectTypeOptionPB {
|
||||
fn selected_select_option(&self, cell_data: CellData<SelectOptionIds>) -> SelectOptionCellDataPB {
|
||||
let select_options = make_selected_select_options(cell_data, &self.options);
|
||||
SelectOptionCellDataPB {
|
||||
@ -41,7 +41,7 @@ impl SelectOptionOperation for MultiSelectTypeOption {
|
||||
}
|
||||
}
|
||||
|
||||
impl CellDataOperation<SelectOptionIds, SelectOptionCellChangeset> for MultiSelectTypeOption {
|
||||
impl CellDataOperation<SelectOptionIds, SelectOptionCellChangeset> for MultiSelectTypeOptionPB {
|
||||
fn decode_cell_data(
|
||||
&self,
|
||||
cell_data: CellData<SelectOptionIds>,
|
||||
@ -93,9 +93,9 @@ impl CellDataOperation<SelectOptionIds, SelectOptionCellChangeset> for MultiSele
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct MultiSelectTypeOptionBuilder(MultiSelectTypeOption);
|
||||
pub struct MultiSelectTypeOptionBuilder(MultiSelectTypeOptionPB);
|
||||
impl_into_box_type_option_builder!(MultiSelectTypeOptionBuilder);
|
||||
impl_builder_from_json_str_and_from_bytes!(MultiSelectTypeOptionBuilder, MultiSelectTypeOption);
|
||||
impl_builder_from_json_str_and_from_bytes!(MultiSelectTypeOptionBuilder, MultiSelectTypeOptionPB);
|
||||
impl MultiSelectTypeOptionBuilder {
|
||||
pub fn option(mut self, opt: SelectOptionPB) -> Self {
|
||||
self.0.options.push(opt);
|
||||
@ -118,7 +118,7 @@ mod tests {
|
||||
use crate::services::cell::CellDataOperation;
|
||||
use crate::services::field::type_options::selection_type_option::*;
|
||||
use crate::services::field::FieldBuilder;
|
||||
use crate::services::field::{MultiSelectTypeOption, MultiSelectTypeOptionBuilder};
|
||||
use crate::services::field::{MultiSelectTypeOptionBuilder, MultiSelectTypeOptionPB};
|
||||
use flowy_grid_data_model::revision::FieldRevision;
|
||||
|
||||
#[test]
|
||||
@ -136,7 +136,7 @@ mod tests {
|
||||
.visibility(true)
|
||||
.build();
|
||||
|
||||
let type_option = MultiSelectTypeOption::from(&field_rev);
|
||||
let type_option = MultiSelectTypeOptionPB::from(&field_rev);
|
||||
|
||||
let option_ids = vec![google_option.id.clone(), facebook_option.id.clone()].join(SELECTION_IDS_SEPARATOR);
|
||||
let data = SelectOptionCellChangeset::from_insert(&option_ids).to_str();
|
||||
@ -170,7 +170,7 @@ mod tests {
|
||||
|
||||
fn assert_multi_select_options(
|
||||
cell_data: String,
|
||||
type_option: &MultiSelectTypeOption,
|
||||
type_option: &MultiSelectTypeOptionPB,
|
||||
field_rev: &FieldRevision,
|
||||
expected: Vec<SelectOptionPB>,
|
||||
) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::entities::{CellChangesetPB, FieldType, GridCellIdPB, GridCellIdParams};
|
||||
use crate::services::cell::{CellBytes, CellBytesParser, CellData, CellDisplayable, FromCellChangeset, FromCellString};
|
||||
use crate::services::field::{MultiSelectTypeOption, SingleSelectTypeOptionPB};
|
||||
use crate::services::field::{MultiSelectTypeOptionPB, SingleSelectTypeOptionPB};
|
||||
use bytes::Bytes;
|
||||
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
|
||||
use flowy_error::{internal_error, ErrorCode, FlowyResult};
|
||||
@ -130,7 +130,7 @@ pub fn select_option_operation(field_rev: &FieldRevision) -> FlowyResult<Box<dyn
|
||||
Ok(Box::new(type_option))
|
||||
}
|
||||
FieldType::MultiSelect => {
|
||||
let type_option = MultiSelectTypeOption::from(field_rev);
|
||||
let type_option = MultiSelectTypeOptionPB::from(field_rev);
|
||||
Ok(Box::new(type_option))
|
||||
}
|
||||
ty => {
|
||||
|
@ -159,7 +159,7 @@ mod tests {
|
||||
.option(google_option.clone())
|
||||
.option(facebook_option.clone());
|
||||
let multi_select_field_rev = FieldBuilder::new(multi_select).build();
|
||||
let multi_type_option = MultiSelectTypeOption::from(&multi_select_field_rev);
|
||||
let multi_type_option = MultiSelectTypeOptionPB::from(&multi_select_field_rev);
|
||||
let cell_data = multi_type_option
|
||||
.apply_changeset(cell_data_changeset.into(), None)
|
||||
.unwrap();
|
||||
|
@ -3,7 +3,7 @@ use crate::entities::{FieldType, GridBlockChangesetPB};
|
||||
use crate::services::block_manager::GridBlockManager;
|
||||
use crate::services::cell::{AnyCellData, CellFilterOperation};
|
||||
use crate::services::field::{
|
||||
CheckboxTypeOption, DateTypeOption, MultiSelectTypeOption, NumberTypeOption, RichTextTypeOption,
|
||||
CheckboxTypeOption, DateTypeOption, MultiSelectTypeOptionPB, NumberTypeOption, RichTextTypeOption,
|
||||
SingleSelectTypeOptionPB, URLTypeOption,
|
||||
};
|
||||
use crate::services::filter::filter_cache::{
|
||||
@ -22,8 +22,6 @@ use std::sync::Arc;
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
pub(crate) struct GridFilterService {
|
||||
#[allow(dead_code)]
|
||||
grid_id: String,
|
||||
scheduler: Arc<dyn GridServiceTaskScheduler>,
|
||||
grid_pad: Arc<RwLock<GridRevisionPad>>,
|
||||
block_manager: Arc<GridBlockManager>,
|
||||
@ -36,12 +34,10 @@ impl GridFilterService {
|
||||
block_manager: Arc<GridBlockManager>,
|
||||
scheduler: S,
|
||||
) -> Self {
|
||||
let grid_id = grid_pad.read().await.grid_id();
|
||||
let scheduler = Arc::new(scheduler);
|
||||
let filter_cache = FilterCache::from_grid_pad(&grid_pad).await;
|
||||
let filter_result_cache = FilterResultCache::new();
|
||||
Self {
|
||||
grid_id,
|
||||
grid_pad,
|
||||
block_manager,
|
||||
scheduler,
|
||||
@ -134,8 +130,9 @@ impl GridFilterService {
|
||||
}
|
||||
|
||||
async fn notify(&self, changesets: Vec<GridBlockChangesetPB>) {
|
||||
let grid_id = self.grid_pad.read().await.grid_id();
|
||||
for changeset in changesets {
|
||||
send_dart_notification(&self.grid_id, GridNotification::DidUpdateGridBlock)
|
||||
send_dart_notification(&grid_id, GridNotification::DidUpdateGridBlock)
|
||||
.payload(changeset)
|
||||
.send();
|
||||
}
|
||||
@ -217,7 +214,7 @@ fn filter_cell(
|
||||
FieldType::MultiSelect => filter_cache.select_option_filter.get(&filter_id).and_then(|filter| {
|
||||
Some(
|
||||
field_rev
|
||||
.get_type_option_entry::<MultiSelectTypeOption>(field_type_rev)?
|
||||
.get_type_option_entry::<MultiSelectTypeOptionPB>(field_type_rev)?
|
||||
.apply_filter(any_cell_data, filter.value())
|
||||
.ok(),
|
||||
)
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use crate::entities::{GridSelectOptionFilter, SelectOptionCondition};
|
||||
use crate::services::cell::{AnyCellData, CellFilterOperation};
|
||||
use crate::services::field::{MultiSelectTypeOption, SingleSelectTypeOptionPB};
|
||||
use crate::services::field::{MultiSelectTypeOptionPB, SingleSelectTypeOptionPB};
|
||||
use crate::services::field::{SelectOptionOperation, SelectedSelectOptions};
|
||||
use flowy_error::FlowyResult;
|
||||
|
||||
@ -39,7 +39,7 @@ impl GridSelectOptionFilter {
|
||||
}
|
||||
}
|
||||
|
||||
impl CellFilterOperation<GridSelectOptionFilter> for MultiSelectTypeOption {
|
||||
impl CellFilterOperation<GridSelectOptionFilter> for MultiSelectTypeOptionPB {
|
||||
fn apply_filter(&self, any_cell_data: AnyCellData, filter: &GridSelectOptionFilter) -> FlowyResult<bool> {
|
||||
if !any_cell_data.is_multi_select() {
|
||||
return Ok(true);
|
||||
|
@ -61,7 +61,8 @@ impl GridRevisionEditor {
|
||||
let block_manager = Arc::new(GridBlockManager::new(grid_id, &user, block_meta_revs, persistence).await?);
|
||||
let filter_service =
|
||||
Arc::new(GridFilterService::new(grid_pad.clone(), block_manager.clone(), task_scheduler.clone()).await);
|
||||
let group_service = Arc::new(GridGroupService::new());
|
||||
let group_service =
|
||||
Arc::new(GridGroupService::new(grid_pad.clone(), block_manager.clone(), task_scheduler.clone()).await);
|
||||
let editor = Arc::new(Self {
|
||||
grid_id: grid_id.to_owned(),
|
||||
user,
|
||||
@ -455,14 +456,14 @@ impl GridRevisionEditor {
|
||||
Ok(grid_setting)
|
||||
}
|
||||
|
||||
pub async fn get_grid_filter(&self, layout_type: &GridLayoutType) -> FlowyResult<Vec<GridFilter>> {
|
||||
pub async fn get_grid_filter(&self, layout_type: &GridLayoutType) -> FlowyResult<Vec<GridFilterConfiguration>> {
|
||||
let read_guard = self.grid_pad.read().await;
|
||||
let layout_rev = layout_type.clone().into();
|
||||
match read_guard.get_filters(Some(&layout_rev), None) {
|
||||
Some(filter_revs) => Ok(filter_revs
|
||||
.iter()
|
||||
.map(|filter_rev| filter_rev.as_ref().into())
|
||||
.collect::<Vec<GridFilter>>()),
|
||||
.collect::<Vec<GridFilterConfiguration>>()),
|
||||
None => Ok(vec![]),
|
||||
}
|
||||
}
|
||||
@ -561,6 +562,10 @@ impl GridRevisionEditor {
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn get_group(&self) -> FlowyResult<RepeatedGridGroupPB> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
async fn modify<F>(&self, f: F) -> FlowyResult<()>
|
||||
where
|
||||
F: for<'a> FnOnce(&'a mut GridRevisionPad) -> FlowyResult<Option<GridChangeset>>,
|
||||
|
@ -1,7 +1,26 @@
|
||||
pub struct GridGroupService {}
|
||||
use crate::services::block_manager::GridBlockManager;
|
||||
use crate::services::grid_editor_task::GridServiceTaskScheduler;
|
||||
use flowy_sync::client_grid::GridRevisionPad;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
pub(crate) struct GridGroupService {
|
||||
scheduler: Arc<dyn GridServiceTaskScheduler>,
|
||||
grid_pad: Arc<RwLock<GridRevisionPad>>,
|
||||
block_manager: Arc<GridBlockManager>,
|
||||
}
|
||||
|
||||
impl GridGroupService {
|
||||
pub fn new() -> Self {
|
||||
Self {}
|
||||
pub(crate) async fn new<S: GridServiceTaskScheduler>(
|
||||
grid_pad: Arc<RwLock<GridRevisionPad>>,
|
||||
block_manager: Arc<GridBlockManager>,
|
||||
scheduler: S,
|
||||
) -> Self {
|
||||
let scheduler = Arc::new(scheduler);
|
||||
Self {
|
||||
scheduler,
|
||||
grid_pad,
|
||||
block_manager,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
use crate::entities::{
|
||||
GridLayoutPB, GridLayoutType, GridSettingPB, RepeatedGridFilterPB, RepeatedGridGroupPB, RepeatedGridSortPB,
|
||||
GridLayoutPB, GridLayoutType, GridSettingPB, RepeatedGridConfigurationFilterPB, RepeatedGridGroupConfigurationPB,
|
||||
RepeatedGridSortPB,
|
||||
};
|
||||
use flowy_grid_data_model::revision::{FieldRevision, GridSettingRevision};
|
||||
use flowy_sync::entities::grid::{CreateGridFilterParams, DeleteFilterParams, GridSettingChangesetParams};
|
||||
@ -43,21 +44,21 @@ impl GridSettingChangesetBuilder {
|
||||
pub fn make_grid_setting(grid_setting_rev: &GridSettingRevision, field_revs: &[Arc<FieldRevision>]) -> GridSettingPB {
|
||||
let current_layout_type: GridLayoutType = grid_setting_rev.layout.clone().into();
|
||||
let filters_by_field_id = grid_setting_rev
|
||||
.get_all_filter(field_revs)
|
||||
.get_all_filters(field_revs)
|
||||
.map(|filters_by_field_id| {
|
||||
filters_by_field_id
|
||||
.into_iter()
|
||||
.map(|(k, v)| (k, v.into()))
|
||||
.collect::<HashMap<String, RepeatedGridFilterPB>>()
|
||||
.collect::<HashMap<String, RepeatedGridConfigurationFilterPB>>()
|
||||
})
|
||||
.unwrap_or_default();
|
||||
let groups_by_field_id = grid_setting_rev
|
||||
.get_all_group()
|
||||
.get_all_groups(field_revs)
|
||||
.map(|groups_by_field_id| {
|
||||
groups_by_field_id
|
||||
.into_iter()
|
||||
.map(|(k, v)| (k, v.into()))
|
||||
.collect::<HashMap<String, RepeatedGridGroupPB>>()
|
||||
.collect::<HashMap<String, RepeatedGridGroupConfigurationPB>>()
|
||||
})
|
||||
.unwrap_or_default();
|
||||
let sorts_by_field_id = grid_setting_rev
|
||||
@ -73,8 +74,8 @@ pub fn make_grid_setting(grid_setting_rev: &GridSettingRevision, field_revs: &[A
|
||||
GridSettingPB {
|
||||
layouts: GridLayoutPB::all(),
|
||||
current_layout_type,
|
||||
filters_by_field_id,
|
||||
groups_by_field_id,
|
||||
filter_configuration_by_field_id: filters_by_field_id,
|
||||
group_configuration_by_field_id: groups_by_field_id,
|
||||
sorts_by_field_id,
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use flowy_grid::entities::FieldType;
|
||||
use std::sync::Arc;
|
||||
|
||||
use flowy_grid::services::field::{
|
||||
DateCellChangesetPB, MultiSelectTypeOption, SelectOptionPB, SingleSelectTypeOptionPB, SELECTION_IDS_SEPARATOR,
|
||||
DateCellChangesetPB, MultiSelectTypeOptionPB, SelectOptionPB, SingleSelectTypeOptionPB, SELECTION_IDS_SEPARATOR,
|
||||
};
|
||||
use flowy_grid::services::row::RowRevisionBuilder;
|
||||
use flowy_grid_data_model::revision::{FieldRevision, RowRevision};
|
||||
@ -87,7 +87,7 @@ impl<'a> GridRowTestBuilder<'a> {
|
||||
F: Fn(Vec<SelectOptionPB>) -> Vec<SelectOptionPB>,
|
||||
{
|
||||
let multi_select_field = self.field_rev_with_type(&FieldType::MultiSelect);
|
||||
let type_option = MultiSelectTypeOption::from(&multi_select_field);
|
||||
let type_option = MultiSelectTypeOptionPB::from(&multi_select_field);
|
||||
let options = f(type_option.options);
|
||||
let ops_ids = options
|
||||
.iter()
|
||||
|
@ -3,7 +3,7 @@ use crate::grid::cell_test::script::GridCellTest;
|
||||
use crate::grid::field_test::util::make_date_cell_string;
|
||||
use flowy_grid::entities::{CellChangesetPB, FieldType};
|
||||
use flowy_grid::services::field::selection_type_option::SelectOptionCellChangeset;
|
||||
use flowy_grid::services::field::{MultiSelectTypeOption, SingleSelectTypeOptionPB};
|
||||
use flowy_grid::services::field::{MultiSelectTypeOptionPB, SingleSelectTypeOptionPB};
|
||||
|
||||
#[tokio::test]
|
||||
async fn grid_cell_update() {
|
||||
@ -28,7 +28,7 @@ async fn grid_cell_update() {
|
||||
SelectOptionCellChangeset::from_insert(&type_option.options.first().unwrap().id).to_str()
|
||||
}
|
||||
FieldType::MultiSelect => {
|
||||
let type_option = MultiSelectTypeOption::from(field_rev);
|
||||
let type_option = MultiSelectTypeOptionPB::from(field_rev);
|
||||
SelectOptionCellChangeset::from_insert(&type_option.options.first().unwrap().id).to_str()
|
||||
}
|
||||
FieldType::Checkbox => "1".to_string(),
|
||||
|
@ -75,7 +75,7 @@ impl GridEditorTest {
|
||||
.row_revs
|
||||
}
|
||||
|
||||
pub async fn grid_filters(&self) -> Vec<GridFilter> {
|
||||
pub async fn grid_filters(&self) -> Vec<GridFilterConfiguration> {
|
||||
let layout_type = GridLayoutType::Table;
|
||||
self.editor.get_grid_filter(&layout_type).await.unwrap()
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use crate::grid::script::EditorScript::*;
|
||||
use crate::grid::script::*;
|
||||
use chrono::NaiveDateTime;
|
||||
use flowy_grid::services::field::{
|
||||
DateCellContentChangeset, DateCellData, MultiSelectTypeOption, SelectOption, SelectOptionCellContentChangeset,
|
||||
DateCellContentChangeset, DateCellData, MultiSelectTypeOptionPB, SelectOption, SelectOptionCellContentChangeset,
|
||||
SingleSelectTypeOption, SELECTION_IDS_SEPARATOR,
|
||||
};
|
||||
use flowy_grid::services::row::{decode_cell_data_from_type_option_cell_data, CreateRowMetaBuilder};
|
||||
@ -250,7 +250,7 @@ async fn grid_row_add_cells_test() {
|
||||
builder.add_select_option_cell(&field.id, option.id.clone()).unwrap();
|
||||
}
|
||||
FieldType::MultiSelect => {
|
||||
let type_option = MultiSelectTypeOption::from(field);
|
||||
let type_option = MultiSelectTypeOptionPB::from(field);
|
||||
let ops_ids = type_option
|
||||
.options
|
||||
.iter()
|
||||
@ -327,7 +327,7 @@ async fn grid_cell_update() {
|
||||
SelectOptionCellContentChangeset::from_insert(&type_option.options.first().unwrap().id).to_str()
|
||||
}
|
||||
FieldType::MultiSelect => {
|
||||
let type_option = MultiSelectTypeOption::from(field_meta);
|
||||
let type_option = MultiSelectTypeOptionPB::from(field_meta);
|
||||
SelectOptionCellContentChangeset::from_insert(&type_option.options.first().unwrap().id).to_str()
|
||||
}
|
||||
FieldType::Checkbox => "1".to_string(),
|
||||
|
Reference in New Issue
Block a user