grid.rs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
  2. use std::collections::HashMap;
  3. #[derive(Debug, Default, ProtoBuf)]
  4. pub struct Grid {
  5. #[pb(index = 1)]
  6. pub grid_id: String,
  7. #[pb(index = 2)]
  8. pub filters: RepeatedGridFilter,
  9. #[pb(index = 3)]
  10. pub field_orders: RepeatedFieldOrder,
  11. #[pb(index = 4)]
  12. pub row_orders: RepeatedRowOrder,
  13. }
  14. #[derive(Debug, Default, ProtoBuf)]
  15. pub struct GridFilter {
  16. #[pb(index = 1)]
  17. pub id: String,
  18. #[pb(index = 2)]
  19. pub name: String,
  20. #[pb(index = 3)]
  21. pub desc: String,
  22. }
  23. #[derive(Debug, Default, ProtoBuf)]
  24. pub struct RepeatedGridFilter {
  25. #[pb(index = 1)]
  26. pub items: Vec<GridFilter>,
  27. }
  28. #[derive(Debug, Default, ProtoBuf)]
  29. pub struct FieldOrder {
  30. #[pb(index = 1)]
  31. pub field_id: String,
  32. #[pb(index = 2)]
  33. pub visibility: bool,
  34. #[pb(index = 3)]
  35. pub width: i32,
  36. }
  37. #[derive(Debug, Default, ProtoBuf)]
  38. pub struct RepeatedFieldOrder {
  39. #[pb(index = 1)]
  40. pub items: Vec<FieldOrder>,
  41. }
  42. #[derive(Debug, Default, ProtoBuf)]
  43. pub struct Field {
  44. #[pb(index = 1)]
  45. pub id: String,
  46. #[pb(index = 2)]
  47. pub name: String,
  48. #[pb(index = 3)]
  49. pub desc: String,
  50. #[pb(index = 4)]
  51. pub field_type: FieldType,
  52. #[pb(index = 5)]
  53. pub frozen: bool,
  54. #[pb(index = 6)]
  55. pub type_options: AnyData,
  56. }
  57. #[derive(Debug, ProtoBuf_Enum)]
  58. pub enum FieldType {
  59. RichText = 0,
  60. Number = 1,
  61. DateTime = 2,
  62. SingleSelect = 3,
  63. MultiSelect = 4,
  64. Checkbox = 5,
  65. }
  66. impl std::default::Default for FieldType {
  67. fn default() -> Self {
  68. FieldType::RichText
  69. }
  70. }
  71. #[derive(Debug, Default, ProtoBuf)]
  72. pub struct AnyData {
  73. #[pb(index = 1)]
  74. pub type_url: String,
  75. #[pb(index = 2)]
  76. pub value: Vec<u8>,
  77. }
  78. #[derive(Debug, Default, ProtoBuf)]
  79. pub struct RowOrder {
  80. #[pb(index = 1)]
  81. pub grid_id: String,
  82. #[pb(index = 2)]
  83. pub row_id: String,
  84. #[pb(index = 3)]
  85. pub visibility: bool,
  86. }
  87. #[derive(Debug, Default, ProtoBuf)]
  88. pub struct RepeatedRowOrder {
  89. #[pb(index = 1)]
  90. pub items: Vec<RowOrder>,
  91. }
  92. #[derive(Debug, Default, ProtoBuf)]
  93. pub struct Row {
  94. #[pb(index = 1)]
  95. pub id: String,
  96. #[pb(index = 2)]
  97. pub grid_id: String,
  98. #[pb(index = 3)]
  99. pub modified_time: i64,
  100. #[pb(index = 4)]
  101. pub cell_by_field_id: HashMap<String, Cell>,
  102. }
  103. #[derive(Debug, Default, ProtoBuf)]
  104. pub struct Cell {
  105. #[pb(index = 1)]
  106. pub id: String,
  107. #[pb(index = 2)]
  108. pub row_id: String,
  109. #[pb(index = 3)]
  110. pub field_id: String,
  111. #[pb(index = 4)]
  112. pub data: AnyData,
  113. }