avo 2.10.2 → 2.10.3.pre.1

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 (68) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +64 -62
  3. data/app/components/avo/fields/country_field/edit_component.html.erb +9 -3
  4. data/app/components/avo/fields/date_field/edit_component.html.erb +26 -8
  5. data/app/components/avo/fields/date_field/index_component.html.erb +7 -1
  6. data/app/components/avo/fields/date_field/show_component.html.erb +7 -1
  7. data/app/components/avo/fields/date_time_field/edit_component.html.erb +26 -10
  8. data/app/components/avo/fields/date_time_field/index_component.html.erb +9 -1
  9. data/app/components/avo/fields/date_time_field/show_component.html.erb +9 -1
  10. data/app/components/avo/fields/file_field/edit_component.html.erb +1 -0
  11. data/app/components/avo/fields/files_field/edit_component.html.erb +1 -0
  12. data/app/components/avo/fields/select_field/edit_component.html.erb +14 -10
  13. data/app/components/avo/index/ordering/button_component.rb +1 -5
  14. data/app/components/avo/views/resource_index_component.html.erb +1 -1
  15. data/app/controllers/avo/application_controller.rb +15 -9
  16. data/app/controllers/avo/base_controller.rb +11 -3
  17. data/app/controllers/avo/reorder_controller.rb +25 -0
  18. data/app/helpers/avo/application_helper.rb +6 -0
  19. data/app/helpers/avo/url_helpers.rb +0 -4
  20. data/app/javascript/js/controllers/fields/date_field_controller.js +98 -24
  21. data/app/javascript/js/controllers/search_controller.js +3 -0
  22. data/app/views/avo/partials/_javascript.html.erb +1 -1
  23. data/config/routes.rb +5 -4
  24. data/db/factories.rb +1 -0
  25. data/lib/avo/app.rb +1 -3
  26. data/lib/avo/base_resource.rb +5 -3
  27. data/lib/avo/concerns/handles_field_args.rb +1 -1
  28. data/lib/avo/concerns/has_fields.rb +2 -0
  29. data/lib/avo/configuration.rb +2 -12
  30. data/lib/avo/fields/base_field.rb +2 -0
  31. data/lib/avo/fields/country_field.rb +2 -0
  32. data/lib/avo/fields/date_field.rb +12 -10
  33. data/lib/avo/fields/date_time_field.rb +21 -9
  34. data/lib/avo/fields/field_extensions/has_include_blank.rb +17 -0
  35. data/lib/avo/fields/file_field.rb +2 -0
  36. data/lib/avo/fields/files_field.rb +2 -0
  37. data/lib/avo/fields/select_field.rb +2 -0
  38. data/lib/avo/licensing/h_q.rb +2 -0
  39. data/lib/avo/services/uri_service.rb +4 -0
  40. data/lib/avo/version.rb +1 -1
  41. data/lib/generators/avo/action_generator.rb +3 -2
  42. data/lib/generators/avo/base_generator.rb +14 -0
  43. data/lib/generators/avo/card/chartkick_generator.rb +18 -0
  44. data/lib/generators/avo/card/metric_generator.rb +18 -0
  45. data/lib/generators/avo/card/partial_generator.rb +19 -0
  46. data/lib/generators/avo/controller_generator.rb +9 -3
  47. data/lib/generators/avo/dashboard_generator.rb +2 -2
  48. data/lib/generators/avo/eject_generator.rb +2 -3
  49. data/lib/generators/avo/field_generator.rb +2 -2
  50. data/lib/generators/avo/filter_generator.rb +3 -2
  51. data/lib/generators/avo/install_generator.rb +2 -2
  52. data/lib/generators/avo/locales_generator.rb +2 -2
  53. data/lib/generators/avo/named_base_generator.rb +14 -0
  54. data/lib/generators/avo/resource_generator.rb +2 -2
  55. data/lib/generators/avo/resource_tool_generator.rb +4 -4
  56. data/lib/generators/avo/tool_generator.rb +4 -4
  57. data/lib/generators/avo/version_generator.rb +23 -0
  58. data/public/avo-assets/avo.css +4 -0
  59. data/public/avo-assets/avo.js +69 -69
  60. data/public/avo-assets/avo.js.map +2 -2
  61. metadata +12 -11
  62. data/db/migrate/20210421064037_add_color_to_teams.rb +0 -5
  63. data/db/migrate/20210423075924_add_progress_to_projects.rb +0 -5
  64. data/db/migrate/20210525143134_add_slug_to_users.rb +0 -6
  65. data/lib/avo/fields/currency_field.rb +0 -15
  66. data/lib/generators/avo/chartkick_card_generator.rb +0 -16
  67. data/lib/generators/avo/metric_card_generator.rb +0 -16
  68. data/lib/generators/avo/partial_card_generator.rb +0 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1fcc28841e21f49a9ad7146589f8e280f352d160106bc67539630a819a2fea14
