123 lines
4.2 KiB
Rust
Raw Normal View History

2022-03-02 22:43:04 +08:00
use crate::event_handler::*;
2022-03-04 22:09:16 +08:00
use crate::manager::GridManager;
2022-03-02 22:43:04 +08: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 21:22:42 +08:00
.event(GridEvent::GetGridData, get_grid_data_handler)
2022-03-17 17:25:43 +08:00
.event(GridEvent::GetGridBlocks, get_grid_blocks_handler)
2022-06-19 21:10:07 +08:00
.event(GridEvent::GetGridSetting, get_grid_setting_handler)
2022-06-20 09:37:52 +08:00
.event(GridEvent::UpdateGridSetting, get_grid_setting_handler)
2022-04-05 21:25:59 +08:00
// Field
2022-03-03 22:17:07 +08:00
.event(GridEvent::GetFields, get_fields_handler)
.event(GridEvent::UpdateField, update_field_handler)
.event(GridEvent::InsertField, insert_field_handler)
2022-05-10 09:33:34 +08:00
.event(GridEvent::UpdateFieldTypeOption, update_field_type_option_handler)
2022-03-27 11:14:21 +08:00
.event(GridEvent::DeleteField, delete_field_handler)
.event(GridEvent::SwitchToField, switch_to_field_handler)
2022-03-27 11:14:21 +08:00
.event(GridEvent::DuplicateField, duplicate_field_handler)
2022-04-13 14:24:54 +08:00
.event(GridEvent::MoveItem, move_item_handler)
.event(GridEvent::GetFieldTypeOption, get_field_type_option_data_handler)
2022-05-19 10:41:00 +08:00
.event(GridEvent::CreateFieldTypeOption, create_field_type_option_data_handler)
2022-04-05 21:25:59 +08:00
// Row
2022-03-09 16:11:24 +08:00
.event(GridEvent::CreateRow, create_row_handler)
2022-03-18 17:14:46 +08:00
.event(GridEvent::GetRow, get_row_handler)
2022-04-09 22:07:48 +08:00
.event(GridEvent::DeleteRow, delete_row_handler)
.event(GridEvent::DuplicateRow, duplicate_row_handler)
2022-04-05 21:25:59 +08:00
// Cell
2022-04-07 20:15:00 +08:00
.event(GridEvent::GetCell, get_cell_handler)
2022-04-05 14:25:07 +08:00
.event(GridEvent::UpdateCell, update_cell_handler)
2022-04-05 21:25:59 +08:00
// SelectOption
2022-04-07 08:33:10 +08:00
.event(GridEvent::NewSelectOption, new_select_option_handler)
.event(GridEvent::UpdateSelectOption, update_select_option_handler)
2022-05-12 22:36:39 +08:00
.event(GridEvent::GetSelectOptionCellData, get_select_option_handler)
2022-05-11 11:34:13 +08:00
.event(GridEvent::UpdateSelectOptionCell, update_select_option_cell_handler)
// Date
.event(GridEvent::UpdateDateCell, update_date_cell_handler);
2022-03-02 22:43:04 +08: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 21:22:42 +08:00
GetGridData = 0,
2022-03-03 22:17:07 +08:00
2022-03-17 17:25:43 +08:00
#[event(input = "QueryGridBlocksPayload", output = "RepeatedGridBlock")]
GetGridBlocks = 1,
2022-03-03 22:17:07 +08:00
2022-06-19 21:10:07 +08:00
#[event(input = "GridId", output = "GridSetting")]
GetGridSetting = 2,
2022-06-20 09:37:52 +08:00
#[event(input = "GridId", input = "GridSettingChangesetPayload")]
UpdateGridSetting = 3,
2022-03-05 17:52:25 +08:00
#[event(input = "QueryFieldPayload", output = "RepeatedField")]
2022-03-18 17:14:46 +08:00
GetFields = 10,
2022-03-03 22:17:07 +08:00
2022-03-27 11:14:21 +08:00
#[event(input = "FieldChangesetPayload")]
UpdateField = 11,
2022-05-10 09:33:34 +08:00
#[event(input = "UpdateFieldTypeOptionPayload")]
UpdateFieldTypeOption = 12,
#[event(input = "InsertFieldPayload")]
2022-05-10 09:33:34 +08:00
InsertField = 13,
2022-03-27 11:14:21 +08:00
#[event(input = "FieldIdentifierPayload")]
2022-05-10 09:33:34 +08:00
DeleteField = 14,
2022-03-27 09:35:10 +08:00
#[event(input = "EditFieldPayload", output = "FieldTypeOptionData")]
2022-05-10 09:33:34 +08:00
SwitchToField = 20,
2022-03-27 11:14:21 +08:00
#[event(input = "FieldIdentifierPayload")]
2022-05-10 09:33:34 +08:00
DuplicateField = 21,
2022-03-27 11:14:21 +08:00
2022-04-13 14:24:54 +08:00
#[event(input = "MoveItemPayload")]
MoveItem = 22,
2022-04-13 14:24:54 +08:00
2022-05-09 14:59:26 +08:00
#[event(input = "EditFieldPayload", output = "FieldTypeOptionData")]
GetFieldTypeOption = 23,
2022-05-19 10:41:00 +08:00
#[event(input = "EditFieldPayload", output = "FieldTypeOptionData")]
CreateFieldTypeOption = 24,
#[event(input = "CreateSelectOptionPayload", output = "SelectOption")]
2022-04-07 08:33:10 +08:00
NewSelectOption = 30,
2022-03-29 22:58:38 +08:00
2022-05-12 22:36:39 +08:00
#[event(input = "CellIdentifierPayload", output = "SelectOptionCellData")]
GetSelectOptionCellData = 31,
2022-04-07 08:33:10 +08:00
#[event(input = "SelectOptionChangesetPayload")]
UpdateSelectOption = 32,
2022-04-05 14:25:07 +08:00
#[event(input = "CreateRowPayload", output = "Row")]
2022-03-29 22:58:38 +08:00
CreateRow = 50,
2022-03-18 17:14:46 +08:00
2022-04-07 08:33:10 +08:00
#[event(input = "RowIdentifierPayload", output = "Row")]
2022-03-29 22:58:38 +08:00
GetRow = 51,
2022-03-09 16:11:24 +08:00
2022-04-09 22:07:48 +08:00
#[event(input = "RowIdentifierPayload")]
DeleteRow = 52,
#[event(input = "RowIdentifierPayload")]
DuplicateRow = 53,
2022-04-07 20:15:00 +08:00
#[event(input = "CellIdentifierPayload", output = "Cell")]
GetCell = 70,
#[event(input = "CellChangeset")]
2022-04-07 20:15:00 +08:00
UpdateCell = 71,
2022-04-05 14:25:07 +08:00
2022-04-07 08:33:10 +08:00
#[event(input = "SelectOptionCellChangesetPayload")]
2022-05-11 11:34:13 +08:00
UpdateSelectOptionCell = 72,
#[event(input = "DateChangesetPayload")]
UpdateDateCell = 80,
2022-03-02 22:43:04 +08:00
}