avo 0.5.0.beta1 → 0.5.0.beta6

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 (148) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -4
  3. data/Gemfile.lock +1 -5
  4. data/README.md +4 -0
  5. data/app/components/avo/index/grid_item_component.html.erb +8 -8
  6. data/app/components/avo/index/grid_item_component.rb +6 -12
  7. data/app/components/avo/index/resource_controls_component.html.erb +1 -1
  8. data/app/components/avo/index/resource_grid_component.html.erb +1 -1
  9. data/app/components/avo/index/resource_table_component.html.erb +2 -2
  10. data/app/components/avo/index/table_row_component.html.erb +1 -1
  11. data/app/controllers/avo/actions_controller.rb +2 -4
  12. data/app/controllers/avo/application_controller.rb +6 -3
  13. data/app/controllers/avo/base_controller.rb +10 -7
  14. data/app/controllers/avo/relations_controller.rb +1 -1
  15. data/app/controllers/avo/search_controller.rb +1 -1
  16. data/app/frontend/packs/application.js +1 -1
  17. data/app/views/avo/base/_actions.html.erb +1 -7
  18. data/app/views/avo/base/_boolean_filter.html.erb +1 -1
  19. data/app/views/avo/base/_filters.html.erb +3 -11
  20. data/app/views/avo/base/_select_filter.html.erb +1 -1
  21. data/app/views/avo/home/_resources.html.erb +0 -1
  22. data/app/views/avo/partials/_table_header.html.erb +1 -1
  23. data/app/views/avo/sidebar/_sidebar.html.erb +1 -1
  24. data/app/views/layouts/avo/_filter_wrapper.html.erb +1 -1
  25. data/app/views/layouts/avo/application.html.erb +5 -0
  26. data/avo.gemspec +0 -1
  27. data/config/webpacker.yml +10 -23
  28. data/lib/avo.rb +5 -16
  29. data/lib/avo/app.rb +190 -0
  30. data/lib/avo/base_action.rb +123 -0
  31. data/lib/avo/base_resource.rb +323 -0
  32. data/lib/avo/configuration.rb +8 -0
  33. data/lib/avo/engine.rb +12 -31
  34. data/lib/avo/{app/fields → fields}/badge_field.rb +1 -1
  35. data/lib/avo/{app/fields/field.rb → fields/base_field.rb} +3 -7
  36. data/lib/avo/{app/fields/belongs_to.rb → fields/belongs_to_field.rb} +3 -3
  37. data/lib/avo/{app/fields → fields}/boolean_field.rb +1 -1
  38. data/lib/avo/{app/fields → fields}/boolean_group_field.rb +1 -1
  39. data/lib/avo/{app/fields → fields}/code_field.rb +1 -1
  40. data/lib/avo/{app/fields → fields}/country_field.rb +1 -1
  41. data/lib/avo/{app/fields → fields}/currency_field.rb +1 -1
  42. data/lib/avo/{app/fields → fields}/date_field.rb +0 -2
  43. data/lib/avo/{app/fields → fields}/date_time_field.rb +0 -2
  44. data/lib/avo/{app/fields → fields}/external_image_field.rb +5 -4
  45. data/lib/avo/{app/fields → fields}/field_extensions/has_field_name.rb +0 -0
  46. data/lib/avo/{app/fields → fields}/field_extensions/visible_in_different_views.rb +1 -1
  47. data/lib/avo/{app/fields → fields}/file_field.rb +1 -2
  48. data/lib/avo/{app/fields → fields}/files_field.rb +1 -2
  49. data/lib/avo/{app/fields → fields}/gravatar_field.rb +1 -1
  50. data/lib/avo/{app/fields/has_and_belongs_to_many.rb → fields/has_and_belongs_to_many_field.rb} +1 -1
  51. data/lib/avo/{app/fields/has_many.rb → fields/has_many_field.rb} +1 -1
  52. data/lib/avo/{app/fields/has_one.rb → fields/has_one_field.rb} +1 -1
  53. data/lib/avo/{app/fields → fields}/heading_field.rb +1 -1
  54. data/lib/avo/{app/fields → fields}/hidden_field.rb +0 -2
  55. data/lib/avo/{app/fields → fields}/id_field.rb +1 -1
  56. data/lib/avo/{app/fields → fields}/key_value_field.rb +1 -1
  57. data/lib/avo/{app/fields → fields}/markdown_field.rb +1 -3
  58. data/lib/avo/{app/fields → fields}/number_field.rb +0 -2
  59. data/lib/avo/{app/fields → fields}/password_field.rb +0 -2
  60. data/lib/avo/{app/fields → fields}/select_field.rb +1 -1
  61. data/lib/avo/{app/fields → fields}/status_field.rb +1 -1
  62. data/lib/avo/{app/fields → fields}/text_field.rb +1 -1
  63. data/lib/avo/{app/fields → fields}/textarea_field.rb +0 -2
  64. data/lib/avo/{app/fields → fields}/trix_field.rb +1 -3
  65. data/lib/avo/filters/base_filter.rb +20 -0
  66. data/lib/avo/filters/boolean_filter.rb +7 -0
  67. data/lib/avo/filters/select_filter.rb +7 -0
  68. data/lib/avo/{app/grid_fields → grid_fields}/body_field.rb +0 -2
  69. data/lib/avo/{app/grid_fields → grid_fields}/grid_field.rb +0 -0
  70. data/lib/avo/{app/grid_fields → grid_fields}/preview_field.rb +0 -2
  71. data/lib/avo/{app/grid_fields → grid_fields}/title_field.rb +0 -2
  72. data/lib/avo/licensing/community_license.rb +6 -0
  73. data/lib/avo/licensing/h_q.rb +88 -0
  74. data/lib/avo/licensing/license.rb +50 -0
  75. data/lib/avo/licensing/license_manager.rb +22 -0
  76. data/lib/avo/licensing/null_license.rb +14 -0
  77. data/lib/avo/licensing/pro_license.rb +11 -0
  78. data/lib/avo/loaders/actions_loader.rb +6 -0
  79. data/lib/avo/loaders/fields_loader.rb +27 -0
  80. data/lib/avo/loaders/filters_loader.rb +6 -0
  81. data/lib/avo/loaders/loader.rb +15 -0
  82. data/lib/avo/services/authorization_service.rb +93 -0
  83. data/lib/avo/services/panel_service.rb +27 -0
  84. data/lib/avo/{app/tools_manager.rb → tools_manager.rb} +0 -0
  85. data/lib/avo/version.rb +1 -1
  86. data/lib/generators/avo/action_generator.rb +11 -5
  87. data/lib/generators/avo/controller_generator.rb +14 -8
  88. data/lib/generators/avo/filter_generator.rb +14 -8
  89. data/lib/generators/avo/install_generator.rb +14 -10
  90. data/lib/generators/avo/locales_generator.rb +16 -0
  91. data/lib/generators/avo/partials_generator.rb +14 -0
  92. data/lib/generators/avo/resource_generator.rb +33 -15
  93. data/lib/generators/avo/templates/{action.rb → action.tt} +2 -4
  94. data/lib/generators/avo/templates/filters/boolean_filter.tt +11 -0
  95. data/lib/generators/avo/templates/filters/select_filter.tt +11 -0
  96. data/lib/generators/avo/templates/initializer/{avo.rb → avo.tt} +6 -4
  97. data/lib/generators/avo/templates/locales/avo.en.yml +17 -0
  98. data/lib/generators/avo/templates/partials/_footer.html.erb +3 -0
  99. data/lib/generators/avo/templates/partials/_header.html.erb +1 -0
  100. data/lib/generators/avo/templates/{views → partials}/_logo.html.erb +0 -0
  101. data/lib/generators/avo/templates/{views → partials}/_scripts.html.erb +0 -0
  102. data/lib/generators/avo/templates/resource/controller.tt +2 -0
  103. data/lib/generators/avo/templates/resource/resource.tt +17 -0
  104. data/public/avo-packs/css/{application-3598cfbb.css → application-c75ac28c.css} +1 -1
  105. data/public/avo-packs/css/application-c75ac28c.css.br +0 -0
  106. data/public/avo-packs/css/{application-3598cfbb.css.gz → application-c75ac28c.css.gz} +0 -0
  107. data/public/avo-packs/js/{application-6ba2bd1bca05d69b96e0.js → application-8849c6e2c8f75d55c666.js} +3 -3
  108. data/public/avo-packs/js/{application-6ba2bd1bca05d69b96e0.js.LICENSE.txt → application-8849c6e2c8f75d55c666.js.LICENSE.txt} +0 -0
  109. data/public/avo-packs/js/application-8849c6e2c8f75d55c666.js.br +0 -0
  110. data/public/avo-packs/js/application-8849c6e2c8f75d55c666.js.gz +0 -0
  111. data/public/avo-packs/js/{application-6ba2bd1bca05d69b96e0.js.map → application-8849c6e2c8f75d55c666.js.map} +1 -1
  112. data/public/avo-packs/js/application-8849c6e2c8f75d55c666.js.map.br +0 -0
  113. data/public/avo-packs/js/{application-6ba2bd1bca05d69b96e0.js.map.gz → application-8849c6e2c8f75d55c666.js.map.gz} +0 -0
  114. data/public/avo-packs/manifest.json +6 -6
  115. data/public/avo-packs/manifest.json.br +0 -0
  116. data/public/avo-packs/manifest.json.gz +0 -0
  117. metadata +78 -93
  118. data/app/controllers/avo/resource_overview_controller.rb +0 -26
  119. data/config/webpacker_packed.yml +0 -86
  120. data/lib/avo/app/action.rb +0 -162
  121. data/lib/avo/app/actions_loader.rb +0 -11
  122. data/lib/avo/app/app.rb +0 -181
  123. data/lib/avo/app/fields_loader.rb +0 -29
  124. data/lib/avo/app/filter.rb +0 -34
  125. data/lib/avo/app/filters/boolean_filter.rb +0 -13
  126. data/lib/avo/app/filters/select_filter.rb +0 -13
  127. data/lib/avo/app/licensing/community_license.rb +0 -4
  128. data/lib/avo/app/licensing/hq.rb +0 -86
  129. data/lib/avo/app/licensing/license.rb +0 -48
  130. data/lib/avo/app/licensing/license_manager.rb +0 -25
  131. data/lib/avo/app/licensing/null_license.rb +0 -12
  132. data/lib/avo/app/licensing/pro_license.rb +0 -9
  133. data/lib/avo/app/resource.rb +0 -291
  134. data/lib/avo/app/resource_grid_fields.rb +0 -30
  135. data/lib/avo/app/services/authorization_service.rb +0 -110
  136. data/lib/avo/app/services/panel_service.rb +0 -25
  137. data/lib/avo/app/tool.rb +0 -5
  138. data/lib/generators/avo/templates/filters/boolean_filter.rb +0 -17
  139. data/lib/generators/avo/templates/filters/select_filter.rb +0 -17
  140. data/lib/generators/avo/templates/resource/%plural_name%_controller.tt +0 -2
  141. data/lib/generators/avo/templates/resource/%singular_name%.tt +0 -20
  142. data/lib/generators/avo/templates/views/_footer.html.erb +0 -3
  143. data/lib/generators/avo/templates/views/_header.html.erb +0 -1
  144. data/lib/generators/avo/views_generator.rb +0 -8
  145. data/public/avo-packs/css/application-3598cfbb.css.br +0 -0
  146. data/public/avo-packs/js/application-6ba2bd1bca05d69b96e0.js.br +0 -0
  147. data/public/avo-packs/js/application-6ba2bd1bca05d69b96e0.js.gz +0 -0
  148. data/public/avo-packs/js/application-6ba2bd1bca05d69b96e0.js.map.br +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 26cae03c309f786a7018713503e33b0ea96e75b5278463ce9cded4307d20bb0d