4
- data.tar.gz: 7d0049458872fa7a81003d1358673b65ff29d38256b6d2d20c8fdaf757b09d8f
3
+ metadata.gz: eaf0eb69447308c9c5124d557cacfcc5fce7ad1ee307980ea1601671e861346b
4
+ data.tar.gz: 1e1b14789776d3d3382fca548f8ab1f18d05996ce39fce98091a75723e3b9dd0
5
5
  SHA512:
6
- metadata.gz: aa278bfe2a28f7f441239455246af82da628b9d699e7a583e6da65972305c75e407fce432341b11d21ec5225ff67c8558b6017bb75a1d42e7be42f3653e0d259
7
- data.tar.gz: 8a6ff3c392ce98703272555aabe01ae005f8df10081c7a1bde90e5a7ef99063144d5d573b4012b31b44d0b0c585334ee69fabf5f4414d1e053c2abaa61fe6ae6
6
+ metadata.gz: 7c42723dfef266320c8b26820c3e9d4670b2c7ce1dccfc49f808cd035d751711479753bb441d15e7b62190b3550d9ea8d435dfe47289c0a8aaa431de37127bc4
7
+ data.tar.gz: 8ea62dec974fc99d1f75f4e38a168738be810e118d99526f3cc166b9a12c1c13a8cfa33310fa6af24be32a838cb4e7cbd6f42c10108b76956a2b268525210992
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (2.10.2)
4
+ avo (2.10.3.pre.1)
5
5
  active_link_to
6
6
  addressable
7
7
  breadcrumbs_on_rails
@@ -22,40 +22,40 @@ PATH
22
22
  GEM
23
23
  remote: https://rubygems.org/
24
24
  specs:
25
- actioncable (6.1.4.6)
26
- actionpack (= 6.1.4.6)
27
- activesupport (= 6.1.4.6)
25
+ actioncable (6.1.6.1)
26
+ actionpack (= 6.1.6.1)
27
+ activesupport (= 6.1.6.1)
28
28
  nio4r (~> 2.0)
29
29
  websocket-driver (>= 0.6.1)
30
- actionmailbox (6.1.4.6)
31
- actionpack (= 6.1.4.6)
32
- activejob (= 6.1.4.6)
33
- activerecord (= 6.1.4.6)
34
- activestorage (= 6.1.4.6)
35
- activesupport (= 6.1.4.6)
30
+ actionmailbox (6.1.6.1)
31
+ actionpack (= 6.1.6.1)
32
+ activejob (= 6.1.6.1)
33
+ activerecord (= 6.1.6.1)
34
+ activestorage (= 6.1.6.1)
35
+ activesupport (= 6.1.6.1)
36
36
  mail (>= 2.7.1)
37
- actionmailer (6.1.4.6)
38
- actionpack (= 6.1.4.6)
39
- actionview (= 6.1.4.6)
40
- activejob (= 6.1.4.6)
41
- activesupport (= 6.1.4.6)
37
+ actionmailer (6.1.6.1)
38
+ actionpack (= 6.1.6.1)
39
+ actionview (= 6.1.6.1)
40
+ activejob (= 6.1.6.1)
41
+ activesupport (= 6.1.6.1)
42
42
  mail (~> 2.5, >= 2.5.4)
