avo 2.7.1.pre.1 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of avo might be problematic. Click here for more details.

Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +5 -5
  4. data/app/components/avo/alert_component.rb +6 -0
  5. data/app/components/avo/card_component.html.erb +2 -2
  6. data/app/components/avo/common_field_wrapper_component.html.erb +10 -3
  7. data/app/components/avo/common_field_wrapper_component.rb +27 -1
  8. data/app/components/avo/edit/field_wrapper_component.html.erb +1 -1
  9. data/app/components/avo/fields/badge_field/index_component.html.erb +1 -1
  10. data/app/components/avo/fields/badge_field/show_component.html.erb +1 -1
  11. data/app/components/avo/fields/belongs_to_field/autocomplete_component.html.erb +21 -10
  12. data/app/components/avo/fields/belongs_to_field/autocomplete_component.rb +7 -1
  13. data/app/components/avo/fields/belongs_to_field/edit_component.html.erb +27 -15
  14. data/app/components/avo/fields/belongs_to_field/edit_component.rb +4 -0
  15. data/app/components/avo/fields/belongs_to_field/index_component.html.erb +1 -1
  16. data/app/components/avo/fields/belongs_to_field/show_component.html.erb +1 -1
  17. data/app/components/avo/fields/boolean_field/edit_component.html.erb +4 -2
  18. data/app/components/avo/fields/boolean_field/index_component.html.erb +1 -1
  19. data/app/components/avo/fields/boolean_field/show_component.html.erb +1 -1
  20. data/app/components/avo/fields/boolean_group_field/edit_component.html.erb +7 -1
  21. data/app/components/avo/fields/boolean_group_field/index_component.html.erb +1 -1
  22. data/app/components/avo/fields/boolean_group_field/show_component.html.erb +1 -1
  23. data/app/components/avo/fields/code_field/edit_component.html.erb +7 -5
  24. data/app/components/avo/fields/code_field/show_component.html.erb +2 -2
  25. data/app/components/avo/fields/common/key_value_component.html.erb +10 -4
  26. data/app/components/avo/fields/common/key_value_component.rb +2 -0
  27. data/app/components/avo/fields/country_field/edit_component.html.erb +4 -2
  28. data/app/components/avo/fields/country_field/index_component.html.erb +1 -1
  29. data/app/components/avo/fields/country_field/show_component.html.erb +1 -1
  30. data/app/components/avo/fields/date_field/edit_component.html.erb +6 -4
  31. data/app/components/avo/fields/date_field/index_component.html.erb +1 -1
  32. data/app/components/avo/fields/date_field/show_component.html.erb +1 -1
  33. data/app/components/avo/fields/date_time_field/edit_component.html.erb +6 -4
  34. data/app/components/avo/fields/date_time_field/index_component.html.erb +1 -1
  35. data/app/components/avo/fields/date_time_field/show_component.html.erb +1 -1
  36. data/app/components/avo/fields/edit_component.rb +7 -0
  37. data/app/components/avo/fields/external_image_field/edit_component.html.erb +5 -2
  38. data/app/components/avo/fields/external_image_field/index_component.html.erb +6 -4
  39. data/app/components/avo/fields/external_image_field/show_component.html.erb +1 -1
  40. data/app/components/avo/fields/file_field/edit_component.html.erb +6 -1
  41. data/app/components/avo/fields/file_field/index_component.html.erb +1 -1
  42. data/app/components/avo/fields/file_field/show_component.html.erb +1 -1
  43. data/app/components/avo/fields/files_field/edit_component.html.erb +7 -1
  44. data/app/components/avo/fields/files_field/index_component.html.erb +1 -1
  45. data/app/components/avo/fields/files_field/show_component.html.erb +1 -1
  46. data/app/components/avo/fields/gravatar_field/index_component.html.erb +1 -1
  47. data/app/components/avo/fields/gravatar_field/show_component.html.erb +1 -1
  48. data/app/components/avo/fields/has_one_field/index_component.html.erb +1 -1
  49. data/app/components/avo/fields/hidden_field/edit_component.html.erb +5 -1
  50. data/app/components/avo/fields/id_field/edit_component.html.erb +1 -1
  51. data/app/components/avo/fields/id_field/index_component.html.erb +1 -1
  52. data/app/components/avo/fields/id_field/show_component.html.erb +1 -1
  53. data/app/components/avo/fields/index_component.rb +3 -0
  54. data/app/components/avo/fields/key_value_field/edit_component.html.erb +1 -1
  55. data/app/components/avo/fields/key_value_field/show_component.html.erb +1 -1
  56. data/app/components/avo/fields/markdown_field/edit_component.html.erb +8 -5
  57. data/app/components/avo/fields/markdown_field/show_component.html.erb +1 -1
  58. data/app/components/avo/fields/number_field/edit_component.html.erb +7 -4
  59. data/app/components/avo/fields/number_field/index_component.html.erb +1 -1
  60. data/app/components/avo/fields/number_field/show_component.html.erb +1 -1
  61. data/app/components/avo/fields/password_field/edit_component.html.erb +4 -2
  62. data/app/components/avo/fields/progress_bar_field/edit_component.html.erb +7 -4
  63. data/app/components/avo/fields/progress_bar_field/index_component.html.erb +1 -1
  64. data/app/components/avo/fields/progress_bar_field/show_component.html.erb +1 -1
  65. data/app/components/avo/fields/select_field/edit_component.html.erb +9 -3
  66. data/app/components/avo/fields/select_field/index_component.html.erb +1 -1
  67. data/app/components/avo/fields/select_field/show_component.html.erb +1 -1
  68. data/app/components/avo/fields/show_component.rb +3 -0
  69. data/app/components/avo/fields/status_field/edit_component.html.erb +6 -3
  70. data/app/components/avo/fields/status_field/index_component.html.erb +1 -1
  71. data/app/components/avo/fields/status_field/show_component.html.erb +1 -1
  72. data/app/components/avo/fields/tags_field/edit_component.html.erb +19 -11
  73. data/app/components/avo/fields/tags_field/index_component.html.erb +1 -1
  74. data/app/components/avo/fields/tags_field/show_component.html.erb +1 -1
  75. data/app/components/avo/fields/text_field/edit_component.html.erb +5 -2
  76. data/app/components/avo/fields/text_field/index_component.html.erb +1 -1
  77. data/app/components/avo/fields/text_field/show_component.html.erb +1 -1
  78. data/app/components/avo/fields/textarea_field/edit_component.html.erb +6 -3
  79. data/app/components/avo/fields/textarea_field/show_component.html.erb +1 -1
  80. data/app/components/avo/fields/trix_field/edit_component.html.erb +13 -4
  81. data/app/components/avo/fields/trix_field/edit_component.rb +3 -0
  82. data/app/components/avo/fields/trix_field/show_component.html.erb +1 -1
  83. data/app/components/avo/index/field_wrapper_component.html.erb +12 -5
  84. data/app/components/avo/index/field_wrapper_component.rb +27 -3
  85. data/app/components/avo/panel_component.rb +4 -3
  86. data/app/components/avo/resource_component.rb +1 -0
  87. data/app/components/avo/show/field_wrapper_component.html.erb +1 -1
  88. data/app/components/avo/show/field_wrapper_component.rb +2 -1
  89. data/app/components/avo/views/resource_edit_component.html.erb +7 -4
  90. data/app/components/avo/views/resource_edit_component.rb +2 -1
  91. data/app/components/avo/views/resource_index_component.html.erb +6 -3
  92. data/app/components/avo/views/resource_index_component.rb +7 -1
  93. data/app/components/avo/views/resource_new_component.html.erb +7 -2
  94. data/app/components/avo/views/resource_new_component.rb +2 -1
  95. data/app/components/avo/views/resource_show_component.html.erb +9 -7
  96. data/app/components/avo/views/resource_show_component.rb +1 -0
  97. data/app/controllers/avo/actions_controller.rb +4 -1
  98. data/app/controllers/avo/base_controller.rb +14 -8
  99. data/app/controllers/avo/search_controller.rb +7 -1
  100. data/app/javascript/js/controllers/custom/course_resource_controller.js +102 -0
  101. data/app/javascript/js/controllers/fields/code_field_controller.js +7 -1
  102. data/app/javascript/js/controllers/fields/key_value_controller.js +1 -0
  103. data/app/javascript/js/controllers/fields/tags_field_controller.js +0 -1
  104. data/app/javascript/js/controllers/menu_controller.js +4 -3
  105. data/app/javascript/js/controllers/resource_edit_controller.js +72 -0
  106. data/app/javascript/js/controllers/resource_index_controller.js +4 -0
  107. data/app/javascript/js/controllers/resource_show_controller.js +4 -0
  108. data/app/javascript/js/controllers/search_controller.js +28 -5
  109. data/app/javascript/js/controllers.js +10 -0
  110. data/app/views/avo/associations/new.html.erb +2 -1
  111. data/app/views/avo/base/_select_filter.html.erb +1 -1
  112. data/app/views/avo/base/_text_filter.html.erb +1 -0
  113. data/app/views/avo/partials/_logo.html.erb +3 -2
  114. data/app/views/avo/partials/_navbar.html.erb +1 -1
  115. data/config/routes.rb +1 -1
  116. data/db/factories.rb +1 -0
  117. data/lib/avo/base_action.rb +9 -2
  118. data/lib/avo/base_card.rb +0 -23
  119. data/lib/avo/base_resource.rb +17 -15
  120. data/lib/avo/concerns/has_fields.rb +93 -0
  121. data/lib/avo/concerns/has_html_attributes.rb +110 -0
  122. data/lib/avo/concerns/has_stimulus_controllers.rb +42 -0
  123. data/lib/avo/fields/base_field.rb +23 -13
  124. data/lib/avo/fields/select_field.rb +1 -1
  125. data/lib/avo/grid_collector.rb +4 -4
  126. data/lib/avo/html/builder.rb +117 -0
  127. data/lib/avo/licensing/pro_license.rb +1 -0
  128. data/lib/avo/version.rb +1 -1
  129. data/lib/avo.rb +4 -0
  130. data/lib/generators/avo/templates/cards/chartkick_card_sample.tt +11 -1
  131. data/lib/generators/avo/templates/cards/metric_card_sample.tt +11 -1
  132. data/lib/generators/avo/templates/field/components/edit_component.html.erb.tt +1 -1
  133. data/lib/generators/avo/templates/field/components/index_component.html.erb.tt +1 -1
  134. data/lib/generators/avo/templates/field/components/show_component.html.erb.tt +1 -1
  135. data/lib/generators/avo/templates/initializer/avo.tt +1 -1
  136. data/lib/generators/avo/templates/locales/avo.en.yml +3 -3
  137. data/public/avo-assets/avo.css +28 -8
  138. data/public/avo-assets/avo.js +148 -148
  139. data/public/avo-assets/avo.js.map +3 -3
  140. data/public/avo-assets/logomark.png +0 -0
  141. metadata +13 -10
  142. data/app/assets/builds/action_cable.js +0 -2
  143. data/app/assets/builds/action_cable.js.map +0 -7
  144. data/app/assets/builds/avo.css +0 -9610
  145. data/app/assets/builds/avo.js +0 -512
  146. data/app/assets/builds/avo.js.map +0 -7
  147. data/lib/avo/fields_collector.rb +0 -70