4
- data.tar.gz: d0d793758868c352618f43c069ecbc49c2c7dbb1d5ab96599a43cf14035f1eae
3
+ metadata.gz: feb0f2107251ad2cef1a10c6980d4ffecde53332b8c584697ebcefb2f341edb5
4
+ data.tar.gz: 49d8bedcfd86bfdb44e8426c393e485451020ca5825528948a199af78f722995
5
5
  SHA512:
6
- metadata.gz: 7b6f1f9f93603229f785f99e6d9e3ee7e245b40fd2c1c55c3dadb6ccfe5a046c04bff9ad1dadc110f9b9f71323345445a4e9af0c7d8e647fd1b3311ca4de54ee
7
- data.tar.gz: 01ca7b5578089f3635292bb57cef8da1916b183ada89973182d66492227cdb45fc61135487f5110a59c0c63eeb430965ea85b2b9583a20751a559e52dd47bbce
6
+ metadata.gz: c5fc2c13d27849cc5c7b5456b9bbb1dea9798f8209746e38cc1d26cbd8f7cd158beab29c8407be0eca1cd0feedc4bfb03a8290941b9a5e66d55dc300cffada06
7
+ data.tar.gz: cd2c38578315087e25b5584de1145bba9bb0454c301f8587ad620f1799158dcddab644e6a8d73677a463b8d344f082cba93aaf53fd2e5a5d1cc9a0a2b0573ff4
data/Gemfile CHANGED
@@ -60,7 +60,6 @@ gem 'listen', '>= 3.0.5', '< 3.2'
60
60
  gem 'spring'