43
43
  rails-dom-testing (~> 2.0)
44
- actionpack (6.1.4.6)
45
- actionview (= 6.1.4.6)
46
- activesupport (= 6.1.4.6)
44
+ actionpack (6.1.6.1)
45
+ actionview (= 6.1.6.1)
46
+ activesupport (= 6.1.6.1)
47
47
  rack (~> 2.0, >= 2.0.9)
48
48
  rack-test (>= 0.6.3)
49
49
  rails-dom-testing (~> 2.0)
50
50
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
51
- actiontext (6.1.4.6)
52
- actionpack (= 6.1.4.6)
53
- activerecord (= 6.1.4.6)
54
- activestorage (= 6.1.4.6)
55
- activesupport (= 6.1.4.6)
51
+ actiontext (6.1.6.1)
52
+ actionpack (= 6.1.6.1)
53
+ activerecord (= 6.1.6.1)
54
+ activestorage (= 6.1.6.1)
55
+ activesupport (= 6.1.6.1)
56
56
  nokogiri (>= 1.8.5)
57
- actionview (6.1.4.6)
58
- activesupport (= 6.1.4.6)
57
+ actionview (6.1.6.1)
58
+ activesupport (= 6.1.6.1)
59
59
  builder (~> 3.1)
60
60
  erubi (~> 1.4)
61
61
  rails-dom-testing (~> 2.0)
@@ -65,22 +65,22 @@ GEM
65
65
  addressable
66
66
  active_median (0.3.3)
67
67
  activesupport (>= 5.2)
68
- activejob (6.1.4.6)
69
- activesupport (= 6.1.4.6)
68
+ activejob (6.1.6.1)
69
+ activesupport (= 6.1.6.1)
70
70
  globalid (>= 0.3.6)
71
- activemodel (6.1.4.6)
72
- activesupport (= 6.1.4.6)
73
- activerecord (6.1.4.6)
74
- activemodel (= 6.1.4.6)
75
- activesupport (= 6.1.4.6)
76
- activestorage (6.1.4.6)
77
- actionpack (= 6.1.4.6)
78
- activejob (= 6.1.4.6)
79
- activerecord (= 6.1.4.6)
80
- activesupport (= 6.1.4.6)
81
- marcel (~> 1.0.0)
71
+ activemodel (6.1.6.1)
72
+ activesupport (= 6.1.6.1)
73
+ activerecord (6.1.6.1)
74
+ activemodel (= 6.1.6.1)
75
+ activesupport (= 6.1.6.1)
76
+ activestorage (6.1.6.1)
77
+ actionpack (= 6.1.6.1)
78
+ activejob (= 6.1.6.1)
79
+ activerecord (= 6.1.6.1)
80
+ activesupport (= 6.1.6.1)
81
+ marcel (~> 1.0)
82
82
  mini_mime (>= 1.1.0)
83
- activesupport (6.1.4.6)
83
+ activesupport (6.1.6.1)
84
84
  concurrent-ruby (~> 1.0, >= 1.0.2)
85
85
  i18n (>= 1.6, < 2)
86
86
  minitest (>= 5.1)
@@ -201,7 +201,7 @@ GEM
201
201
  httparty (0.20.0)
202
202
  mime-types (~> 3.0)
203
203
  multi_xml (>= 0.5.2)
204
- i18n (1.10.0)
204
+ i18n (1.11.0)
205
205
  concurrent-ruby (~> 1.0)
206
206
  i18n_data (0.15.0)
207
207
  simple_po_parser (~> 1.1)
@@ -249,9 +249,11 @@ GEM
249
249
  net-protocol
250
250
  timeout
251
251
  nio4r (2.5.8)
252
- nokogiri (1.13.6)
252
+ nokogiri (1.13.7)
253
253
  mini_portile2 (~> 2.8.0)