@@ -1,70 +0,0 @@
1
- module Avo
2
- module FieldsCollector
3
- def field(field_name, as:, **args, &block)
4
- self.fields ||= []
5
- self.invalid_fields ||= []
6
-
7
- field_instance = parse_field(field_name, as: as, **args, &block)
8
-
9
- if field_instance.present?
10
- self.fields << field_instance
11
- else
12
- self.invalid_fields << ({
13
- name: field_name,
14
- as: as,
15
- resource: name,
16
- message: "There's an invalid field configuration for this resource. <br/> <code class='px-1 py-px rounded bg-red-600'>field :#{field_name}, as: #{as}</code>"
17
- })
18
- end
19
- end
20
-
21
- def parse_field(field_name, as:, **args, &block)
22
- # The field is passed as a symbol eg: :text, :color_picker, :trix
23
- if as.is_a? Symbol
24
- field_class = field_class_from_symbol(as)
25
-
26
- if field_class.present?
27
- # The field has been registered before.
28
- instantiate_field(field_name, klass: field_class, **args, &block)
29
- else
30
- # The symbol can be transformed to a class and found.
31
- class_name = as.to_s.camelize
32
- field_class = "#{class_name}Field"
33
-
34
- # Discover & load custom field classes
35
- if Object.const_defined? field_class
36
- instantiate_field(field_name, klass: field_class.safe_constantize, **args, &block)
37
- end
38
- end
39
- elsif as.is_a? Class
40
- # The field has been passed as a class.
41
- if Object.const_defined? as.to_s
42
- instantiate_field(field_name, klass: as, **args, &block)
43
- end
44
- end
45
- end
46
-
47
- def heading(body, **args)
48
- self.fields ||= []
49
- self.fields << Avo::Fields::HeadingField.new(body, **args)
50
- end
51
-
52
- private
53
-
54
- def instantiate_field(field_name, klass:, **args, &block)
55
- if block
56
- klass.new(field_name, **args || {}, &block)
57
- else
58
- klass.new(field_name, **args || {})
59
- end
60
- end
61
-
62
- def field_class_from_symbol(symbol)
63
- matched_field = Avo::App.fields.find do |field|
64
- field[:name].to_s == symbol.to_s
65
- end
66
-
67
- return matched_field[:class] if matched_field.present? && matched_field[:class].present?
68
- end
69
- end
70
- end