mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: fix bugs when switch group field
This commit is contained in:
@ -78,7 +78,7 @@ pub struct DeleteFilterParams {
|
||||
}
|
||||
|
||||
#[derive(ProtoBuf, Debug, Default, Clone)]
|
||||
pub struct CreateGridFilterPayloadPB {
|
||||
pub struct InsertFilterPayloadPB {
|
||||
#[pb(index = 1)]
|
||||
pub field_id: String,
|
||||
|
||||
@ -92,7 +92,7 @@ pub struct CreateGridFilterPayloadPB {
|
||||
pub content: Option<String>,
|
||||
}
|
||||
|
||||
impl CreateGridFilterPayloadPB {
|
||||
impl InsertFilterPayloadPB {
|
||||
#[allow(dead_code)]
|
||||
pub fn new<T: Into<i32>>(field_rev: &FieldRevision, condition: T, content: Option<String>) -> Self {
|
||||
Self {
|
||||
@ -104,10 +104,10 @@ impl CreateGridFilterPayloadPB {
|
||||
}
|
||||
}
|
||||
|
||||
impl TryInto<CreateFilterParams> for CreateGridFilterPayloadPB {
|
||||
impl TryInto<InsertFilterParams> for InsertFilterPayloadPB {
|
||||
type Error = ErrorCode;
|
||||
|
||||
fn try_into(self) -> Result<CreateFilterParams, Self::Error> {
|
||||
fn try_into(self) -> Result<InsertFilterParams, Self::Error> {
|
||||
let field_id = NotEmptyStr::parse(self.field_id)
|
||||
.map_err(|_| ErrorCode::FieldIdIsEmpty)?
|
||||
.0;
|
||||
@ -130,7 +130,7 @@ impl TryInto<CreateFilterParams> for CreateGridFilterPayloadPB {
|
||||
}
|
||||
}
|
||||
|
||||
Ok(CreateFilterParams {
|
||||
Ok(InsertFilterParams {
|
||||
field_id,
|
||||
field_type_rev: self.field_type.into(),
|
||||
condition,
|
||||
@ -139,7 +139,7 @@ impl TryInto<CreateFilterParams> for CreateGridFilterPayloadPB {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CreateFilterParams {
|
||||
pub struct InsertFilterParams {
|
||||
pub field_id: String,
|
||||
pub field_type_rev: FieldTypeRevision,
|
||||
pub condition: u8,
|
||||
|
@ -130,7 +130,7 @@ impl std::convert::From<Vec<Arc<GroupConfigurationRevision>>> for RepeatedGridGr
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, ProtoBuf, Debug, Default, Clone)]
|
||||
pub struct CreateGridGroupPayloadPB {
|
||||
pub struct InsertGroupPayloadPB {
|
||||
#[pb(index = 1)]
|
||||
pub field_id: String,
|
||||
|
||||
@ -138,22 +138,22 @@ pub struct CreateGridGroupPayloadPB {
|
||||
pub field_type: FieldType,
|
||||
}
|
||||
|
||||
impl TryInto<CreatGroupParams> for CreateGridGroupPayloadPB {
|
||||
impl TryInto<InsertGroupParams> for InsertGroupPayloadPB {
|
||||
type Error = ErrorCode;
|
||||
|
||||
fn try_into(self) -> Result<CreatGroupParams, Self::Error> {
|
||||
fn try_into(self) -> Result<InsertGroupParams, Self::Error> {
|
||||
let field_id = NotEmptyStr::parse(self.field_id)
|
||||
.map_err(|_| ErrorCode::FieldIdIsEmpty)?
|
||||
.0;
|
||||
|
||||
Ok(CreatGroupParams {
|
||||
Ok(InsertGroupParams {
|
||||
field_id,
|
||||
field_type_rev: self.field_type.into(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CreatGroupParams {
|
||||
pub struct InsertGroupParams {
|
||||
pub field_id: String,
|
||||
pub field_type_rev: FieldTypeRevision,
|
||||
}
|
||||
|
@ -1,13 +1,12 @@
|
||||
use crate::entities::{
|
||||
CreatGroupParams, CreateFilterParams, CreateGridFilterPayloadPB, CreateGridGroupPayloadPB, DeleteFilterParams,
|
||||
DeleteFilterPayloadPB, DeleteGroupParams, DeleteGroupPayloadPB, RepeatedGridFilterConfigurationPB,
|
||||
DeleteFilterParams, DeleteFilterPayloadPB, DeleteGroupParams, DeleteGroupPayloadPB, InsertFilterParams,
|
||||
InsertFilterPayloadPB, InsertGroupParams, InsertGroupPayloadPB, RepeatedGridFilterConfigurationPB,
|
||||
RepeatedGridGroupConfigurationPB,
|
||||
};
|
||||
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
|
||||
use flowy_error::ErrorCode;
|
||||
use flowy_grid_data_model::parser::NotEmptyStr;
|
||||
use flowy_grid_data_model::revision::LayoutRevision;
|
||||
use std::collections::HashMap;
|
||||
use std::convert::TryInto;
|
||||
use strum::IntoEnumIterator;
|
||||
use strum_macros::EnumIter;
|
||||
@ -85,13 +84,13 @@ pub struct GridSettingChangesetPayloadPB {
|
||||
pub layout_type: GridLayout,
|
||||
|
||||
#[pb(index = 3, one_of)]
|
||||
pub insert_filter: Option<CreateGridFilterPayloadPB>,
|
||||
pub insert_filter: Option<InsertFilterPayloadPB>,
|
||||
|
||||
#[pb(index = 4, one_of)]
|
||||
pub delete_filter: Option<DeleteFilterPayloadPB>,
|
||||
|
||||
#[pb(index = 5, one_of)]
|
||||
pub insert_group: Option<CreateGridGroupPayloadPB>,
|
||||
pub insert_group: Option<InsertGroupPayloadPB>,
|
||||
|
||||
#[pb(index = 6, one_of)]
|
||||
pub delete_group: Option<DeleteGroupPayloadPB>,
|
||||
@ -102,7 +101,7 @@ impl TryInto<GridSettingChangesetParams> for GridSettingChangesetPayloadPB {
|
||||
|
||||
fn try_into(self) -> Result<GridSettingChangesetParams, Self::Error> {
|
||||
let view_id = NotEmptyStr::parse(self.grid_id)
|
||||
.map_err(|_| ErrorCode::FieldIdIsEmpty)?
|
||||
.map_err(|_| ErrorCode::ViewIdInvalid)?
|
||||
.0;
|
||||
|
||||
let insert_filter = match self.insert_filter {
|
||||
@ -139,9 +138,9 @@ impl TryInto<GridSettingChangesetParams> for GridSettingChangesetPayloadPB {
|
||||
pub struct GridSettingChangesetParams {
|
||||
pub grid_id: String,
|
||||
pub layout_type: LayoutRevision,
|
||||
pub insert_filter: Option<CreateFilterParams>,
|
||||
pub insert_filter: Option<InsertFilterParams>,
|
||||
pub delete_filter: Option<DeleteFilterParams>,
|
||||
pub insert_group: Option<CreatGroupParams>,
|
||||
pub insert_group: Option<InsertGroupParams>,
|
||||
pub delete_group: Option<DeleteGroupParams>,
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,32 @@ pub(crate) async fn get_grid_setting_handler(
|
||||
data_result(grid_setting)
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "trace", skip(data, manager), err)]
|
||||
pub(crate) async fn update_grid_setting_handler(
|
||||
data: Data<GridSettingChangesetPayloadPB>,
|
||||
manager: AppData<Arc<GridManager>>,
|
||||
) -> Result<(), FlowyError> {
|
||||
let params: GridSettingChangesetParams = data.into_inner().try_into()?;
|
||||
|
||||
let editor = manager.get_grid_editor(¶ms.grid_id)?;
|
||||
if let Some(insert_params) = params.insert_group {
|
||||
let _ = editor.create_group(insert_params).await?;
|
||||
}
|
||||
|
||||
if let Some(delete_params) = params.delete_group {
|
||||
let _ = editor.delete_group(delete_params).await?;
|
||||
}
|
||||
|
||||
if let Some(create_filter) = params.insert_filter {
|
||||
let _ = editor.create_filter(create_filter).await?;
|
||||
}
|
||||
|
||||
if let Some(delete_filter) = params.delete_filter {
|
||||
let _ = editor.delete_filter(delete_filter).await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(data, manager), err)]
|
||||
pub(crate) async fn get_grid_blocks_handler(
|
||||
data: Data<QueryBlocksPayloadPB>,
|
||||
|
@ -11,7 +11,7 @@ pub fn create(grid_manager: Arc<GridManager>) -> Module {
|
||||
.event(GridEvent::GetGrid, get_grid_handler)
|
||||
.event(GridEvent::GetGridBlocks, get_grid_blocks_handler)
|
||||
.event(GridEvent::GetGridSetting, get_grid_setting_handler)
|
||||
// .event(GridEvent::UpdateGridSetting, update_grid_setting_handler)
|
||||
.event(GridEvent::UpdateGridSetting, update_grid_setting_handler)
|
||||
// Field
|
||||
.event(GridEvent::GetFields, get_fields_handler)
|
||||
.event(GridEvent::UpdateField, update_field_handler)
|
||||
@ -75,8 +75,8 @@ pub enum GridEvent {
|
||||
|
||||
/// [UpdateGridSetting] event is used to update the grid's settings.
|
||||
///
|
||||
/// The event handler accepts [GridIdPB] and return errors if failed to modify the grid's settings.
|
||||
#[event(input = "GridIdPB", input = "GridSettingChangesetPayloadPB")]
|
||||
/// The event handler accepts [GridSettingChangesetPayloadPB] and return errors if failed to modify the grid's settings.
|
||||
#[event(input = "GridSettingChangesetPayloadPB")]
|
||||
UpdateGridSetting = 3,
|
||||
|
||||
/// [GetFields] event is used to get the grid's settings.
|
||||
@ -225,4 +225,7 @@ pub enum GridEvent {
|
||||
|
||||
#[event(input = "MoveGroupRowPayloadPB")]
|
||||
MoveGroupRow = 112,
|
||||
|
||||
#[event(input = "MoveGroupRowPayloadPB")]
|
||||
GroupByField = 113,
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ impl GridRevisionEditor {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn group_field(&self, field_id: &str) -> FlowyResult<()> {
|
||||
pub async fn group_by_field(&self, field_id: &str) -> FlowyResult<()> {
|
||||
let _ = self.view_manager.group_by_field(field_id).await?;
|
||||
Ok(())
|
||||
}
|
||||
@ -536,8 +536,16 @@ impl GridRevisionEditor {
|
||||
self.view_manager.get_filters().await
|
||||
}
|
||||
|
||||
pub async fn update_filter(&self, params: CreateFilterParams) -> FlowyResult<()> {
|
||||
let _ = self.view_manager.update_filter(params).await?;
|
||||
pub async fn create_group(&self, params: InsertGroupParams) -> FlowyResult<()> {
|
||||
self.view_manager.insert_or_update_group(params).await
|
||||
}
|
||||
|
||||
pub async fn delete_group(&self, params: DeleteGroupParams) -> FlowyResult<()> {
|
||||
self.view_manager.delete_group(params).await
|
||||
}
|
||||
|
||||
pub async fn create_filter(&self, params: InsertFilterParams) -> FlowyResult<()> {
|
||||
let _ = self.view_manager.insert_or_update_filter(params).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,15 @@
|
||||
use crate::dart_notification::{send_dart_notification, GridNotification};
|
||||
use crate::entities::{
|
||||
CreateFilterParams, CreateRowParams, DeleteFilterParams, GridFilterConfigurationPB, GridGroupConfigurationPB,
|
||||
GridLayout, GridLayoutPB, GridSettingPB, GroupChangesetPB, GroupPB, GroupViewChangesetPB, InsertedGroupPB,
|
||||
InsertedRowPB, MoveGroupParams, RepeatedGridFilterConfigurationPB, RepeatedGridGroupConfigurationPB, RowPB,
|
||||
CreateRowParams, DeleteFilterParams, DeleteGroupParams, GridFilterConfigurationPB, GridGroupConfigurationPB,
|
||||
GridLayout, GridLayoutPB, GridSettingPB, GroupChangesetPB, GroupPB, GroupViewChangesetPB, InsertFilterParams,
|
||||
InsertGroupParams, InsertedGroupPB, InsertedRowPB, MoveGroupParams, RepeatedGridFilterConfigurationPB,
|
||||
RepeatedGridGroupConfigurationPB, RowPB,
|
||||
};
|
||||
use crate::services::grid_editor_task::GridServiceTaskScheduler;
|
||||
use crate::services::grid_view_manager::{GridViewFieldDelegate, GridViewRowDelegate};
|
||||
use crate::services::group::{
|
||||
find_group_field, make_group_controller, GroupConfigurationReader, GroupConfigurationWriter, GroupController,
|
||||
MoveGroupRowContext,
|
||||
default_group_configuration, find_group_field, make_group_controller, GroupConfigurationReader,
|
||||
GroupConfigurationWriter, GroupController, MoveGroupRowContext,
|
||||
};
|
||||
use flowy_error::{FlowyError, FlowyResult};
|
||||
use flowy_grid_data_model::revision::{
|
||||
@ -19,7 +20,6 @@ use flowy_revision::{RevisionCloudService, RevisionManager, RevisionObjectBuilde
|
||||
use flowy_sync::client_grid::{GridViewRevisionChangeset, GridViewRevisionPad};
|
||||
use flowy_sync::entities::revision::Revision;
|
||||
use lib_infra::future::{wrap_future, AFFuture, FutureResult};
|
||||
use std::collections::HashMap;
|
||||
use std::future::Future;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::RwLock;
|
||||
@ -210,15 +210,40 @@ impl GridViewRevisionEditor {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn insert_filter(&self, insert_filter: CreateFilterParams) -> FlowyResult<()> {
|
||||
pub(crate) async fn insert_group(&self, params: InsertGroupParams) -> FlowyResult<()> {
|
||||
if let Some(field_rev) = self.field_delegate.get_field_rev(¶ms.field_id).await {
|
||||
let _ = self
|
||||
.modify(|pad| {
|
||||
let configuration = default_group_configuration(&field_rev);
|
||||
let changeset = pad.insert_group(¶ms.field_id, ¶ms.field_type_rev, configuration)?;
|
||||
Ok(changeset)
|
||||
})
|
||||
.await?;
|
||||
}
|
||||
if self.group_controller.read().await.field_id() != params.field_id {
|
||||
let _ = self.group_by_field(¶ms.field_id).await?;
|
||||
self.notify_did_update_setting().await;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn delete_group(&self, params: DeleteGroupParams) -> FlowyResult<()> {
|
||||
self.modify(|pad| {
|
||||
let changeset = pad.delete_filter(¶ms.field_id, ¶ms.field_type_rev, ¶ms.group_id)?;
|
||||
Ok(changeset)
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
pub(crate) async fn insert_filter(&self, params: InsertFilterParams) -> FlowyResult<()> {
|
||||
self.modify(|pad| {
|
||||
let filter_rev = FilterConfigurationRevision {
|
||||
id: gen_grid_filter_id(),
|
||||
field_id: insert_filter.field_id.clone(),
|
||||
condition: insert_filter.condition,
|
||||
content: insert_filter.content,
|
||||
field_id: params.field_id.clone(),
|
||||
condition: params.condition,
|
||||
content: params.content,
|
||||
};
|
||||
let changeset = pad.insert_filter(&insert_filter.field_id, &insert_filter.field_type_rev, filter_rev)?;
|
||||
let changeset = pad.insert_filter(¶ms.field_id, ¶ms.field_type_rev, filter_rev)?;
|
||||
Ok(changeset)
|
||||
})
|
||||
.await
|
||||
@ -279,6 +304,13 @@ impl GridViewRevisionEditor {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn notify_did_update_setting(&self) {
|
||||
let setting = self.get_setting().await;
|
||||
send_dart_notification(&self.view_id, GridNotification::DidUpdateGridSetting)
|
||||
.payload(setting)
|
||||
.send();
|
||||
}
|
||||
|
||||
pub async fn notify_did_update_group(&self, changeset: GroupChangesetPB) {
|
||||
send_dart_notification(&changeset.group_id, GridNotification::DidUpdateGroup)
|
||||
.payload(changeset)
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::entities::{
|
||||
CreateFilterParams, CreateRowParams, DeleteFilterParams, GridFilterConfigurationPB, GridSettingPB, MoveGroupParams,
|
||||
RepeatedGridGroupPB, RowPB,
|
||||
CreateRowParams, DeleteFilterParams, DeleteGroupParams, GridFilterConfigurationPB, GridSettingPB,
|
||||
InsertFilterParams, InsertGroupParams, MoveGroupParams, RepeatedGridGroupPB, RowPB,
|
||||
};
|
||||
use crate::manager::GridUser;
|
||||
use crate::services::grid_editor_task::GridServiceTaskScheduler;
|
||||
@ -110,14 +110,14 @@ impl GridViewManager {
|
||||
Ok(view_editor.get_filters().await)
|
||||
}
|
||||
|
||||
pub(crate) async fn update_filter(&self, insert_filter: CreateFilterParams) -> FlowyResult<()> {
|
||||
pub(crate) async fn insert_or_update_filter(&self, params: InsertFilterParams) -> FlowyResult<()> {
|
||||
let view_editor = self.get_default_view_editor().await?;
|
||||
view_editor.insert_filter(insert_filter).await
|
||||
view_editor.insert_filter(params).await
|
||||
}
|
||||
|
||||
pub(crate) async fn delete_filter(&self, delete_filter: DeleteFilterParams) -> FlowyResult<()> {
|
||||
pub(crate) async fn delete_filter(&self, params: DeleteFilterParams) -> FlowyResult<()> {
|
||||
let view_editor = self.get_default_view_editor().await?;
|
||||
view_editor.delete_filter(delete_filter).await
|
||||
view_editor.delete_filter(params).await
|
||||
}
|
||||
|
||||
pub(crate) async fn load_groups(&self) -> FlowyResult<RepeatedGridGroupPB> {
|
||||
@ -126,6 +126,16 @@ impl GridViewManager {
|
||||
Ok(RepeatedGridGroupPB { items: groups })
|
||||
}
|
||||
|
||||
pub(crate) async fn insert_or_update_group(&self, params: InsertGroupParams) -> FlowyResult<()> {
|
||||
let view_editor = self.get_default_view_editor().await?;
|
||||
view_editor.insert_group(params).await
|
||||
}
|
||||
|
||||
pub(crate) async fn delete_group(&self, params: DeleteGroupParams) -> FlowyResult<()> {
|
||||
let view_editor = self.get_default_view_editor().await?;
|
||||
view_editor.delete_group(params).await
|
||||
}
|
||||
|
||||
pub(crate) async fn move_group(&self, params: MoveGroupParams) -> FlowyResult<()> {
|
||||
let view_editor = self.get_default_view_editor().await?;
|
||||
let _ = view_editor.move_group(params).await?;
|
||||
|
@ -133,6 +133,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(self, generated_groups), err)]
|
||||
pub(crate) fn init_groups(
|
||||
&mut self,
|
||||
generated_groups: Vec<GeneratedGroup>,
|
||||
@ -316,7 +317,8 @@ where
|
||||
fn merge_groups(old_groups: &[GroupRevision], new_groups: Vec<GroupRevision>) -> MergeGroupResult {
|
||||
let mut merge_result = MergeGroupResult::new();
|
||||
if old_groups.is_empty() {
|
||||
merge_result.all_group_revs = new_groups;
|
||||
merge_result.all_group_revs = new_groups.clone();
|
||||
merge_result.new_group_revs = new_groups;
|
||||
return merge_result;
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ where
|
||||
let field_type_rev = field_rev.ty;
|
||||
let type_option = field_rev.get_type_option::<T>(field_type_rev);
|
||||
let groups = G::generate_groups(&field_rev.id, &configuration, &type_option);
|
||||
let _ = configuration.init_groups(groups, false)?;
|
||||
let _ = configuration.init_groups(groups, true)?;
|
||||
|
||||
Ok(Self {
|
||||
field_id: field_rev.id.clone(),
|
||||
|
@ -16,7 +16,7 @@ impl DefaultGroupController {
|
||||
let group = Group::new(
|
||||
DEFAULT_GROUP_CONTROLLER.to_owned(),
|
||||
field_rev.id.clone(),
|
||||
"Oops".to_owned(),
|
||||
"".to_owned(),
|
||||
"".to_owned(),
|
||||
);
|
||||
Self {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::entities::{CreateFilterParams, DeleteFilterParams, GridLayout, GridSettingChangesetParams};
|
||||
use crate::entities::{DeleteFilterParams, GridLayout, GridSettingChangesetParams, InsertFilterParams};
|
||||
|
||||
pub struct GridSettingChangesetBuilder {
|
||||
params: GridSettingChangesetParams,
|
||||
@ -17,7 +17,7 @@ impl GridSettingChangesetBuilder {
|
||||
Self { params }
|
||||
}
|
||||
|
||||
pub fn insert_filter(mut self, params: CreateFilterParams) -> Self {
|
||||
pub fn insert_filter(mut self, params: InsertFilterParams) -> Self {
|
||||
self.params.insert_filter = Some(params);
|
||||
self
|
||||
}
|
||||
|
@ -3,14 +3,14 @@
|
||||
#![allow(dead_code)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use flowy_grid::entities::{CreateFilterParams, CreateGridFilterPayloadPB, DeleteFilterParams, GridLayout, GridSettingChangesetParams, GridSettingPB};
|
||||
use flowy_grid::entities::{InsertFilterParams, InsertFilterPayloadPB, DeleteFilterParams, GridLayout, GridSettingChangesetParams, GridSettingPB};
|
||||
use flowy_grid::services::setting::GridSettingChangesetBuilder;
|
||||
use flowy_grid_data_model::revision::{FieldRevision, FieldTypeRevision};
|
||||
use crate::grid::grid_editor::GridEditorTest;
|
||||
|
||||
pub enum FilterScript {
|
||||
InsertGridTableFilter {
|
||||
payload: CreateGridFilterPayloadPB,
|
||||
payload: InsertFilterPayloadPB,
|
||||
},
|
||||
AssertTableFilterCount {
|
||||
count: i32,
|
||||
@ -47,8 +47,8 @@ impl GridFilterTest {
|
||||
match script {
|
||||
|
||||
FilterScript::InsertGridTableFilter { payload } => {
|
||||
let params: CreateFilterParams = payload.try_into().unwrap();
|
||||
let _ = self.editor.update_filter(params).await.unwrap();
|
||||
let params: InsertFilterParams = payload.try_into().unwrap();
|
||||
let _ = self.editor.create_filter(params).await.unwrap();
|
||||
}
|
||||
FilterScript::AssertTableFilterCount { count } => {
|
||||
let filters = self.editor.get_grid_filter().await.unwrap();
|
||||
|
@ -1,13 +1,13 @@
|
||||
use crate::grid::filter_test::script::FilterScript::*;
|
||||
use crate::grid::filter_test::script::*;
|
||||
use flowy_grid::entities::{CreateGridFilterPayloadPB, FieldType, TextFilterCondition};
|
||||
use flowy_grid::entities::{FieldType, InsertFilterPayloadPB, TextFilterCondition};
|
||||
use flowy_grid_data_model::revision::FieldRevision;
|
||||
|
||||
#[tokio::test]
|
||||
async fn grid_filter_create_test() {
|
||||
let mut test = GridFilterTest::new().await;
|
||||
let field_rev = test.get_field_rev(FieldType::RichText);
|
||||
let payload = CreateGridFilterPayloadPB::new(field_rev, TextFilterCondition::TextIsEmpty, Some("abc".to_owned()));
|
||||
let payload = InsertFilterPayloadPB::new(field_rev, TextFilterCondition::TextIsEmpty, Some("abc".to_owned()));
|
||||
let scripts = vec![InsertGridTableFilter { payload }, AssertTableFilterCount { count: 1 }];
|
||||
test.run_scripts(scripts).await;
|
||||
}
|
||||
@ -19,7 +19,7 @@ async fn grid_filter_invalid_condition_panic_test() {
|
||||
let field_rev = test.get_field_rev(FieldType::RichText).clone();
|
||||
|
||||
// 100 is not a valid condition, so this test should be panic.
|
||||
let payload = CreateGridFilterPayloadPB::new(&field_rev, 100, Some("".to_owned()));
|
||||
let payload = InsertFilterPayloadPB::new(&field_rev, 100, Some("".to_owned()));
|
||||
let scripts = vec![InsertGridTableFilter { payload }];
|
||||
test.run_scripts(scripts).await;
|
||||
}
|
||||
@ -46,6 +46,6 @@ async fn grid_filter_delete_test() {
|
||||
#[tokio::test]
|
||||
async fn grid_filter_get_rows_test() {}
|
||||
|
||||
fn create_filter(field_rev: &FieldRevision, condition: TextFilterCondition, s: &str) -> CreateGridFilterPayloadPB {
|
||||
CreateGridFilterPayloadPB::new(field_rev, condition, Some(s.to_owned()))
|
||||
fn create_filter(field_rev: &FieldRevision, condition: TextFilterCondition, s: &str) -> InsertFilterPayloadPB {
|
||||
InsertFilterPayloadPB::new(field_rev, condition, Some(s.to_owned()))
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ impl GridGroupTest {
|
||||
.await;
|
||||
}
|
||||
GroupScript::GroupByField { field_id } => {
|
||||
self.editor.group_field(&field_id).await.unwrap();
|
||||
self.editor.group_by_field(&field_id).await.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user