254
254
  racc (~> 1.4)
255
+ nokogiri (1.13.7-x86_64-linux)
256
+ racc (~> 1.4)
255
257
  orm_adapter (0.5.0)
256
258
  pagy (5.10.1)
257
259
  activesupport
@@ -265,23 +267,23 @@ GEM
265
267
  pundit (2.2.0)
266
268
  activesupport (>= 3.0.0)
267
269
  racc (1.6.0)
268
- rack (2.2.3.1)
269
- rack-test (1.1.0)
270
- rack (>= 1.0, < 3)
271
- rails (6.1.4.6)
272
- actioncable (= 6.1.4.6)
273
- actionmailbox (= 6.1.4.6)
274
- actionmailer (= 6.1.4.6)
275
- actionpack (= 6.1.4.6)
276
- actiontext (= 6.1.4.6)
277
- actionview (= 6.1.4.6)
278
- activejob (= 6.1.4.6)
279
- activemodel (= 6.1.4.6)
280
- activerecord (= 6.1.4.6)
281
- activestorage (= 6.1.4.6)
282
- activesupport (= 6.1.4.6)
270
+ rack (2.2.4)
271
+ rack-test (2.0.2)
272
+ rack (>= 1.3)
273
+ rails (6.1.6.1)
274
+ actioncable (= 6.1.6.1)
275
+ actionmailbox (= 6.1.6.1)
276
+ actionmailer (= 6.1.6.1)
277
+ actionpack (= 6.1.6.1)
278
+ actiontext (= 6.1.6.1)
279
+ actionview (= 6.1.6.1)
280
+ activejob (= 6.1.6.1)
281
+ activemodel (= 6.1.6.1)
282
+ activerecord (= 6.1.6.1)
283
+ activestorage (= 6.1.6.1)
284
+ activesupport (= 6.1.6.1)
283
285
  bundler (>= 1.15.0)
284
- railties (= 6.1.4.6)
286
+ railties (= 6.1.6.1)
285
287
  sprockets-rails (>= 2.0.0)
286
288
  rails-controller-testing (1.0.5)
287
289
  actionpack (>= 5.0.1.rc1)
@@ -292,11 +294,11 @@ GEM
292
294
  nokogiri (>= 1.6)
293
295
  rails-html-sanitizer (1.4.3)
294
296
  loofah (~> 2.3)
295
- railties (6.1.4.6)
296
- actionpack (= 6.1.4.6)
297
- activesupport (= 6.1.4.6)
297
+ railties (6.1.6.1)
298
+ actionpack (= 6.1.6.1)
299
+ activesupport (= 6.1.6.1)
298
300
  method_source
299
- rake (>= 0.13)
301
+ rake (>= 12.2)
300
302
  thor (~> 1.0)
301
303
  rainbow (3.1.1)
302
304
  rake (13.0.6)
@@ -370,7 +372,7 @@ GEM
370
372
  spring (4.0.0)
371
373
  spring-commands-rspec (1.0.4)
372
374
  spring (>= 0.9.1)
373
- sprockets (4.0.2)
375
+ sprockets (4.1.1)
374
376
  concurrent-ruby (~> 1.0)
375
377
  rack (> 1, < 3)
376
378
  sprockets-rails (3.4.2)
@@ -1,9 +1,15 @@
1
1
  <%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, displayed_in_modal: @displayed_in_modal do %>
2
- <%= @form.select @field.id, @field.select_options, { selected: @field.value, prompt: @field.placeholder },
2
+ <%= @form.select @field.id, @field.select_options, {
3
+ selected: @field.value,
4
+ include_blank: @field.include_blank
5
+ },
6
+ aria: {
7
+ placeholder: @field.placeholder
8
+ },
3
9
  class: classes("w-full"),
4
10
  data: @field.get_html(:data, view: view, element: :input),
5
11
  disabled: @field.readonly,
