event_map.rs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. use crate::event_handler::*;
  2. use crate::manager::GridManager;
  3. use flowy_derive::{Flowy_Event, ProtoBuf_Enum};
  4. use lib_dispatch::prelude::*;
  5. use std::sync::Arc;
  6. use strum_macros::Display;
  7. pub fn create(grid_manager: Arc<GridManager>) -> Module {
  8. let mut module = Module::new().name(env!("CARGO_PKG_NAME")).data(grid_manager);
  9. module = module
  10. .event(GridEvent::GetGrid, get_grid_handler)
  11. .event(GridEvent::GetGridBlocks, get_grid_blocks_handler)
  12. .event(GridEvent::GetGridSetting, get_grid_setting_handler)
  13. .event(GridEvent::UpdateGridSetting, update_grid_setting_handler)
  14. // Field
  15. .event(GridEvent::GetFields, get_fields_handler)
  16. .event(GridEvent::UpdateField, update_field_handler)
  17. .event(GridEvent::InsertField, insert_field_handler)
  18. .event(GridEvent::UpdateFieldTypeOption, update_field_type_option_handler)
  19. .event(GridEvent::DeleteField, delete_field_handler)
  20. .event(GridEvent::SwitchToField, switch_to_field_handler)
  21. .event(GridEvent::DuplicateField, duplicate_field_handler)
  22. .event(GridEvent::MoveItem, move_item_handler)
  23. .event(GridEvent::GetFieldTypeOption, get_field_type_option_data_handler)
  24. .event(GridEvent::CreateFieldTypeOption, create_field_type_option_data_handler)
  25. // Row
  26. .event(GridEvent::CreateRow, create_row_handler)
  27. .event(GridEvent::GetRow, get_row_handler)
  28. .event(GridEvent::DeleteRow, delete_row_handler)
  29. .event(GridEvent::DuplicateRow, duplicate_row_handler)
  30. // Cell
  31. .event(GridEvent::GetCell, get_cell_handler)
  32. .event(GridEvent::UpdateCell, update_cell_handler)
  33. // SelectOption
  34. .event(GridEvent::NewSelectOption, new_select_option_handler)
  35. .event(GridEvent::UpdateSelectOption, update_select_option_handler)
  36. .event(GridEvent::GetSelectOptionCellData, get_select_option_handler)
  37. .event(GridEvent::UpdateSelectOptionCell, update_select_option_cell_handler)
  38. // Date
  39. .event(GridEvent::UpdateDateCell, update_date_cell_handler);
  40. module
  41. }
  42. #[derive(Clone, Copy, PartialEq, Eq, Debug, Display, Hash, ProtoBuf_Enum, Flowy_Event)]
  43. #[event_err = "FlowyError"]
  44. pub enum GridEvent {
  45. #[event(input = "GridIdPB", output = "GridPB")]
  46. GetGrid = 0,
  47. #[event(input = "QueryGridBlocksPayloadPB", output = "RepeatedGridBlockPB")]
  48. GetGridBlocks = 1,
  49. #[event(input = "GridIdPB", output = "GridSettingPB")]
  50. GetGridSetting = 2,
  51. #[event(input = "GridIdPB", input = "GridSettingChangesetPayloadPB")]
  52. UpdateGridSetting = 3,
  53. #[event(input = "QueryFieldPayloadPB", output = "RepeatedGridFieldPB")]
  54. GetFields = 10,
  55. #[event(input = "FieldChangesetPayloadPB")]
  56. UpdateField = 11,
  57. #[event(input = "UpdateFieldTypeOptionPayloadPB")]
  58. UpdateFieldTypeOption = 12,
  59. #[event(input = "InsertFieldPayloadPB")]
  60. InsertField = 13,
  61. #[event(input = "DeleteFieldPayloadPB")]
  62. DeleteField = 14,
  63. #[event(input = "EditFieldPayloadPB", output = "FieldTypeOptionDataPB")]
  64. SwitchToField = 20,
  65. #[event(input = "DuplicateFieldPayloadPB")]
  66. DuplicateField = 21,
  67. #[event(input = "MoveItemPayloadPB")]
  68. MoveItem = 22,
  69. #[event(input = "GridFieldTypeOptionIdPB", output = "FieldTypeOptionDataPB")]
  70. GetFieldTypeOption = 23,
  71. #[event(input = "CreateFieldPayloadPB", output = "FieldTypeOptionDataPB")]
  72. CreateFieldTypeOption = 24,
  73. #[event(input = "CreateSelectOptionPayloadPB", output = "SelectOptionPB")]
  74. NewSelectOption = 30,
  75. #[event(input = "GridCellIdPB", output = "SelectOptionCellDataPB")]
  76. GetSelectOptionCellData = 31,
  77. #[event(input = "SelectOptionChangesetPayloadPB")]
  78. UpdateSelectOption = 32,
  79. #[event(input = "CreateRowPayloadPB", output = "GridRowPB")]
  80. CreateRow = 50,
  81. #[event(input = "GridRowIdPB", output = "OptionalRowPB")]
  82. GetRow = 51,
  83. #[event(input = "GridRowIdPB")]
  84. DeleteRow = 52,
  85. #[event(input = "GridRowIdPB")]
  86. DuplicateRow = 53,
  87. #[event(input = "GridCellIdPB", output = "GridCellPB")]
  88. GetCell = 70,
  89. #[event(input = "CellChangesetPB")]
  90. UpdateCell = 71,
  91. #[event(input = "SelectOptionCellChangesetPayloadPB")]
  92. UpdateSelectOptionCell = 72,
  93. #[event(input = "DateChangesetPayloadPB")]
  94. UpdateDateCell = 80,
  95. }