61
61
 
62
62
  gem 'factory_bot_rails'
63
- gem 'faker', require: false
64
63
  # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
65
64
  gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
66
65
 
@@ -89,6 +88,10 @@ group :development do
89
88
  # gem 'pry-rails'
90
89
  end
91
90
 
91
+ group :development, :test do
92
+ gem 'faker', require: false
93
+ end
94
+
92
95
  group :test do
93
96
  gem 'rspec-rails', '~> 4.0.0'
94
97
  gem 'rails-controller-testing'
@@ -97,7 +100,6 @@ group :test do
97
100
  gem 'selenium-webdriver'
98
101
  # Easy installation and use of web drivers to run system tests with browsers
99
102
  gem 'webdrivers'
100
- gem 'faker'
101
103
  gem 'fuubar'
102
104
  gem 'simplecov', require: false
103
105
  gem 'simplecov-cobertura'
@@ -116,8 +118,6 @@ gem 'httparty'
116
118
 
117
119
  gem 'iso'
118
120
 
119
- gem 'i18n-js'
120
-
121
121
  gem 'hotwire-rails'
122
122
 
123
123
  gem 'active_link_to'
data/Gemfile.lock CHANGED
@@ -1,12 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (0.5.0.beta1)
4
+ avo (0.5.0.beta6)
5
5
  active_link_to