6
- placeholder: @field.placeholder,
7
- style: @field.get_html(:style, view: view, element: :input)
12
+ style: @field.get_html(:style, view: view, element: :input),
13
+ placeholder: @field.include_blank.present? ? nil : @field.placeholder
8
14
  %>
9
15
  <% end %>
@@ -1,14 +1,32 @@
1
1
  <%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, displayed_in_modal: @displayed_in_modal do %>
2
- <div data-controller="date-field">
3
- <%= @form.date_field @field.id,
2
+ <%= content_tag :div, data: {
3
+ controller: "date-field",
4
+ date_field_view_value: @view,
5
+ date_field_enable_time_value: false,
6
+ date_field_format_value: @field.format,
7
+ date_field_picker_format_value: @field.picker_format,
8
+ date_field_first_day_of_week_value: @field.first_day_of_week,
9
+ date_field_disable_mobile_value: @field.disable_mobile,
10
+ date_field_relative_value: @field.relative,
11
+ } do %>
12
+ <%= datetime_field "fake_#{@field.id}", "fake",
13
+ value: @field.edit_formatted_value,
4
14
  class: classes("w-full"),
15
+ data: {
16
+ 'date-field-target': 'fakeInput',
17
+ placeholder: @field.placeholder,
18
+ relative: @field.relative,
19
+ **@field.get_html(:data, view: view, element: :input)
20
+ },
21
+ disabled: @field.readonly,
22
+ placeholder: @field.placeholder,
23
+ style: @field.get_html(:style, view: view, element: :input)
24
+ %>
25
+ <%= @form.text_field @field.id,
26
+ value: @field.edit_formatted_value,
27
+ class: classes("w-full hidden"),
5
28
  data: {
6
29
  'date-field-target': 'input',
7
- 'first-day-of-week': @field.first_day_of_week,
8
- 'picker-format': @field.picker_format,
9
- 'disable-mobile': @field.disable_mobile,
10
- 'enable-time': false,
11
- format: @field.format,
12
30
  placeholder: @field.placeholder,
13
31
  relative: @field.relative,
14
32
  **@field.get_html(:data, view: view, element: :input)
@@ -17,5 +35,5 @@
17
35
  placeholder: @field.placeholder,
18
36
  style: @field.get_html(:style, view: view, element: :input)
19
37
  %>
20
- </div>
38
+ <% end %>
21
39
  <% end %>
@@ -1,3 +1,9 @@
1
1
  <%= index_field_wrapper field: @field, resource: @resource do %>
2
- <%= @field.formatted_value %>
2
+ <%= content_tag :div, data: {
3
+ controller: "date-field",
4
+ date_field_view_value: @view,
5
+ date_field_format_value: @field.format,
6
+ } do %>
7
+ <%= @field.formatted_value %>
8
+ <% end %>
3
9
  <% end %>
@@ -1,3 +1,9 @@
1
1
  <%= show_field_wrapper field: @field, resource: @resource, index: @index do %>
2
- <%= @field.formatted_value %>
2
+ <%= content_tag :div, data: {
3
+ controller: "date-field",
4
+ date_field_view_value: @view,
5
+ date_field_format_value: @field.format,
6
+ } do %>
7
+ <%= @field.formatted_value %>
8
+ <% end %>
3
9
  <% end %>
@@ -1,16 +1,32 @@
1
1
  <%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, displayed_in_modal: @displayed_in_modal do %>
2
- <div data-controller="date-field">
3
- <%= @form.datetime_field @field.id,
2
+ <%= content_tag :div, data: {
3
+ controller: "date-field",
4
+ date_field_view_value: @view,
5
+ date_field_enable_time_value: true,
6
+ date_field_picker_format_value: @field.picker_format,
7
+ date_field_first_day_of_week_value: @field.first_day_of_week,
8
+ date_field_disable_mobile_value: @field.disable_mobile,
9
+ date_field_time24_hr_value: @field.time_24hr,
10
+ date_field_timezone_value: @field.timezone,
11
+ } do %>
12
+ <%= datetime_field "fake_#{@field.id}", "fake",
13
+ value: @field.edit_formatted_value,
4
14
  class: classes("w-full"),
15
+ data: {
16
+ 'date-field-target': 'fakeInput',
17
+ placeholder: @field.placeholder,
18
+ relative: @field.relative,
19
+ **@field.get_html(:data, view: view, element: :input)
20
+ },
21
+ disabled: @field.readonly,
22
+ placeholder: @field.placeholder,
23
+ style: @field.get_html(:style, view: view, element: :input)
24
+ %>
25
+ <%= @form.text_field @field.id,
26
+ value: @field.edit_formatted_value,
27
+ class: classes("w-full hidden"),
5
28
  data: {
6
29
  'date-field-target': 'input',
7
- 'first-day-of-week': @field.first_day_of_week,
8
- 'picker-format': @field.picker_format,
9
- 'disable-mobile': @field.disable_mobile,
10
- 'enable-time': true,
11
- time24hr: @field.time_24hr,
12
- timezone: @field.timezone,
13
- format: @field.format,
14
30
  placeholder: @field.placeholder,
15
31
  relative: @field.relative,
16
32
  **@field.get_html(:data, view: view, element: :input)
@@ -19,5 +35,5 @@
19
35
  placeholder: @field.placeholder,
20
36
  style: @field.get_html(:style, view: view, element: :input)
21
37
  %>
22
- </div>
38
+ <% end %>
23
39
  <% end %>
@@ -1,3 +1,11 @@
1
1
  <%= index_field_wrapper field: @field, resource: @resource do %>
2
- <%= @field.formatted_value %>
2
+ <%= content_tag :div, data: {
3
+ controller: "date-field",
4
+ date_field_view_value: @view,
5
+ date_field_format_value: @field.format,
6
+ date_field_timezone_value: @field.timezone,
7
+ date_field_picker_format_value: @field.picker_format,
8
+ } do %>
9
+ <%= @field.formatted_value %>
10
+ <% end %>
3
11
  <% end %>
@@ -1,3 +1,11 @@
1
1
  <%= show_field_wrapper field: @field, resource: @resource, index: @index do %>
2
- <%= @field.formatted_value %>
2
+ <%= content_tag :div, data: {
3
+ controller: "date-field",
4
+ date_field_view_value: @view,
5
+ date_field_format_value: @field.format,
6
+ date_field_timezone_value: @field.timezone,
7
+ date_field_picker_format_value: @field.picker_format,
8
+ } do %>
9
+ <%= @field.formatted_value %>
10
+ <% end %>
3
11
  <% end %>
@@ -7,6 +7,7 @@
7
7
 
8
8
  <% if @resource.authorization.authorize_action(:upload_attachments?, raise_exception: false) %>
9
9
  <%= @form.file_field @field.id,
10
+ accept: @field.accept,
10
11
  data: @field.get_html(:data, view: view, element: :input),
11
12
  direct_upload: @field.direct_upload,
12
13
  disabled: @field.readonly,
@@ -4,6 +4,7 @@
4
4
  <% if @resource.authorization.authorize_action(:upload_attachments?, raise_exception: false) %>
5
5
  <div class="mt-2">
6
6
  <%= @form.file_field @field.id,
7
+ accept: @field.accept,
7
8
  data: @field.get_html(:data, view: view, element: :input),
8
9
  direct_upload: @field.direct_upload,
9
10
  disabled: @field.readonly,
@@ -1,12 +1,16 @@
1
1
  <%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, displayed_in_modal: @displayed_in_modal do %>
2
- <%= @form.select @field.id, @field.options_for_select, { selected: @field.value, prompt: @field.placeholder }, {
3
- aria: {
4
- placeholder: @field.placeholder
5
- },
6
- class: classes("w-full"),
7
- data: @field.get_html(:data, view: view, element: :input),
8
- disabled: @field.readonly,
9
- style: @field.get_html(:style, view: view, element: :input),
10
- value: @field.model.present? ? @field.model[@field.id] : @field.value
11
- } %>
2
+ <%= @form.select @field.id, @field.options_for_select, {
3
+ selected: @field.value,
4
+ include_blank: @field.include_blank
5
+ },
6
+ aria: {
7
+ placeholder: @field.placeholder
8
+ },
9
+ class: classes("w-full"),
10
+ data: @field.get_html(:data, view: view, element: :input),
11
+ disabled: @field.readonly,
12
+ style: @field.get_html(:style, view: view, element: :input),
13
+ value: @field.model.present? ? @field.model[@field.id] : @field.value,
14
+ placeholder: @field.include_blank.present? ? nil : @field.placeholder
15
+ %>
12
16
  <% end %>
@@ -18,10 +18,6 @@ class Avo::Index::Ordering::ButtonComponent < Avo::Index::Ordering::BaseComponen
18
18
  end
19
19
 
20
20
  def order_path(args)
21
- if reflection.present?
22
- Avo::App.view_context.avo.associations_order_path(reflection_parent_resource.route_key, params[:id], field.id, resource.model.id, **args)
23
- else
24
- Avo::App.view_context.avo.resources_order_path(resource.route_key, resource.model.id, **args)
25
- end
21
+ Avo::App.view_context.avo.reorder_order_path(resource.route_key, resource.model.id, **args)
26
22
  end
27
23
  end
@@ -34,7 +34,7 @@
34
34
  >
35
35
  <% if @resource.search_query.present? %>
36
36
  <div class="flex items-center px-4 w-64">
37
- <%= render partial: 'avo/partials/resource_search', locals: {resource: @resource.model_name.collection} %>
37
+ <%= render partial: 'avo/partials/resource_search', locals: {resource: @resource.route_key} %>
38
38
  </div>
39
39
  <% else %>
40
40
  <%# Offset for the space-y-2 property when the search is missing %>
@@ -11,10 +11,11 @@ module Avo
11
11
  include Avo::UrlHelpers
12
12
 
13
13
  protect_from_forgery with: :exception
14
+ around_action :set_avo_locale
15
+ around_action :set_force_locale, if: -> { params[:force_locale].present? }
16
+ before_action :set_default_locale, if: -> { params[:set_locale].present? }
14
17
  before_action :init_app
15
18
  before_action :check_avo_license
16
- before_action :set_default_locale
17
- around_action :set_force_locale, if: -> { params[:force_locale].present? }
18
19
  before_action :set_authorization
19
20
  before_action :_authenticate!
20
21
  before_action :set_container_classes
@@ -288,18 +289,23 @@ module Avo
288
289
  @resource.form_scope
289
290
  end
290
291
 
292
+ # Sets the locale set in avo.rb initializer
293
+ def set_avo_locale(&action)
294
+ locale = Avo.configuration.locale || I18n.default_locale
295
+ I18n.with_locale(locale, &action)
296
+ end
297
+
298
+ # Enable the user to change the default locale with the `?set_locale=pt-BR` param
291
299
  def set_default_locale
292
- I18n.locale = params[:set_locale] || I18n.default_locale
300
+ locale = params[:set_locale] || I18n.default_locale
293
301
 
294
- I18n.default_locale = I18n.locale
302
+ I18n.default_locale = locale
295
303
  end
296
304
 
297
305
  # Temporary set the locale and reverting at the end of the request.
298
- def set_force_locale
299
- initial_locale = I18n.locale.to_s.dup
300
- I18n.locale = params[:force_locale]
301
- yield
302
- I18n.locale = initial_locale
306
+ def set_force_locale(&action)
307
+ locale = params[:force_locale] || I18n.default_locale
308
+ I18n.with_locale(locale, &action)
303
309
  end
304
310
 
305
311
  def default_url_options
@@ -154,7 +154,7 @@ module Avo
154
154
 
155
155
  respond_to do |format|
156
156
  if saved
157
- format.html { redirect_to after_create_path, notice: "#{@model.class.name} #{t("avo.was_successfully_created")}." }
157
+ format.html { redirect_to after_create_path, notice: "#{@resource.name} #{t("avo.was_successfully_created")}." }
158
158
  else
159
159
  flash.now[:error] = t "avo.you_missed_something_check_form"
160
160
  format.html { render :new, status: :unprocessable_entity }
@@ -173,7 +173,7 @@ module Avo
173
173
 
174
174
  respond_to do |format|
175
175
  if saved
176
- format.html { redirect_to after_update_path, notice: "#{@model.class.name} #{t("avo.was_successfully_updated")}." }
176
+ format.html { redirect_to after_update_path, notice: "#{@resource.name} #{t("avo.was_successfully_updated")}." }
177
177
  else
178
178
  flash.now[:error] = t "avo.you_missed_something_check_form"
179
179
  format.html { render :edit, status: :unprocessable_entity }
@@ -370,6 +370,8 @@ module Avo
370
370
  def set_edit_title_and_breadcrumbs
371
371
  @resource = @resource.hydrate(model: @model, view: :edit, user: _current_user)
372
372
  @page_title = @resource.default_panel_name.to_s
373
+
374
+ last_crumb_args = {}
373
375
  # If we're accessing this resource via another resource add the parent to the breadcrumbs.
374
376
  if params[:via_resource_class].present? && params[:via_resource_id].present?
375
377
  via_resource = Avo::App.get_resource_by_model_name params[:via_resource_class]
@@ -378,11 +380,17 @@ module Avo
378
380
 
379
381
  add_breadcrumb via_resource.plural_name, resources_path(resource: @resource)
380
382
  add_breadcrumb via_resource.model_title, resource_path(model: via_model, resource: via_resource)
383
+ puts ["via_resource.model_title->", via_resource.model_title].inspect
384
+
385
+ last_crumb_args = {
386
+ via_resource_class: params[:via_resource_class],
387
+ via_resource_id: params[:via_resource_id]
388
+ }
381
389
  else
382
390
  add_breadcrumb @resource.plural_name.humanize, resources_path(resource: @resource)
383
391
  end
384
392
 
385
- add_breadcrumb @resource.model_title, resource_path(model: @resource.model, resource: @resource)
393
+ add_breadcrumb @resource.model_title, resource_path(model: @resource.model, resource: @resource, **last_crumb_args)
386
394
  add_breadcrumb t("avo.edit").humanize
387
395
  end
388
396
 
@@ -0,0 +1,25 @@
1
+ require_dependency "avo/application_controller"
2
+
3
+ module Avo
4
+ class ReorderController < ApplicationController
5
+ before_action :set_resource_name
6
+ before_action :set_resource
7
+ before_action :hydrate_resource
8
+ before_action :set_model
9
+
10
+ def order
11
+ direction = params[:direction].to_sym
12
+
13
+ if direction.present?
14
+ @resource
15
+ .hydrate(model: @model, params: params)
16
+ .ordering_host
17
+ .order direction
18
+ end
19
+
20
+ respond_to do |format|
21
+ format.html { redirect_to params[:referrer] || resources_path(resource: @resource) }
22
+ end
23
+ end
24
+ end
25
+ end
@@ -132,5 +132,11 @@ module Avo
132
132
  model.class
133
133
  end
134
134
  end
135
+
136
+ def root_path_without_url
137
+ Avo::App.root_path.to_s.delete_prefix(request.base_url.to_s).delete_suffix "/"
138
+ rescue
139
+ Avo.configuration.root_path
140
+ end
135
141
  end
136
142
  end
@@ -76,9 +76,5 @@ module Avo
76
76
 
77
77
  avo.resources_associations_index_path(parent_model.model_name.route_key, record.id, **existing_params, **args)
78
78
  end
79
-
80
- def order_up_resource_path(model:, resource:, **args)
81
- avo.send :"order_up_resources_#{resource.singular_route_key}_path", model, **args
82
- end
83
79
  end
84
80
  end