habarico 7.2.0.pre.beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +82 -0
  4. data/Rakefile +15 -0
  5. data/VERSION +1 -0
  6. data/app/controllers/habarico/action_schema_controller.rb +41 -0
  7. data/app/controllers/habarico/application_controller.rb +15 -0
  8. data/app/controllers/habarico/contrib/preferences/user_preferences_controller.rb +105 -0
  9. data/app/controllers/habarico/global_schema_controller.rb +11 -0
  10. data/app/controllers/habarico/local_schema_controller.rb +35 -0
  11. data/app/helpers/habarico/application_helper.rb +4 -0
  12. data/app/models/habarico/application_record.rb +5 -0
  13. data/app/views/layouts/habarico/application.html.erb +17 -0
  14. data/config/locales/cs.yml +39 -0
  15. data/config/locales/de.yml +39 -0
  16. data/config/locales/en.yml +39 -0
  17. data/config/locales/es.yml +39 -0
  18. data/config/locales/fr.yml +39 -0
  19. data/config/locales/it.yml +39 -0
  20. data/config/locales/ja.yml +39 -0
  21. data/config/locales/nl.yml +39 -0
  22. data/config/locales/pl.yml +39 -0
  23. data/config/locales/pt.yml +39 -0
  24. data/config/locales/ro.yml +39 -0
  25. data/config/locales/sk.yml +39 -0
  26. data/config/locales/uk.yml +39 -0
  27. data/config/routes.rb +1 -0
  28. data/lib/generators/habarico/preferences/install_generator.rb +27 -0
  29. data/lib/generators/habarico/preferences/templates/create_habarico_user_preferences.rb.tt +15 -0
  30. data/lib/habarico/active_model/references.rb +68 -0
  31. data/lib/habarico/authenticatable.rb +31 -0
  32. data/lib/habarico/config.rb +71 -0
  33. data/lib/habarico/context.rb +126 -0
  34. data/lib/habarico/contrib/preferences/base_preferences.rb +40 -0
  35. data/lib/habarico/contrib/preferences/config.rb +31 -0
  36. data/lib/habarico/contrib/preferences/errors.rb +79 -0
  37. data/lib/habarico/contrib/preferences/locales/cs.yml +8 -0
  38. data/lib/habarico/contrib/preferences/locales/de.yml +8 -0
  39. data/lib/habarico/contrib/preferences/locales/en.yml +8 -0
  40. data/lib/habarico/contrib/preferences/locales/es.yml +8 -0
  41. data/lib/habarico/contrib/preferences/locales/fr.yml +8 -0
  42. data/lib/habarico/contrib/preferences/locales/it.yml +8 -0
  43. data/lib/habarico/contrib/preferences/locales/ja.yml +8 -0
  44. data/lib/habarico/contrib/preferences/locales/nl.yml +8 -0
  45. data/lib/habarico/contrib/preferences/locales/pl.yml +8 -0
  46. data/lib/habarico/contrib/preferences/locales/pt.yml +8 -0
  47. data/lib/habarico/contrib/preferences/locales/ro.yml +8 -0
  48. data/lib/habarico/contrib/preferences/locales/sk.yml +8 -0
  49. data/lib/habarico/contrib/preferences/locales/uk.yml +8 -0
  50. data/lib/habarico/contrib/preferences/registry.rb +293 -0
  51. data/lib/habarico/contrib/preferences/routes.rb +17 -0
  52. data/lib/habarico/contrib/preferences/schemas.rb +129 -0
  53. data/lib/habarico/contrib/preferences/serializer.rb +19 -0
  54. data/lib/habarico/contrib/preferences/user_preference.rb +16 -0
  55. data/lib/habarico/contrib/preferences.rb +32 -0
  56. data/lib/habarico/controller.rb +584 -0
  57. data/lib/habarico/definition/action_reference.rb +18 -0
  58. data/lib/habarico/definition/actions/action.rb +14 -0
  59. data/lib/habarico/definition/actions/create_action.rb +18 -0
  60. data/lib/habarico/definition/actions/delete_action.rb +20 -0
  61. data/lib/habarico/definition/actions/edit_action.rb +18 -0
  62. data/lib/habarico/definition/actions/link_action.rb +11 -0
  63. data/lib/habarico/definition/actions/resource_action.rb +12 -0
  64. data/lib/habarico/definition/actions/save_action.rb +14 -0
  65. data/lib/habarico/definition/actions/show_action.rb +18 -0
  66. data/lib/habarico/definition/actions/upload_images_action.rb +11 -0
  67. data/lib/habarico/definition/actions/view_action.rb +11 -0
  68. data/lib/habarico/definition/boxes/array_box.rb +10 -0
  69. data/lib/habarico/definition/boxes/box.rb +32 -0
  70. data/lib/habarico/definition/boxes/gallery_box.rb +10 -0
  71. data/lib/habarico/definition/boxes/grid_box.rb +10 -0
  72. data/lib/habarico/definition/boxes/grid_item_box.rb +10 -0
  73. data/lib/habarico/definition/boxes/list_box.rb +10 -0
  74. data/lib/habarico/definition/boxes/object_box.rb +10 -0
  75. data/lib/habarico/definition/boxes/tab_box.rb +10 -0
  76. data/lib/habarico/definition/boxes/tab_item_box.rb +10 -0
  77. data/lib/habarico/definition/boxes/wizard_box.rb +10 -0
  78. data/lib/habarico/definition/concerns/definition_model.rb +38 -0
  79. data/lib/habarico/definition/definition.rb +206 -0
  80. data/lib/habarico/definition/field_reference.rb +9 -0
  81. data/lib/habarico/definition/filter_reference.rb +7 -0
  82. data/lib/habarico/definition/menu/link_menu_item.rb +12 -0
  83. data/lib/habarico/definition/menu/menu_item.rb +9 -0
  84. data/lib/habarico/definition/menu/text_menu_item.rb +12 -0
  85. data/lib/habarico/definition/menu/view_menu_item.rb +13 -0
  86. data/lib/habarico/definition/response.rb +13 -0
  87. data/lib/habarico/definition/views/action_view.rb +11 -0
  88. data/lib/habarico/definition/views/create_view.rb +15 -0
  89. data/lib/habarico/definition/views/edit_view.rb +15 -0
  90. data/lib/habarico/definition/views/list_view.rb +17 -0
  91. data/lib/habarico/definition/views/show_view.rb +15 -0
  92. data/lib/habarico/definition/views/view.rb +10 -0
  93. data/lib/habarico/engine.rb +6 -0
  94. data/lib/habarico/file_validations.rb +119 -0
  95. data/lib/habarico/generators/abstract_generator.rb +21 -0
  96. data/lib/habarico/generators/action/action_schema_generator.rb +111 -0
  97. data/lib/habarico/generators/action/confirm_dialog_properties_generator.rb +30 -0
  98. data/lib/habarico/generators/action/global_resource_action_schema_generator.rb +46 -0
  99. data/lib/habarico/generators/action/link_action_parameters_generator.rb +31 -0
  100. data/lib/habarico/generators/action/resource_action_endpoint_parameters_generator.rb +70 -0
  101. data/lib/habarico/generators/action/resource_action_parameters_generator.rb +40 -0
  102. data/lib/habarico/generators/action/resource_action_schema_generator.rb +51 -0
  103. data/lib/habarico/generators/action/save_action_parameters_generator.rb +26 -0
  104. data/lib/habarico/generators/action/upload_images_action_parameters_generator.rb +41 -0
  105. data/lib/habarico/generators/action/view_action_endpoint_parameters_generator.rb +37 -0
  106. data/lib/habarico/generators/action/view_action_parameters_generator.rb +56 -0
  107. data/lib/habarico/generators/endpoint/dynamic_render_options_generator.rb +26 -0
  108. data/lib/habarico/generators/endpoint/endpoints_schema_generator.rb +61 -0
  109. data/lib/habarico/generators/endpoint/enum_type_generator.rb +45 -0
  110. data/lib/habarico/generators/endpoint/field_options_generator.rb +179 -0
  111. data/lib/habarico/generators/endpoint/field_schema_generator.rb +381 -0
  112. data/lib/habarico/generators/endpoint/fields_schema_generator.rb +35 -0
  113. data/lib/habarico/generators/endpoint/filter_schema_generator.rb +201 -0
  114. data/lib/habarico/generators/endpoint/filters_schema_generator.rb +25 -0
  115. data/lib/habarico/generators/endpoint/method_schema_generator.rb +34 -0
  116. data/lib/habarico/generators/endpoint/number_field_options_generator.rb +45 -0
  117. data/lib/habarico/generators/endpoint/phone_field_options_generator.rb +29 -0
  118. data/lib/habarico/generators/endpoint/relation_field_options_generator.rb +90 -0
  119. data/lib/habarico/generators/endpoint/search_filter_schema_generator.rb +44 -0
  120. data/lib/habarico/generators/menu/menu_group_schema_generator.rb +63 -0
  121. data/lib/habarico/generators/menu/menu_link_parameters_generator.rb +31 -0
  122. data/lib/habarico/generators/menu/menu_schema_generator.rb +105 -0
  123. data/lib/habarico/generators/menu/menu_view_endpoint_parameters_generator.rb +44 -0
  124. data/lib/habarico/generators/menu/menu_view_parameters_generator.rb +50 -0
  125. data/lib/habarico/generators/resource/action_resource_schema_generator.rb +84 -0
  126. data/lib/habarico/generators/resource/global_resource_schema_generator.rb +70 -0
  127. data/lib/habarico/generators/resource/local_resource_schema_generator.rb +111 -0
  128. data/lib/habarico/generators/resource/object_resource_schema_generator.rb +49 -0
  129. data/lib/habarico/generators/resource/resource_schema_generator.rb +31 -0
  130. data/lib/habarico/generators/view/action_descriptor_generator.rb +88 -0
  131. data/lib/habarico/generators/view/array_box_parameters_generator.rb +34 -0
  132. data/lib/habarico/generators/view/box_options_generator.rb +23 -0
  133. data/lib/habarico/generators/view/box_schema_generator.rb +194 -0
  134. data/lib/habarico/generators/view/detail_view_parameters_generator.rb +57 -0
  135. data/lib/habarico/generators/view/field_descriptor_generator.rb +107 -0
  136. data/lib/habarico/generators/view/filter_descriptor_generator.rb +75 -0
  137. data/lib/habarico/generators/view/gallery_box_parameters_generator.rb +71 -0
  138. data/lib/habarico/generators/view/global_view_schema_generator.rb +59 -0
  139. data/lib/habarico/generators/view/grid_item_box_parameters_generator.rb +44 -0
  140. data/lib/habarico/generators/view/list_box_parameters_generator.rb +124 -0
  141. data/lib/habarico/generators/view/list_view_parameters_generator.rb +120 -0
  142. data/lib/habarico/generators/view/object_box_parameters_generator.rb +26 -0
  143. data/lib/habarico/generators/view/sort_descriptor_generator.rb +30 -0
  144. data/lib/habarico/generators/view/tab_box_parameters_generator.rb +26 -0
  145. data/lib/habarico/generators/view/view_endpoint_parameters_generator.rb +71 -0
  146. data/lib/habarico/generators/view/view_schema_generator.rb +87 -0
  147. data/lib/habarico/generators/view/wizard_box_parameters_generator.rb +32 -0
  148. data/lib/habarico/helpers/action_helper.rb +9 -0
  149. data/lib/habarico/helpers/attributes_helper.rb +67 -0
  150. data/lib/habarico/helpers/box_helper.rb +19 -0
  151. data/lib/habarico/helpers/callable_helper.rb +15 -0
  152. data/lib/habarico/helpers/filter_params_helper.rb +49 -0
  153. data/lib/habarico/helpers/order_by_helper.rb +56 -0
  154. data/lib/habarico/helpers/reflection_helper.rb +61 -0
  155. data/lib/habarico/helpers/sorting_helper.rb +136 -0
  156. data/lib/habarico/schema/action/action_schema.rb +46 -0
  157. data/lib/habarico/schema/action/confirm_dialog_properties.rb +13 -0
  158. data/lib/habarico/schema/action/global_resource_action_schema.rb +29 -0
  159. data/lib/habarico/schema/action/link_action_parameters.rb +15 -0
  160. data/lib/habarico/schema/action/resource_action_endpoint_parameters.rb +24 -0
  161. data/lib/habarico/schema/action/resource_action_parameters.rb +17 -0
  162. data/lib/habarico/schema/action/resource_action_schema.rb +14 -0
  163. data/lib/habarico/schema/action/save_action_parameters.rb +10 -0
  164. data/lib/habarico/schema/action/upload_images_action_parameters.rb +23 -0
  165. data/lib/habarico/schema/action/view_action_endpoint_parameters.rb +16 -0
  166. data/lib/habarico/schema/action/view_action_parameters.rb +27 -0
  167. data/lib/habarico/schema/endpoint/ai_field_options.rb +10 -0
  168. data/lib/habarico/schema/endpoint/box_options.rb +10 -0
  169. data/lib/habarico/schema/endpoint/choices_field_options.rb +10 -0
  170. data/lib/habarico/schema/endpoint/dynamic_render_options.rb +14 -0
  171. data/lib/habarico/schema/endpoint/endpoints_schema.rb +22 -0
  172. data/lib/habarico/schema/endpoint/enum_type.rb +21 -0
  173. data/lib/habarico/schema/endpoint/field_options.rb +56 -0
  174. data/lib/habarico/schema/endpoint/field_schema.rb +65 -0
  175. data/lib/habarico/schema/endpoint/filter_schema.rb +44 -0
  176. data/lib/habarico/schema/endpoint/image_field_options.rb +13 -0
  177. data/lib/habarico/schema/endpoint/key_value.rb +13 -0
  178. data/lib/habarico/schema/endpoint/method_schema.rb +13 -0
  179. data/lib/habarico/schema/endpoint/number_field_options.rb +24 -0
  180. data/lib/habarico/schema/endpoint/phone_field_options.rb +13 -0
  181. data/lib/habarico/schema/endpoint/relation_field_options.rb +39 -0
  182. data/lib/habarico/schema/extensible_enum.rb +20 -0
  183. data/lib/habarico/schema/menu/action_view_choice.rb +13 -0
  184. data/lib/habarico/schema/menu/menu_group_schema.rb +26 -0
  185. data/lib/habarico/schema/menu/menu_schema.rb +36 -0
  186. data/lib/habarico/schema/resource/global_resource_schema.rb +14 -0
  187. data/lib/habarico/schema/resource/local_resource_schema.rb +14 -0
  188. data/lib/habarico/schema/resource/object_resource_schema.rb +8 -0
  189. data/lib/habarico/schema/resource/resource_schema.rb +16 -0
  190. data/lib/habarico/schema/types.rb +102 -0
  191. data/lib/habarico/schema/view/action_descriptor.rb +30 -0
  192. data/lib/habarico/schema/view/array_box_parameters.rb +13 -0
  193. data/lib/habarico/schema/view/box_schema.rb +67 -0
  194. data/lib/habarico/schema/view/detail_view_parameters.rb +16 -0
  195. data/lib/habarico/schema/view/field_descriptor.rb +50 -0
  196. data/lib/habarico/schema/view/field_wrapper_properties.rb +13 -0
  197. data/lib/habarico/schema/view/filter_descriptor.rb +24 -0
  198. data/lib/habarico/schema/view/gallery_box_parameters.rb +31 -0
  199. data/lib/habarico/schema/view/global_view_schema.rb +25 -0
  200. data/lib/habarico/schema/view/grid_item_box_parameters.rb +13 -0
  201. data/lib/habarico/schema/view/list_box_parameters.rb +44 -0
  202. data/lib/habarico/schema/view/list_view_parameters.rb +31 -0
  203. data/lib/habarico/schema/view/object_box_parameters.rb +10 -0
  204. data/lib/habarico/schema/view/sort_descriptor.rb +15 -0
  205. data/lib/habarico/schema/view/sortable_parameters.rb +13 -0
  206. data/lib/habarico/schema/view/tab_box_parameters.rb +10 -0
  207. data/lib/habarico/schema/view/view_action_descriptor_parameters.rb +21 -0
  208. data/lib/habarico/schema/view/view_endpoint_parameters.rb +22 -0
  209. data/lib/habarico/schema/view/view_schema.rb +33 -0
  210. data/lib/habarico/schema/view/wizard_box_parameters.rb +13 -0
  211. data/lib/habarico/search/field_resolver.rb +138 -0
  212. data/lib/habarico/search/search_matcher.rb +152 -0
  213. data/lib/habarico/serializers/meta_serializer.rb +42 -0
  214. data/lib/habarico/serializers/record_serializer.rb +33 -0
  215. data/lib/habarico/serializers/serializer.rb +61 -0
  216. data/lib/habarico/services/resource_service.rb +69 -0
  217. data/lib/habarico/services/routing_service.rb +160 -0
  218. data/lib/habarico/services/schema_service.rb +72 -0
  219. data/lib/habarico/version.rb +5 -0
  220. data/lib/habarico.rb +262 -0
  221. metadata +324 -0
