2022-03-02 14:43:04 +00:00
|
|
|
use crate::event_handler::*;
|
2022-03-04 14:09:16 +00:00
|
|
|
use crate::manager::GridManager;
|
2022-03-02 14:43:04 +00:00
|
|
|
use flowy_derive::{Flowy_Event, ProtoBuf_Enum};
|
|
|
|
use lib_dispatch::prelude::*;
|
|
|
|
use std::sync::Arc;
|
|
|
|
use strum_macros::Display;
|
|
|
|
|
|
|
|
pub fn create(grid_manager: Arc<GridManager>) -> Module {
|
|
|
|
let mut module = Module::new().name(env!("CARGO_PKG_NAME")).data(grid_manager);
|
|
|
|
module = module
|
2022-03-06 13:22:42 +00:00
|
|
|
.event(GridEvent::GetGridData, get_grid_data_handler)
|
2022-03-17 09:25:43 +00:00
|
|
|
.event(GridEvent::GetGridBlocks, get_grid_blocks_handler)
|
2022-03-03 14:17:07 +00:00
|
|
|
.event(GridEvent::GetFields, get_fields_handler)
|
2022-03-23 14:10:31 +00:00
|
|
|
.event(GridEvent::UpdateField, update_field_handler)
|
|
|
|
.event(GridEvent::CreateField, create_field_handler)
|
2022-03-27 03:14:21 +00:00
|
|
|
.event(GridEvent::DeleteField, delete_field_handler)
|
|
|
|
.event(GridEvent::DuplicateField, duplicate_field_handler)
|
2022-03-31 14:51:46 +00:00
|
|
|
.event(GridEvent::GetEditFieldContext, edit_edit_field_context_handler)
|
2022-03-29 14:58:38 +00:00
|
|
|
.event(GridEvent::CreateSelectOption, create_select_option_handler)
|
2022-03-09 08:11:24 +00:00
|
|
|
.event(GridEvent::CreateRow, create_row_handler)
|
2022-03-18 09:14:46 +00:00
|
|
|
.event(GridEvent::GetRow, get_row_handler)
|
2022-03-09 08:11:24 +00:00
|
|
|
.event(GridEvent::UpdateCell, update_cell_handler);
|
2022-03-02 14:43:04 +00:00
|
|
|
|
|
|
|
module
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, PartialEq, Eq, Debug, Display, Hash, ProtoBuf_Enum, Flowy_Event)]
|
|
|
|
#[event_err = "FlowyError"]
|
|
|
|
pub enum GridEvent {
|
|
|
|
#[event(input = "GridId", output = "Grid")]
|
2022-03-06 13:22:42 +00:00
|
|
|
GetGridData = 0,
|
2022-03-03 14:17:07 +00:00
|
|
|
|
2022-03-17 09:25:43 +00:00
|
|
|
#[event(input = "QueryGridBlocksPayload", output = "RepeatedGridBlock")]
|
|
|
|
GetGridBlocks = 1,
|
2022-03-03 14:17:07 +00:00
|
|
|
|
2022-03-05 09:52:25 +00:00
|
|
|
#[event(input = "QueryFieldPayload", output = "RepeatedField")]
|
2022-03-18 09:14:46 +00:00
|
|
|
GetFields = 10,
|
2022-03-03 14:17:07 +00:00
|
|
|
|
2022-03-27 03:14:21 +00:00
|
|
|
#[event(input = "FieldChangesetPayload")]
|
2022-03-23 14:10:31 +00:00
|
|
|
UpdateField = 11,
|
|
|
|
|
|
|
|
#[event(input = "CreateFieldPayload")]
|
|
|
|
CreateField = 12,
|
|
|
|
|
2022-03-27 03:14:21 +00:00
|
|
|
#[event(input = "FieldIdentifierPayload")]
|
2022-03-27 01:35:10 +00:00
|
|
|
DeleteField = 13,
|
|
|
|
|
2022-03-27 03:14:21 +00:00
|
|
|
#[event(input = "FieldIdentifierPayload")]
|
|
|
|
DuplicateField = 15,
|
|
|
|
|
2022-03-31 14:51:46 +00:00
|
|
|
#[event(input = "GetEditFieldContextParams", output = "EditFieldContext")]
|
|
|
|
GetEditFieldContext = 16,
|
2022-03-24 09:09:05 +00:00
|
|
|
|
2022-03-29 14:58:38 +00:00
|
|
|
#[event(input = "CreateSelectOptionPayload", output = "SelectOption")]
|
|
|
|
CreateSelectOption = 30,
|
|
|
|
|
2022-03-16 08:10:35 +00:00
|
|
|
#[event(input = "CreateRowPayload", output = "Row")]
|
2022-03-29 14:58:38 +00:00
|
|
|
CreateRow = 50,
|
2022-03-18 09:14:46 +00:00
|
|
|
|
|
|
|
#[event(input = "QueryRowPayload", output = "Row")]
|
2022-03-29 14:58:38 +00:00
|
|
|
GetRow = 51,
|
2022-03-09 08:11:24 +00:00
|
|
|
|
2022-03-16 08:10:35 +00:00
|
|
|
#[event(input = "CellMetaChangeset")]
|
2022-03-29 14:58:38 +00:00
|
|
|
UpdateCell = 70,
|
2022-03-02 14:43:04 +00:00
|
|
|
}
|