6
6
  countries
7
7
  hotwire-rails
8
8
  httparty
9
- i18n-js
10
9
  image_processing
11
10
  inline_svg
12
11
  pagy
@@ -144,8 +143,6 @@ GEM
144
143
  multi_xml (>= 0.5.2)
145
144
  i18n (1.8.9)
146
145
  concurrent-ruby (~> 1.0)
147
- i18n-js (3.8.0)
148
- i18n (>= 0.6.6)
149
146
  i18n_data (0.10.0)
150
147
  image_processing (1.12.1)
151
148
  mini_magick (>= 4.9.5, < 5)
@@ -368,7 +365,6 @@ DEPENDENCIES
368
365
  gem-release
369
366
  hotwire-rails
370
367
  httparty
371
- i18n-js
372
368
  image_processing (~> 1.2)
373
369
  inline_svg
374
370
  iso
data/README.md CHANGED
@@ -50,3 +50,7 @@ $ bundle install
50
50
  # Contributing
51
51
 
52
52
  Please read [CONTRIBUTING.MD](./CONTRIBUTING.MD)
53
+
54
+ # Upgrade guide
55
+
56
+ Please read the [UPGRADE_GUIDE.MD](https://docs.avohq.io/0.5.x/upgrade.html)
@@ -4,19 +4,19 @@
4
4
  <div class="relative w-full pb-3/4 rounded-t-xl overflow-hidden">
5
5
  <%== item_selector_input floating: true, size: :lg %>
6
6
 
7
- <% if preview.respond_to? :to_image %>
8
- <%= link_to_if preview.link_to_resource, image_tag(preview.to_image, class: 'absolute h-full w-full object-cover'), helpers.resource_path(@resource.model), class: 'absolute h-full w-full object-cover', title: title.value %>
9
- <% elsif preview.type == 'file_field' %>
10
- <% if preview.value.attached? && preview.value.representable? %>
11
- <%= link_to_if preview.link_to_resource, image_tag(preview.variant(resize_to_limit: [480, 480]), class: 'absolute h-full w-full object-cover'), helpers.resource_path(@resource.model), class: 'absolute h-full w-full object-cover', title: title.value %>
7
+ <% if cover.respond_to? :to_image %>
8
+ <%= link_to_if cover.link_to_resource, image_tag(cover.to_image, class: 'absolute h-full w-full object-cover'), helpers.resource_path(@resource.model), class: 'absolute h-full w-full object-cover', title: title.value %>
9
+ <% elsif cover.type == 'file_field' %>
10
+ <% if cover.value.attached? && cover.value.representable? %>
11
+ <%= link_to_if cover.link_to_resource, image_tag(cover.variant(resize_to_limit: [480, 480]), class: 'absolute h-full w-full object-cover'), helpers.resource_path(@resource.model), class: 'absolute h-full w-full object-cover', title: title.value %>
12
12
  <% else %>
13
13
  <div class="absolute bg-gray-100 w-full h-full">
14
14
  <%= helpers.svg 'avocado', class: 'relative transform -translate-x-1/2 -translate-y-1/2 h-20 text-gray-400 inset-auto top-1/2 left-1/2' %>
15
15
  </div>
16
16
  <% end %>
17
17
  <% else %>
18
- <% if preview.value.present? %>
19
- <%= link_to_if preview.link_to_resource, image_tag(preview.value, class: 'absolute h-full w-full object-cover'), helpers.resource_path(@resource.model), class: 'absolute h-full w-full object-cover', title: title.value %>
18
+ <% if cover.value.present? %>
19
+ <%= link_to_if cover.link_to_resource, image_tag(cover.value, class: 'absolute h-full w-full object-cover'), helpers.resource_path(@resource.model), class: 'absolute h-full w-full object-cover', title: title.value %>
20
20
  <% else %>
21
21
  <div class="absolute bg-gray-100 w-full h-full">
22
22
  <%= helpers.svg 'avocado', class: 'relative transform -translate-x-1/2 -translate-y-1/2 h-20 text-gray-400 inset-auto top-1/2 left-1/2' %>
@@ -27,7 +27,7 @@
27
27
  <div class="grid grid-cols-1 place-content-between p-4 h-full">
28
28
  <div class="mb-4">
29
29
  <div class="grid font-semibold leading-tight text-lg mb-2">
30
- <%= link_to_if preview.link_to_resource, title.value, helpers.resource_path(@resource.model) if title.present? %>
30
+ <%= link_to_if title.link_to_resource, title.value, helpers.resource_path(@resource.model) if title.present? %>
31
31
  </div>
32
32
  <div class="text-sm break-words">
33
33
  <%= body.value if body.present? %>
@@ -3,29 +3,23 @@
3
3
  class Avo::Index::GridItemComponent < ViewComponent::Base
4
4
  include Avo::ResourcesHelper
5
5
 
6
- def initialize(resource: resource, reflection: reflection, parent_model: nil)
6
+ def initialize(resource: nil, reflection: nil, parent_model: nil)
7
7
  @resource = resource
8
8
  @reflection = reflection
9
- @grid_fields = resource.get_fields(view_type: :grid)
9
+ @grid_fields = resource.get_grid_fields
10
10
  @parent_model = parent_model
11
11
  end
12
12
 
13
13
  private
14
- def preview
15
- @grid_fields.detect do |field|
16
- field.grid_position == :preview
17
- end
14
+ def cover
15
+ @grid_fields[:cover].first
18
16
  end
19
17
 
20
18
  def title
21
- @grid_fields.detect do |field|
22
- field.grid_position == :title
23
- end
19
+ @grid_fields[:title].first
24
20
  end
25
21
 
26
22
  def body
27
- @grid_fields.detect do |field|
28
- field.grid_position == :body
29
- end
23
+ @grid_fields[:body].first
30
24
  end
31
25
  end
@@ -24,7 +24,7 @@
24
24
 
25
25
  <% if can_detach? %>
26
26
  <%= form_with url: helpers.resource_detach_path(params[:resource_name], params[:id], params[:related_name], @resource.model.id), method: :delete, html: {'data-turbo-frame': params[:turbo_frame]} do |form| %>
27
- <%= form.button helpers.svg('trash', class: 'text-gray-400 h-6 hover:text-gray-600'),
27
+ <%= form.button helpers.svg('trash-sm', class: 'text-gray-400 h-6 hover:text-gray-600'),
28
28
  title: t('avo.detach_item', { item: @resource.model.model_name.name.downcase }).capitalize,
29
29
  type: :submit,
30
30
  data: {
@@ -1,7 +1,7 @@
1
1
  <% if @resources.present?%>
2
2
  <div class="w-full grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 2xl:grid-cols-6 gap-6">
3
3
  <% @resources.each_with_index do |resource, index| %>
4
- <% cache_if Avo::PACKED, [resource.model, resource.file_hash] do %>
4
+ <% cache_if Avo.configuration.cache_resources_on_index_view, resource.cache_hash(@parent_model) do %>
5
5
  <%= render(Avo::Index::GridItemComponent.new(resource: resource, reflection: @reflection, parent_model: @parent_model)) %>
6
6
  <% end %>
7
7
  <% end %>
@@ -1,10 +1,10 @@
1
1
  <div class="w-full">
2
2
  <% if @resources.present?%>
3
3
  <table class="w-full px-4 overflow-hidden">
4
- <%= render partial: 'avo/partials/table_header', locals: {fields: @resource.get_fields(view_type: :table, reflection: @reflection)} %>
4
+ <%= render partial: 'avo/partials/table_header', locals: {fields: @resource.get_fields(reflection: @reflection)} %>
5
5
  <tbody>
6
6
  <% @resources.each_with_index do |resource, index| %>
7
- <% cache_if Avo::PACKED, [resource.model, resource.file_hash] do %>
7
+ <% cache_if Avo.configuration.cache_resources_on_index_view, resource.cache_hash(@parent_model) do %>
8
8
  <%= render Avo::Index::TableRowComponent.new(resource: resource, reflection: @reflection, parent_model: @parent_model) %>
9
9
  <% end %>
10
10
  <% end %>
@@ -7,7 +7,7 @@
7
7
  <%== item_selector_input floating: false %>
8
8
  </div>
9
9
  </td>
10
- <% @resource.get_fields(view_type: :table, reflection: @reflection).each_with_index do |field, index| %>
10
+ <% @resource.get_fields(reflection: @reflection).each_with_index do |field, index| %>
11
11
  <%= index_field field, index, @resource %>
12
12
  <% end %>
13
13
  <td class="text-right whitespace-nowrap px-2">
@@ -27,16 +27,14 @@ module Avo
27
27
  end
28
28
 
29
29
  def set_action
30
- action_class = params[:action_id].gsub('avo_actions_', '').classify
31
- action_name = "Avo::Actions::#{action_class}"
30
+ action_class = params[:action_id].gsub('avo_actions_', '').classify.safe_constantize
32
31
 
33
32
  if params[:id].present?
34
33
  model = @resource.model_class.find params[:id]
35
34
  end
36
35
 
37
- @action = action_name.safe_constantize.new
36
+ @action = action_class.new
38
37
  @action.hydrate(model: model, resource: resource, user: _current_user)
39
- @action.boot_fields request
40
38
  end
41
39
 
42
40
  def respond(response)
@@ -15,8 +15,7 @@ module Avo
15
15
  add_flash_types :info, :warning, :success, :error
16
16
 
17
17
  def init_app
18
- Avo::App.boot if Avo::IN_DEVELOPMENT
19
- Avo::App.init request
18
+ Avo::App.init request: request, context: context
20
19
 
21
20
  @license = Avo::App.license
22
21
  end
@@ -36,6 +35,10 @@ module Avo
36
35
  instance_eval(&Avo.configuration.current_user)
37
36
  end
38
37
 
38
+ def context
39
+ instance_eval(&Avo.configuration.context)
40
+ end
41
+
39
42
  def resources_path(model, keep_query_params: false, **args)
40
43
  return if model.nil?
41
44
 
@@ -221,7 +224,7 @@ module Avo
221
224
  end
222
225
 
223
226
  def set_authorization
224
- @authorization = AuthorizationService.new _current_user
227
+ @authorization = Services::AuthorizationService.new _current_user
225
228
  end
226
229
 
227
230
  def set_container_classes
@@ -169,6 +169,10 @@ module Avo
169
169
  cookies[:per_page] = params[:per_page]
170
170
  end
171
171
 
172
+ if @parent_model.present?
173
+ @index_params[:per_page] = Avo.configuration.via_per_page
174
+ end
175
+
172
176
  # Sorting
173
177
  @index_params[:sort_by] = params[:sort_by] || :created_at
174
178
  @index_params[:sort_direction] = params[:sort_direction] || :desc
@@ -179,7 +183,11 @@ module Avo
179
183
  end
180
184
 
181
185
  def set_filters
182
- @filters = @resource.get_filters.map(&:new)
186
+ @filters = @resource.get_filters.map do |filter_class|
187
+ filter = filter_class.new
188
+
189
+ filter
190
+ end
183
191
  end
184
192
 
185
193
  def set_actions
@@ -188,12 +196,7 @@ module Avo
188
196
  end
189
197
 
190
198
  @actions = @resource.get_actions.map do |action|
191
- action = action.new
192
-
193
- action.hydrate(model: model, resource: @resource)
194
- action.boot_fields request
195
-
196
- action
199
+ action.new.hydrate(model: model, resource: @resource)
197
200
  end
198
201
  end
199
202
 
@@ -35,7 +35,7 @@ module Avo
35
35
  @options = query.all.map do |model|
36
36
  {
37
37
  value: model.id,
38
- label: model.send(@attachment_resource.title)
38
+ label: model.send(@attachment_resource.class.title)
39
39
  }
40
40
  end
41
41
  end
@@ -35,7 +35,7 @@ module Avo
35
35
  resources.map do |model|
36
36
  {
37
37
  id: model.id,
38
- search_label: model.send(avo_resource.title),
38
+ search_label: model.send(avo_resource.class.title),
39
39
  link: "/resources/#{model.class.to_s.singularize.underscore}/#{model.id}",
40
40
  }
41
41
  end
@@ -11,7 +11,7 @@ import tippy from 'tippy.js'
11
11
  // Toastr alerts
12
12
  import '../js/toastr'
13
13
 
14
- Mousetrap.bind('r r r', () => Turbo.visit(window.location.href))
14
+ Mousetrap.bind('r r r', () => Turbo.visit(window.location.href, { action: "replace" }))
15
15
 
16
16
  const application = Application.start()
17
17
 
@@ -14,12 +14,6 @@
14
14
  >
15
15
  <%
16
16
  @actions.each_with_index do |action, index|
17
- case action.class.superclass.to_s
18
- when Avo::Filters::SelectFilter.to_s
19
- template = 'select_action'
20
- when Avo::Filters::BooleanFilter.to_s
21
- template = 'boolean_action'
22
- end
23
17
  path = action_name == 'show' ?
24
18
  "/avo/resources/#{@resource.model_class.model_name.route_key}/#{@model.id}/actions/#{action.param_id}" :
25
19
  "/avo/resources/#{@resource.model_class.model_name.route_key}/actions/#{action.param_id}"
@@ -28,7 +22,7 @@
28
22
  'data-turbo-frame': 'actions_show',
29
23
  'data-action': 'click->actions-picker#visitAction',
30
24
  class: 'flex items-center w-full py-2 px-4 font-bold text-gray-700 hover:text-white hover:bg-blue-500' do %>
31
- <%= svg 'play', extra_class: 'inline' %> <%= action.name %>
25
+ <%= svg 'play', class: 'h-5 mr-1 inline' %> <%= action.name %>
32
26
  <% end %>
33
27
  <% end %>
34
28
  </div>
@@ -12,7 +12,7 @@
12
12
  set_value = {} if set_value.nil?
13
13
  %>
14
14
  <div data-controller="boolean-filter">
15
- <%= filter_wrapper name: filter.name, index: index do %>
15
+ <%= filter_wrapper name: filter.name do %>
16
16
  <div class="flex items-center">
17
17
  <div class="space-y-2">
18
18
  <% filter.options.each do |value, label| %>
@@ -10,19 +10,11 @@
10
10
  <% end %>
11
11
 
12
12
  <div
13
- class="absolute block inset-auto right-0 top-full bg-white min-w-300px mt-2 z-20 shadow-context rounded-xl hidden"
13
+ class="absolute block inset-auto right-0 top-full bg-white min-w-300px mt-2 z-20 shadow-context rounded-xl hidden divide-y divide-gray-300"
14
14
  data-toggle-panel-target="panel"
15
15
  >
16
- <%
17
- @filters.each_with_index do |filter, index|
18
- case filter.class.superclass.to_s
19
- when Avo::Filters::SelectFilter.to_s
20
- template = 'avo/base/select_filter'
21
- when Avo::Filters::BooleanFilter.to_s
22
- template = 'avo/base/boolean_filter'
23
- end
24
- %>
25
- <%= render partial: template, locals: {filter: filter, index: index} %>
16
+ <% @filters.each do |filter| %>
17
+ <%= render partial: filter.class.template, locals: {filter: filter} %>
26
18
  <% end %>
27
19
 
28
20
  <div class="p-4 border-gray-300 border-t">
@@ -7,7 +7,7 @@
7
7
  end
8
8
  %>
9
9
  <div data-controller="select-filter">
10
- <%= filter_wrapper name: filter.name, index: index do %>
10
+ <%= filter_wrapper name: filter.name do %>
11
11
  <%= select_tag filter.id, options_for_select(filter.options.invert, set_value),
12
12
  class: input_classes('w-full mb-0'),
13
13
  include_blank: '—',
@@ -1,5 +1,4 @@
1
1
  <%
2
- Rails.application.eager_load!
3
2
  models = ApplicationRecord.descendants
4
3
  %>
5
4
  <div>
@@ -30,7 +30,7 @@
30
30
  end
31
31
  classes = "text-blue-gray-600 tracking-tight leading-tight text-xs font-semibold"
32
32
  %>
33
- <th class="text-left uppercase px-3 py-2 ">
33
+ <th class="text-left uppercase px-3 py-2 whitespace-nowrap">
34
34
  <% if field.sortable %>
35
35
  <%= link_to params.permit!.merge(sort_by: sort_by, sort_direction: sort_direction), class: "flex items-center #{classes} #{'cursor-pointer' if field.sortable}", 'data-turbo-frame': params[:turbo_frame] do %>
36
36
  <%= field.name %>
@@ -6,7 +6,7 @@
6
6
 
7
7
  <div class="flex-1 flex flex-col justify-between">
8
8
  <div class="tools py-4">
9
- <%= render Avo::NavigationLinkComponent.new label: t('avo.dashboard'), path: '/avo', active: :exclusive if Rails.env.development? %>
9
+ <%= render Avo::NavigationLinkComponent.new label: 'Get started', path: '/avo', active: :exclusive if Rails.env.development? %>
10
10
  <%= render Avo::NavigationHeadingComponent.new label: t('avo.resources') %>
11
11
 
12
12
  <div class="w-full">
@@ -1,4 +1,4 @@
1
- <div class="border-gray-300 <%= 'border-t' if index != 0 %>">
1
+ <div>
2
2
  <div class="p-4 pb-0 text-sm font-bold text-gray-600">
3
3
  <%= name %>
4
4
  </div>
@@ -8,6 +8,11 @@
8
8
 
9
9
  <%= render partial: 'avo/partials/javascript' %>
10
10
 
11
+ <%# if Avo::PACKED %>
12
+ <%#= stylesheet_link_tag 'application', media: 'all', "data-turbo-track": "reload" %>
13
+ <%#= javascript_include_tag 'avo-packs/application', "data-turbo-track": "reload" %>
14
+ <%# else %>
15
+ <%# end %>
11
16
  <%= javascript_pack_tag 'application' %>
12
17
  <%= stylesheet_pack_tag 'application', media: 'all' %>
13
18
  </head>
data/avo.gemspec CHANGED
@@ -39,7 +39,6 @@ Gem::Specification.new do |spec|
39
39
  spec.add_dependency 'countries'
40
40
  spec.add_dependency 'pundit'
41
41
  spec.add_dependency 'httparty'
42
- spec.add_dependency 'i18n-js'
43
42
  spec.add_dependency 'active_link_to'
44
43
  spec.add_dependency 'image_processing'
45
44
  spec.add_dependency 'view_component'