@@ -0,0 +1,14 @@
1
+ module Habarico
2
+ class GlobalResourceSchema < ResourceSchema
3
+
4
+ # List of actions (buttons) available for the resource, for example: "detail", "create", "edit", "delete" or a custom action like "approve"
5
+ has_many_attr :actions, 'Habarico::GlobalResourceActionSchema'
6
+
7
+ # List of views available for the resource, for example: "list", "show", "create", "edit"
8
+ has_many_attr :views, 'Habarico::GlobalViewSchema'
9
+
10
+ # Definition of the menu item and its parents associated with this resource
11
+ has_one_attr :menu, 'Habarico::MenuSchema'
12
+
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module Habarico
2
+ class LocalResourceSchema < ResourceSchema
3
+
4
+ # List of actions (buttons) available for the resource, for example: "detail", "create", "edit", "delete" or a custom action like "approve"
5
+ has_many_attr :actions, 'Habarico::ResourceActionSchema'
6
+
7
+ # List of views available for the resource, for example: "list", "show", "create", "edit"
8
+ has_many_attr :views, 'Habarico::ViewSchema'
9
+
10
+ # Definition of the API underlying this resource
11
+ has_one_attr :endpoints, 'Habarico::EndpointsSchema'
12
+
13
+ end
14
+ end
@@ -0,0 +1,8 @@
1
+ module Habarico
2
+ class ObjectResourceSchema < ResourceSchema
3
+
4
+ # List of actions (buttons) available for the resource, for example: "detail", "create", "edit", "delete" or a custom action like "approve"
5
+ has_many_attr :actions, 'Habarico::ResourceActionSchema'
6
+
7
+ end
8
+ end
@@ -0,0 +1,16 @@
1
+ module Habarico
2
+ class ResourceSchema
3
+ include ::ActiveModel::Model
4
+ include Eluvia::ActiveModel::Attributes
5
+
6
+ # Name of the resource in the API, used for coupling with actions
7
+ string_attr :name
8
+
9
+ # Human-readable label for the resource
10
+ string_attr :label
11
+
12
+ # Primary key field name for the resource, usually "id"
13
+ string_attr :pk_field_name
14
+
15
+ end
16
+ end
@@ -0,0 +1,102 @@
1
+ module Habarico
2
+ # Shared enum value lists.
3
+ #
4
+ # Every constant here mirrors one enum entity of the OpenAPI contract (`doc/openapi.yaml`) and is
5
+ # named after it, so the two can be matched one to one. Schema classes reference these instead of
6
+ # repeating the values inline, which is what used to let the same enum drift apart between classes.
7
+ #
8
+ # The values are the ones Ruby has always sent - aligning them with the contract (Ruby is missing
9
+ # `export` and `ai-assistant` in ACTION_TYPE and `decimal` / `tree-relation` in FIELD_FORMAT_TYPE)
10
+ # is tracked separately, see HAB-708 section 6.
11
+ module Types
12
+
13
+ # Four lists below are deliberately *not* frozen and carry a `Style/MutableConstant` disable:
14
+ # `Types.register` appends to them when a pro/enterprise gem contributes a value (HAB-812).
15
+ # Freezing them would make that extension point impossible. Every other list is frozen,
16
+ # because it mirrors a closed enum of the OpenAPI contract that nothing may widen.
17
+
18
+ # ColorType - MUI colour palette shared by actions, action descriptors and enum items
19
+ COLOR_TYPE = %i[primary secondary success error warning info inherit].freeze
20
+
21
+ # FieldType - data type of a field or filter
22
+ FIELD_TYPE = %i[string number integer boolean array object] # rubocop:disable Style/MutableConstant
23
+
24
+ # FieldFormatType - format applied to a field or filter on top of its data type
25
+ # rubocop:disable-next Style/MutableConstant
26
+ FIELD_FORMAT_TYPE = %i[date date-time time text rich-text email url password
27
+ base64-image base64-file uuid relation choices search phone
28
+ czech-bank-account czech-ico czech-dic czech-birth-number
29
+ ai ai-text range]
30
+
31
+ # BoxType - layout container types
32
+ BOX_TYPE = %i[tab tab-item wizard simple list object array grid grid-item gallery] # rubocop:disable Style/MutableConstant
33
+
34
+ # ViewType - kind of the view
35
+ VIEW_TYPE = %i[list show create edit action].freeze
36
+
37
+ # ViewModeType - how a view is presented when opened by a trigger
38
+ VIEW_MODE_TYPE = %i[redirect dialog sidepanel].freeze
39
+
40
+ # ActionType - kind of the action
41
+ ACTION_TYPE = %i[view link resource save upload-images] # rubocop:disable Style/MutableConstant
42
+
43
+ # MenuType - kind of the menu item
44
+ MENU_TYPE = %i[link view text].freeze
45
+
46
+ # RequestMethodType - HTTP method of an endpoint
47
+ REQUEST_METHOD_TYPE = %i[get post patch put delete].freeze
48
+
49
+ # SortDirectionType - direction of a sort descriptor
50
+ SORT_DIRECTION_TYPE = %i[asc desc].freeze
51
+
52
+ # LinkTargetType - where a link action opens
53
+ LINK_TARGET_TYPE = %i[self blank].freeze
54
+
55
+ # TextAlignType - horizontal alignment of a field value
56
+ TEXT_ALIGN_TYPE = %i[left center right].freeze
57
+
58
+ # *************************************************************************
59
+ # Extension point: registering additional values (HAB-812)
60
+ # *************************************************************************
61
+
62
+ # Lists a pro/enterprise gem may extend. The rest stay frozen: they mirror a closed enum of
63
+ # the OpenAPI contract (`doc/openapi.yaml`) that no gem may widen on its own.
64
+ #
65
+ # The whole vocabulary stays in the free core - including values with no Ruby implementation
66
+ # yet (`upload-images`, `ai`, `ai-text`). The names are a contract shared with the frontend;
67
+ # what is paid is the implementation behind them, not the name.
68
+ EXTENSIBLE = %i[FIELD_TYPE FIELD_FORMAT_TYPE BOX_TYPE ACTION_TYPE].freeze
69
+
70
+ class << self
71
+ # Schema classes whose `enum_attr` was declared from a list, as
72
+ # `{ list_name => [[klass, attr_name], ...] }`. Filled by `ExtensibleEnum`.
73
+ def consumers
74
+ @consumers ||= Hash.new { |hash, key| hash[key] = [] }
75
+ end
76
+
77
+ # Add values to an extensible list and re-declare the enum on every schema class built from
78
+ # it. The re-declaration is what makes this work at all: `enum_attr` copies the choices into
79
+ # the class when it is called, so appending to the array alone would change nothing.
80
+ #
81
+ # Habarico::Types.register(:FIELD_FORMAT_TYPE, :signature)
82
+ #
83
+ # Raises when the list is not extensible or the value is already there.
84
+ def register(list_name, *values)
85
+ list_name = list_name.to_sym
86
+ unless EXTENSIBLE.include?(list_name)
87
+ raise ArgumentError, "#{list_name} is not extensible. Extensible lists: #{EXTENSIBLE.join(', ')}."
88
+ end
89
+
90
+ list = const_get(list_name)
91
+ values.map!(&:to_sym)
92
+ duplicates = values & list
93
+ raise ArgumentError, "#{list_name} already contains #{duplicates.join(', ')}." if duplicates.any?
94
+
95
+ list.concat(values)
96
+ consumers[list_name].each { |klass, attr_name| klass.enum_attr(attr_name, list) }
97
+ list
98
+ end
99
+ end
100
+
101
+ end
102
+ end
@@ -0,0 +1,30 @@
1
+ module Habarico
2
+ class ActionDescriptor
3
+ include ::ActiveModel::Model
4
+ include Eluvia::ActiveModel::Attributes
5
+ include Eluvia::ActiveModel::EnumAttribute
6
+
7
+ # Name of the action, used for coupling with resource action schema
8
+ string_attr :name
9
+
10
+ # Override for `label` from action schema
11
+ string_attr :label
12
+
13
+ # Override for `icon` from action schema
14
+ string_attr :icon
15
+
16
+ # Override for `color` from action schema
17
+ string_attr :color
18
+ enum_attr :color, Types::COLOR_TYPE
19
+
20
+ # Special action in case no resource action schema is coupled
21
+ has_one_attr :action, 'Habarico::ActionSchema'
22
+
23
+ # View parameters for the action descriptor (mode, choices, parameters)
24
+ has_one_attr :view, 'Habarico::ViewActionDescriptorParameters'
25
+
26
+ # Nested menu items for dropdown/submenu actions
27
+ has_many_attr :menu_items, 'Habarico::ActionDescriptor'
28
+
29
+ end
30
+ end
@@ -0,0 +1,13 @@
1
+ module Habarico
2
+ class ArrayBoxParameters
3
+ include ::ActiveModel::Model
4
+ include Eluvia::ActiveModel::Attributes
5
+
6
+ # Name of the attribute to be used as target for array operations
7
+ string_attr :target
8
+
9
+ # Whether to render the array box inline
10
+ boolean_attr :inline
11
+
12
+ end
13
+ end
@@ -0,0 +1,67 @@
1
+ module Habarico
2
+ class BoxSchema
3
+ include ::ActiveModel::Model
4
+ include Eluvia::ActiveModel::Attributes
5
+ include Eluvia::ActiveModel::EnumAttribute
6
+ include Habarico::ExtensibleEnum
7
+
8
+ intended_for_types *Types::BOX_TYPE
9
+
10
+ # Type of the box
11
+ string_attr :type
12
+ extensible_enum_attr :type, :BOX_TYPE
13
+
14
+ # Name of the box
15
+ string_attr :name
16
+
17
+ # Human-readable label of the box
18
+ string_attr :label
19
+
20
+ # List of child boxes and fields (polymorphic: FieldDescriptor | BoxSchema)
21
+ has_many_attr :boxes, ['Habarico::FieldDescriptor', 'Habarico::BoxSchema'], default: 'Habarico::BoxSchema'
22
+
23
+ # Flag indicating if the box is or is not editable
24
+ boolean_attr :read_only
25
+
26
+ # Flag indicating if the box is or is not wrapped in a card UI element
27
+ boolean_attr :card
28
+
29
+ # Makes the box collapsible; value sets the default state ('open' = expanded, 'closed' = collapsed).
30
+ # Null means the box is not collapsible.
31
+ string_attr :collapsible
32
+ enum_attr :collapsible, %i[open closed]
33
+
34
+ # Actions rendered in this box's local toolbar (box header / card header area), relative to the box root.
35
+ # On a step container (tab/wizard) the actions appear on the last step. For a 'list' box this is the box-level
36
+ # toolbar; the table's own toolbar is carried by 'list.toolbar_actions' instead.
37
+ has_many_attr :toolbar_actions, 'Habarico::ActionDescriptor'
38
+
39
+ # Actions rendered at the bottom of the box, below the fields (similar to form submit buttons at the view level).
40
+ has_many_attr :bottom_actions, 'Habarico::ActionDescriptor'
41
+
42
+ # Additional parameters for box type 'tab'
43
+ has_one_attr :tab, 'Habarico::TabBoxParameters'
44
+
45
+ # Additional parameters for box type 'wizard'
46
+ has_one_attr :wizard, 'Habarico::WizardBoxParameters'
47
+
48
+ # Additional parameters for box type 'grid-item'
49
+ has_one_attr :grid_item, 'Habarico::GridItemBoxParameters'
50
+
51
+ # Additional parameters for box type 'list'
52
+ has_one_attr :list, 'Habarico::ListBoxParameters'
53
+
54
+ # Additional parameters for box type 'array'
55
+ has_one_attr :array, 'Habarico::ArrayBoxParameters'
56
+
57
+ # Additional parameters for box type 'object'
58
+ has_one_attr :object, 'Habarico::ObjectBoxParameters'
59
+
60
+ # Additional parameters for box type 'gallery'
61
+ has_one_attr :gallery, 'Habarico::GalleryBoxParameters'
62
+
63
+ # Additional options for the box (e.g. dynamic rendering)
64
+ has_one_attr :options, 'Habarico::BoxOptions'
65
+
66
+ end
67
+ end
@@ -0,0 +1,16 @@
1
+ module Habarico
2
+ class DetailViewParameters
3
+ include ::ActiveModel::Model
4
+ include Eluvia::ActiveModel::Attributes
5
+
6
+ # Definition of a main box
7
+ has_one_attr :box, 'Habarico::BoxSchema'
8
+
9
+ # In case we don't want to show the default set of resource actions, a custom set of action descriptors can be provided and displayed in the tollbar
10
+ has_many_attr :toolbar_actions, 'Habarico::ActionDescriptor'
11
+
12
+ # A set of action descriptors can be provided and displayed under the detail box / form
13
+ has_many_attr :bottom_actions, 'Habarico::ActionDescriptor'
14
+
15
+ end
16
+ end
@@ -0,0 +1,50 @@
1
+ module Habarico
2
+ class FieldDescriptor
3
+ include ::ActiveModel::Model
4
+ include Eluvia::ActiveModel::Attributes
5
+ include Eluvia::ActiveModel::EnumAttribute
6
+
7
+ intended_for_types :field
8
+
9
+ # Type of the descriptor, always 'field'
10
+ string_attr :type
11
+ enum_attr :type, [:field]
12
+
13
+ # Name of the field in the data model, used for coupling with field schema
14
+ string_attr :name
15
+
16
+ # Override for `label` from field schema
17
+ string_attr :label
18
+
19
+ # Override for `short_label` from field schema
20
+ string_attr :short_label
21
+
22
+ # Override for `help_text` from field schema
23
+ string_attr :help_text
24
+
25
+ # Override for `sortable` from field schema
26
+ boolean_attr :sortable
27
+
28
+ # Override for `sort_by` from field schema
29
+ string_attr :sort_by
30
+
31
+ # Override for `read_only` from field schema
32
+ boolean_attr :read_only
33
+
34
+ # Override for `write_only` from field schema
35
+ boolean_attr :write_only
36
+
37
+ # Override for `default_value` from field schema
38
+ any_attr :default_value
39
+
40
+ # Action to trigger when the field value is clicked
41
+ has_one_attr :action, 'Habarico::ActionDescriptor'
42
+
43
+ # Wrapper properties for grouping multiple fields in one column
44
+ has_one_attr :wrapper, 'Habarico::FieldWrapperProperties'
45
+
46
+ # Override for `options` from field schema
47
+ has_one_attr :options, 'Habarico::FieldOptions'
48
+
49
+ end
50
+ end
@@ -0,0 +1,13 @@
1
+ module Habarico
2
+ class FieldWrapperProperties
3
+ include ::ActiveModel::Model
4
+ include Eluvia::ActiveModel::Attributes
5
+
6
+ # Fields of the wrapper
7
+ has_many_attr :fields, 'Habarico::FieldDescriptor'
8
+
9
+ # Divider between fields
10
+ string_attr :divider
11
+
12
+ end
13
+ end
@@ -0,0 +1,24 @@
1
+ module Habarico
2
+ class FilterDescriptor
3
+ include ::ActiveModel::Model
4
+ include Eluvia::ActiveModel::Attributes
5
+
6
+ # Name of the filter in API, used for coupling with filter schema
7
+ string_attr :name
8
+
9
+ # Override for `label` from filter schema
10
+ string_attr :label
11
+
12
+ # Override for `help_text` from filter schema
13
+ string_attr :help_text
14
+
15
+ # Override for `is_always_on` from filter schema
16
+ boolean_attr :is_always_on
17
+
18
+ # Override for `default_value` from filter schema
19
+ any_attr :default_value
20
+
21
+ # TODO options
22
+
23
+ end
24
+ end
@@ -0,0 +1,31 @@
1
+ module Habarico
2
+ class GalleryBoxParameters
3
+ include ::ActiveModel::Model
4
+ include Eluvia::ActiveModel::Attributes
5
+
6
+ # Reference to another resource
7
+ string_attr :reference
8
+
9
+ # Name of the field containing the image ({url, filename})
10
+ string_attr :image_field
11
+
12
+ # Human-readable label of the box
13
+ string_attr :label
14
+
15
+ # Name of the attribute in the referenced resource used as the coupling value
16
+ string_attr :target
17
+
18
+ # List of filters to be displayed / available to the gallery
19
+ has_many_attr :filters, 'Habarico::FilterDescriptor'
20
+
21
+ # Default sorting for the gallery
22
+ has_one_attr :default_sorting, 'Habarico::SortDescriptor'
23
+
24
+ # Additional filters to be applied to the gallery by default
25
+ any_attr :extra_filters
26
+
27
+ # Additional parameters sent with the get schema request
28
+ has_many_attr :schema_params, 'String', underlying_type: :hash
29
+
30
+ end
31
+ end
@@ -0,0 +1,25 @@
1
+ module Habarico
2
+ class GlobalViewSchema
3
+ include ::ActiveModel::Model
4
+ include Eluvia::ActiveModel::Attributes
5
+ include Eluvia::ActiveModel::EnumAttribute
6
+
7
+ # Name of the view, usually "list", "show", "create", "edit"
8
+ string_attr :name
9
+
10
+ # Type of the view
11
+ string_attr :type
12
+ enum_attr :type, Types::VIEW_TYPE
13
+
14
+ # Flag indicating if the view is detail (uses primary key)
15
+ boolean_attr :is_detail
16
+
17
+ # Default presentation mode when a trigger opens this view without its own mode.
18
+ # When omitted, the frontend falls back to `redirect`.
19
+ string_attr :mode
20
+ enum_attr :mode, Types::VIEW_MODE_TYPE
21
+
22
+ # Definition of the endpoint
23
+ has_one_attr :endpoint, 'Habarico::ViewEndpointParameters'
24
+ end
25
+ end
@@ -0,0 +1,13 @@
1
+ module Habarico
2
+ class GridItemBoxParameters
3
+ include ::ActiveModel::Model
4
+ include Eluvia::ActiveModel::Attributes
5
+
6
+ integer_attr :xs
7
+ integer_attr :sm
8
+ integer_attr :md
9
+ integer_attr :lg
10
+ integer_attr :xl
11
+
12
+ end
13
+ end
@@ -0,0 +1,44 @@
1
+ module Habarico
2
+ class ListBoxParameters
3
+ include ::ActiveModel::Model
4
+ include Eluvia::ActiveModel::Attributes
5
+
6
+ # Reference to another resource
7
+ string_attr :reference
8
+
9
+ # Name of the attribute in the references resource to use as the coupling value
10
+ string_attr :target
11
+
12
+ # Additional filters to be applied to the list by default, can be used instead of target
13
+ any_attr :extra_filters
14
+
15
+ # List of filters to be displayed / available to the list
16
+ has_many_attr :filters, 'Habarico::FilterDescriptor'
17
+
18
+ # In case we don't want to show the default set of resource actions, a custom set of action descriptors can be provided and displayed in each row
19
+ has_many_attr :row_actions, 'Habarico::ActionDescriptor'
20
+
21
+ # Actions rendered in the table's own toolbar (top of the resource list, e.g. create), separate from the
22
+ # box-level toolbar which belongs to the box root
23
+ has_many_attr :toolbar_actions, 'Habarico::ActionDescriptor'
24
+
25
+ # Utility actions of the table (export, print, ...) rendered next to the filter bar, separate from row and toolbar actions
26
+ has_many_attr :list_actions, 'Habarico::ActionDescriptor'
27
+
28
+ # Default sorting for the list
29
+ has_one_attr :default_sorting, 'Habarico::SortDescriptor'
30
+
31
+ # Drag & drop sortable configuration
32
+ has_one_attr :sortable, 'Habarico::SortableParameters'
33
+
34
+ # Additional parameters sent with the get schema request
35
+ has_many_attr :schema_params, 'String', underlying_type: :hash
36
+
37
+ # Action to activate on a single row click (e.g. open a record preview in a side panel)
38
+ has_one_attr :single_click_action, 'Habarico::ActionDescriptor'
39
+
40
+ # Action to activate on a row double-click
41
+ has_one_attr :double_click_action, 'Habarico::ActionDescriptor'
42
+
43
+ end
44
+ end
@@ -0,0 +1,31 @@
1
+ module Habarico
2
+ class ListViewParameters
3
+ include ::ActiveModel::Model
4
+ include Eluvia::ActiveModel::Attributes
5
+
6
+ # List of fields to be displayed / available in the list
7
+ has_many_attr :boxes, 'Habarico::FieldDescriptor'
8
+
9
+ # List of filters to be displayed / available to the list
10
+ has_many_attr :filters, 'Habarico::FilterDescriptor'
11
+
12
+ # In case we don't want to show the default set of resource actions, a custom set of action descriptors can be provided and displayed in each row
13
+ has_many_attr :row_actions, 'Habarico::ActionDescriptor'
14
+
15
+ # In case we don't want to show the default set of resource actions, a custom set of action descriptors can be provided and displayed in the tollbar
16
+ has_many_attr :toolbar_actions, 'Habarico::ActionDescriptor'
17
+
18
+ # Utility actions of the table (export, print, ...) rendered next to the filter bar, separate from row and toolbar actions
19
+ has_many_attr :list_actions, 'Habarico::ActionDescriptor'
20
+
21
+ # Default sorting for the list
22
+ has_one_attr :default_sorting, 'Habarico::SortDescriptor'
23
+
24
+ # Action to activate on a single row click (e.g. open a record preview in a side panel)
25
+ has_one_attr :single_click_action, 'Habarico::ActionDescriptor'
26
+
27
+ # Action to activate on a row double-click
28
+ has_one_attr :double_click_action, 'Habarico::ActionDescriptor'
29
+
30
+ end
31
+ end
@@ -0,0 +1,10 @@
1
+ module Habarico
2
+ class ObjectBoxParameters
3
+ include ::ActiveModel::Model
4
+ include Eluvia::ActiveModel::Attributes
5
+
6
+ # Name of the nested serializer field used as the target for object operations
7
+ string_attr :target
8
+
9
+ end
10
+ end
@@ -0,0 +1,15 @@
1
+ module Habarico
2
+ class SortDescriptor
3
+ include ::ActiveModel::Model
4
+ include Eluvia::ActiveModel::Attributes
5
+ include Eluvia::ActiveModel::EnumAttribute
6
+
7
+ # Name of the field to sort by
8
+ string_attr :field_name
9
+
10
+ # Direction of the sort
11
+ string_attr :direction
12
+ enum_attr :direction, Types::SORT_DIRECTION_TYPE
13
+
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ module Habarico
2
+ class SortableParameters
3
+ include ::ActiveModel::Model
4
+ include Eluvia::ActiveModel::Attributes
5
+
6
+ # Name of the field to sort by when drag-and-drop reordering
7
+ string_attr :field_name
8
+
9
+ # Additional filters to scope the sortable operation (e.g. group by parent)
10
+ any_attr :sort_for_filters
11
+
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ module Habarico
2
+ class TabBoxParameters
3
+ include ::ActiveModel::Model
4
+ include Eluvia::ActiveModel::Attributes
5
+
6
+ # Show previous/next navigation buttons in the box toolbar
7
+ boolean_attr :show_toolbar_navigation
8
+
9
+ end
10
+ end
@@ -0,0 +1,21 @@
1
+ module Habarico
2
+ class ViewActionDescriptorParameters
3
+ include ::ActiveModel::Model
4
+ include Eluvia::ActiveModel::Attributes
5
+ include Eluvia::ActiveModel::EnumAttribute
6
+
7
+ # Mode in which to display the action view: redirect to a standalone page, dialog, or side panel
8
+ string_attr :mode
9
+ enum_attr :mode, Types::VIEW_MODE_TYPE
10
+
11
+ # View choices for the action
12
+ has_many_attr :choices, 'Habarico::ActionViewChoice'
13
+
14
+ # Additional parameters for the view
15
+ has_many_attr :parameters, 'String', underlying_type: :hash
16
+
17
+ # Keep linked parent in the URL when navigating to the linked resource
18
+ boolean_attr :keep_linked_parent
19
+
20
+ end
21
+ end
@@ -0,0 +1,22 @@
1
+ module Habarico
2
+ class ViewEndpointParameters
3
+ include ::ActiveModel::Model
4
+ include Eluvia::ActiveModel::Attributes
5
+ include Eluvia::ActiveModel::EnumAttribute
6
+
7
+ # Path of the endpoint to call. Only set when the standard resource path is not used, i.e. for
8
+ # action views; for the standard views the frontend derives the path from the resource itself.
9
+ string_attr :path
10
+
11
+ # HTTP method for the requested endpoint
12
+ string_attr :method
13
+ enum_attr :method, Types::REQUEST_METHOD_TYPE
14
+
15
+ # Reference to another resource, if applicable
16
+ string_attr :reference
17
+
18
+ # Name of the controller action associated with the endpoint, if applicable
19
+ string_attr :action_name
20
+
21
+ end
22
+ end
@@ -0,0 +1,33 @@
1
+ module Habarico
2
+ class ViewSchema
3
+ include ::ActiveModel::Model
4
+ include Eluvia::ActiveModel::Attributes
5
+ include Eluvia::ActiveModel::EnumAttribute
6
+
7
+ # Name of the view, usually "list", "show", "create", "edit"
8
+ string_attr :name
9
+
10
+ # Type of the view
11
+ string_attr :type
12
+ enum_attr :type, Types::VIEW_TYPE
13
+
14
+ # Flag indicating if the view is detail (uses primary key)
15
+ boolean_attr :is_detail
16
+
17
+ # Human-readable label of the view
18
+ string_attr :label
19
+
20
+ # Definition of the list, applicable for list views
21
+ has_one_attr :list, 'Habarico::ListViewParameters'
22
+
23
+ # Definition of the detail, applicable for detail views
24
+ has_one_attr :detail, 'Habarico::DetailViewParameters'
25
+
26
+ # Definition of the endpoint
27
+ has_one_attr :endpoint, 'Habarico::ViewEndpointParameters'
28
+
29
+ # Breadcrumbs for navigation in case we need not standard ones
30
+ has_many_attr :breadcrumbs, 'Habarico::MenuSchema'
31
+
32
+ end
33
+ end