mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: config checkbox ui
This commit is contained in:
@ -190,6 +190,19 @@ pub(crate) async fn create_row_handler(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip_all, err)]
|
||||
pub(crate) async fn get_cell_handler(
|
||||
data: Data<CellIdentifierPayload>,
|
||||
manager: AppData<Arc<GridManager>>,
|
||||
) -> DataResult<Cell, FlowyError> {
|
||||
let params: CellIdentifier = data.into_inner().try_into()?;
|
||||
let editor = manager.get_grid_editor(¶ms.grid_id)?;
|
||||
match editor.get_cell(¶ms).await {
|
||||
None => data_result(Cell::new(¶ms.field_id, "".to_owned())),
|
||||
Some(cell) => data_result(cell),
|
||||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip_all, err)]
|
||||
pub(crate) async fn update_cell_handler(
|
||||
data: Data<CellMetaChangeset>,
|
||||
|
@ -21,6 +21,7 @@ pub fn create(grid_manager: Arc<GridManager>) -> Module {
|
||||
.event(GridEvent::CreateRow, create_row_handler)
|
||||
.event(GridEvent::GetRow, get_row_handler)
|
||||
// Cell
|
||||
.event(GridEvent::GetCell, get_cell_handler)
|
||||
.event(GridEvent::UpdateCell, update_cell_handler)
|
||||
// SelectOption
|
||||
.event(GridEvent::NewSelectOption, new_select_option_handler)
|
||||
@ -80,9 +81,12 @@ pub enum GridEvent {
|
||||
#[event(input = "RowIdentifierPayload", output = "Row")]
|
||||
GetRow = 51,
|
||||
|
||||
#[event(input = "CellIdentifierPayload", output = "Cell")]
|
||||
GetCell = 70,
|
||||
|
||||
#[event(input = "CellMetaChangeset")]
|
||||
UpdateCell = 70,
|
||||
UpdateCell = 71,
|
||||
|
||||
#[event(input = "SelectOptionCellChangesetPayload")]
|
||||
ApplySelectOptionCellChangeset = 71,
|
||||
ApplySelectOptionCellChangeset = 72,
|
||||
}
|
||||
|
@ -39,8 +39,9 @@ pub enum GridEvent {
|
||||
ApplySelectOptionChangeset = 32,
|
||||
CreateRow = 50,
|
||||
GetRow = 51,
|
||||
UpdateCell = 70,
|
||||
ApplySelectOptionCellChangeset = 71,
|
||||
GetCell = 70,
|
||||
UpdateCell = 71,
|
||||
ApplySelectOptionCellChangeset = 72,
|
||||
}
|
||||
|
||||
impl ::protobuf::ProtobufEnum for GridEvent {
|
||||
@ -64,8 +65,9 @@ impl ::protobuf::ProtobufEnum for GridEvent {
|
||||
32 => ::std::option::Option::Some(GridEvent::ApplySelectOptionChangeset),
|
||||
50 => ::std::option::Option::Some(GridEvent::CreateRow),
|
||||
51 => ::std::option::Option::Some(GridEvent::GetRow),
|
||||
70 => ::std::option::Option::Some(GridEvent::UpdateCell),
|
||||
71 => ::std::option::Option::Some(GridEvent::ApplySelectOptionCellChangeset),
|
||||
70 => ::std::option::Option::Some(GridEvent::GetCell),
|
||||
71 => ::std::option::Option::Some(GridEvent::UpdateCell),
|
||||
72 => ::std::option::Option::Some(GridEvent::ApplySelectOptionCellChangeset),
|
||||
_ => ::std::option::Option::None
|
||||
}
|
||||
}
|
||||
@ -86,6 +88,7 @@ impl ::protobuf::ProtobufEnum for GridEvent {
|
||||
GridEvent::ApplySelectOptionChangeset,
|
||||
GridEvent::CreateRow,
|
||||
GridEvent::GetRow,
|
||||
GridEvent::GetCell,
|
||||
GridEvent::UpdateCell,
|
||||
GridEvent::ApplySelectOptionCellChangeset,
|
||||
];
|
||||
@ -116,15 +119,15 @@ impl ::protobuf::reflect::ProtobufValue for GridEvent {
|
||||
}
|
||||
|
||||
static file_descriptor_proto_data: &'static [u8] = b"\
|
||||
\n\x0fevent_map.proto*\xd1\x02\n\tGridEvent\x12\x0f\n\x0bGetGridData\x10\
|
||||
\n\x0fevent_map.proto*\xde\x02\n\tGridEvent\x12\x0f\n\x0bGetGridData\x10\
|
||||
\0\x12\x11\n\rGetGridBlocks\x10\x01\x12\r\n\tGetFields\x10\n\x12\x0f\n\
|
||||
\x0bUpdateField\x10\x0b\x12\x0f\n\x0bCreateField\x10\x0c\x12\x0f\n\x0bDe\
|
||||
leteField\x10\r\x12\x11\n\rSwitchToField\x10\x0e\x12\x12\n\x0eDuplicateF\
|
||||
ield\x10\x0f\x12\x17\n\x13GetEditFieldContext\x10\x10\x12\x13\n\x0fNewSe\
|
||||
lectOption\x10\x1e\x12\x1a\n\x16GetSelectOptionContext\x10\x1f\x12\x1e\n\
|
||||
\x1aApplySelectOptionChangeset\x10\x20\x12\r\n\tCreateRow\x102\x12\n\n\
|
||||
\x06GetRow\x103\x12\x0e\n\nUpdateCell\x10F\x12\"\n\x1eApplySelectOptionC\
|
||||
ellChangeset\x10Gb\x06proto3\
|
||||
\x06GetRow\x103\x12\x0b\n\x07GetCell\x10F\x12\x0e\n\nUpdateCell\x10G\x12\
|
||||
\"\n\x1eApplySelectOptionCellChangeset\x10Hb\x06proto3\
|
||||
";
|
||||
|
||||
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;
|
||||
|
@ -15,6 +15,7 @@ enum GridEvent {
|
||||
ApplySelectOptionChangeset = 32;
|
||||
CreateRow = 50;
|
||||
GetRow = 51;
|
||||
UpdateCell = 70;
|
||||
ApplySelectOptionCellChangeset = 71;
|
||||
GetCell = 70;
|
||||
UpdateCell = 71;
|
||||
ApplySelectOptionCellChangeset = 72;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
use crate::dart_notification::{send_dart_notification, GridNotification};
|
||||
use crate::manager::GridUser;
|
||||
use crate::services::block_meta_manager::GridBlockMetaEditorManager;
|
||||
use crate::services::cell::CellIdentifier;
|
||||
use crate::services::field::{default_type_option_builder_from_type, type_option_builder_from_bytes, FieldBuilder};
|
||||
use crate::services::persistence::block_index::BlockIndexPersistence;
|
||||
use crate::services::row::*;
|
||||
@ -264,6 +265,12 @@ impl ClientGridEditor {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get_cell(&self, params: &CellIdentifier) -> Option<Cell> {
|
||||
let field_meta = self.get_field_meta(¶ms.field_id).await?;
|
||||
let row_meta = self.block_meta_manager.get_row_meta(¶ms.row_id).await.ok()??;
|
||||
make_cell(¶ms.field_id, &field_meta, &row_meta)
|
||||
}
|
||||
|
||||
pub async fn get_cell_meta(&self, row_id: &str, field_id: &str) -> FlowyResult<Option<CellMeta>> {
|
||||
let row_meta = self.block_meta_manager.get_row_meta(row_id).await?;
|
||||
match row_meta {
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::services::field::*;
|
||||
use flowy_grid_data_model::entities::BuildGridContext;
|
||||
use flowy_grid_data_model::entities::{BuildGridContext, FieldType};
|
||||
use flowy_sync::client_grid::GridBuilder;
|
||||
|
||||
pub fn make_default_grid() -> BuildGridContext {
|
||||
@ -25,10 +25,16 @@ pub fn make_default_grid() -> BuildGridContext {
|
||||
.visibility(true)
|
||||
.build();
|
||||
|
||||
let checkbox_field = FieldBuilder::from_field_type(&FieldType::Checkbox)
|
||||
.name("isReady")
|
||||
.visibility(true)
|
||||
.build();
|
||||
|
||||
GridBuilder::default()
|
||||
.add_field(text_field)
|
||||
.add_field(single_select_field)
|
||||
.add_field(multi_select_field)
|
||||
.add_field(checkbox_field)
|
||||
.add_empty_row()
|
||||
.add_empty_row()
|
||||
.add_empty_row()
|
||||
|
Reference in New Issue
Block a user