avo 2.21.0 → 2.21.1.pre.issue1444
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.
Potentially problematic release.
This version of avo might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/app/components/avo/empty_state_component.html.erb +1 -1
- data/app/components/avo/empty_state_component.rb +10 -12
- data/app/components/avo/fields/belongs_to_field/edit_component.rb +1 -1
- data/app/components/avo/fields/boolean_field/edit_component.html.erb +1 -1
- data/app/components/avo/fields/boolean_group_field/edit_component.html.erb +1 -1
- data/app/components/avo/fields/code_field/edit_component.html.erb +2 -2
- data/app/components/avo/fields/country_field/edit_component.html.erb +1 -1
- data/app/components/avo/fields/date_field/edit_component.html.erb +2 -2
- data/app/components/avo/fields/date_time_field/edit_component.html.erb +2 -2
- data/app/components/avo/fields/edit_component.rb +0 -4
- data/app/components/avo/fields/external_image_field/edit_component.html.erb +1 -1
- data/app/components/avo/fields/file_field/edit_component.html.erb +1 -1
- data/app/components/avo/fields/files_field/edit_component.html.erb +1 -1
- data/app/components/avo/fields/has_one_field/show_component.html.erb +3 -3
- data/app/components/avo/fields/markdown_field/edit_component.html.erb +1 -1
- data/app/components/avo/fields/markdown_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/number_field/edit_component.html.erb +1 -1
- data/app/components/avo/fields/password_field/edit_component.html.erb +1 -1
- data/app/components/avo/fields/progress_bar_field/edit_component.html.erb +1 -1
- data/app/components/avo/fields/select_field/edit_component.html.erb +1 -1
- data/app/components/avo/fields/show_component.rb +0 -4
- data/app/components/avo/fields/status_field/edit_component.html.erb +1 -1
- data/app/components/avo/fields/tags_field/edit_component.html.erb +2 -2
- data/app/components/avo/fields/text_field/edit_component.html.erb +1 -1
- data/app/components/avo/fields/textarea_field/edit_component.html.erb +1 -1
- data/app/components/avo/fields/time_field/edit_component.html.erb +2 -2
- data/app/components/avo/fields/trix_field/edit_component.html.erb +2 -3
- data/app/components/avo/fields/trix_field/edit_component.rb +1 -5
- data/app/components/avo/index/resource_grid_component.html.erb +1 -1
- data/app/components/avo/index/resource_table_component.rb +3 -3
- data/app/components/avo/paginator_component.html.erb +5 -1
- data/app/components/avo/paginator_component.rb +0 -8
- data/app/components/avo/resource_component.rb +2 -17
- data/app/components/avo/views/resource_index_component.html.erb +1 -1
- data/app/controllers/avo/attachments_controller.rb +0 -4
- data/app/controllers/avo/base_controller.rb +2 -8
- data/app/controllers/avo/dashboards/cards_controller.rb +1 -1
- data/app/controllers/avo/search_controller.rb +5 -11
- data/app/javascript/js/controllers/fields/trix_field_controller.js +3 -6
- data/app/javascript/js/controllers/item_select_all_controller.js +4 -7
- data/app/views/avo/actions/show.html.erb +1 -1
- data/app/views/avo/base/_multiple_select_filter.html.erb +1 -1
- data/app/views/avo/partials/_resource_search.html.erb +1 -1
- data/config/i18n-tasks.yml +1 -1
- data/config/initializers/pagy.rb +0 -16
- data/config/master.key +1 -0
- data/lib/avo/base_action.rb +0 -8
- data/lib/avo/base_card.rb +2 -5
- data/lib/avo/base_resource.rb +2 -3
- data/lib/avo/concerns/handles_field_args.rb +1 -8
- data/lib/avo/fields/base_field.rb +1 -2
- data/lib/avo/fields/select_field.rb +1 -1
- data/lib/avo/services/authorization_service.rb +2 -2
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/templates/field/components/edit_component.html.erb.tt +1 -1
- data/lib/generators/avo/templates/locales/avo.en.yml +2 -3
- data/lib/generators/avo/templates/locales/avo.fr.yml +2 -3
- data/lib/generators/avo/templates/locales/avo.nb.yml +2 -3
- data/lib/generators/avo/templates/locales/avo.nn.yml +2 -3
- data/lib/generators/avo/templates/locales/avo.pt-BR.yml +2 -3
- data/lib/generators/avo/templates/locales/avo.ro.yml +55 -56
- data/lib/generators/avo/templates/locales/avo.tr.yml +2 -3
- data/public/avo-assets/avo.base.js +2 -2
- data/public/avo-assets/avo.base.js.map +2 -2
- metadata +5 -9
- data/lib/avo/fields/concerns/is_disabled.rb +0 -19
- data/lib/avo/hosts/resource_record_host.rb +0 -7
- data/lib/generators/avo/templates/locales/avo.pt.yml +0 -120
- data/lib/generators/avo/templates/locales/pagy/nn.yml +0 -15
- data/lib/generators/avo/templates/locales/pagy/ro.yml +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24cf9486da47ba10e6a5daa1580d555a14c87f9c642a5a8d56d69a9f47784f4e
|
4
|
+
data.tar.gz: e85a3b0a6bc76ba138b523601a64a74539559d919a4c984dc18a7361304527e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34db8a5f063bef99fd6a4cdb5cc72df589e1f0329286ec7f22653de5c96a47788a7c9ad82a7197b11acb90355f9c8f5fd4ba594bf29dace1613d74d31a520917
|
7
|
+
data.tar.gz: 05b2170b8af382365f157c31335b1f913f44a7d5117fe22a1cf6130200362b788812315604e7836570e384a1f2708d58625503aad2fcbbad3a738cb2163ba0f1
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
avo (2.21.
|
4
|
+
avo (2.21.1.pre.issue1444)
|
5
5
|
actionview (>= 6.0)
|
6
6
|
active_link_to
|
7
7
|
activerecord (>= 6.0)
|
@@ -409,7 +409,7 @@ GEM
|
|
409
409
|
tzinfo (2.0.5)
|
410
410
|
concurrent-ruby (~> 1.0)
|
411
411
|
unicode-display_width (2.2.0)
|
412
|
-
view_component (2.
|
412
|
+
view_component (2.77.0)
|
413
413
|
activesupport (>= 5.0.0, < 8.0)
|
414
414
|
concurrent-ruby (~> 1.0)
|
415
415
|
method_source (~> 1.0)
|
@@ -1,26 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Avo::EmptyStateComponent < ViewComponent::Base
|
4
|
-
|
5
|
-
|
6
|
-
def initialize(message: nil, view_type: :table, add_background: false, by_association: false)
|
4
|
+
def initialize(message: nil, resource_name: nil, related_name: nil, view_type: :table, add_background: false)
|
7
5
|
@message = message
|
8
6
|
@view_type = view_type
|
7
|
+
@related_name = related_name
|
8
|
+
@resource_name = resource_name
|
9
9
|
@add_background = add_background
|
10
|
-
@by_association = by_association
|
11
10
|
end
|
12
11
|
|
13
|
-
def
|
14
|
-
message
|
15
|
-
end
|
12
|
+
def message
|
13
|
+
return @message if @message.present?
|
16
14
|
|
17
|
-
|
18
|
-
|
15
|
+
translation_tag = @related_name.present? ? 'avo.no_related_item_found' : 'avo.no_item_found'
|
16
|
+
helpers.t translation_tag, item: @resource_name
|
19
17
|
end
|
20
18
|
|
21
|
-
|
19
|
+
def view_type_svg
|
20
|
+
return "grid-empty-state" if @view_type.to_sym == :grid
|
22
21
|
|
23
|
-
|
24
|
-
helpers.t by_association ? 'avo.no_related_item_found' : 'avo.no_item_found'
|
22
|
+
"table-empty-state"
|
25
23
|
end
|
26
24
|
end
|
@@ -8,7 +8,7 @@ class Avo::Fields::BelongsToField::EditComponent < Avo::Fields::EditComponent
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def disabled
|
11
|
-
return true if @field.is_readonly?
|
11
|
+
return true if @field.is_readonly?
|
12
12
|
|
13
13
|
# When visiting the record through it's association we keep the field disabled by default
|
14
14
|
# We make an exception when the user deliberately instructs Avo to allow detaching in this scenario
|
@@ -4,7 +4,7 @@
|
|
4
4
|
checked: @field.value,
|
5
5
|
class: "text-lg h-4 w-4 checked:bg-primary-400 focus:checked:!bg-primary-400 #{@field.get_html(:classes, view: view, element: :input)}",
|
6
6
|
data: @field.get_html(:data, view: view, element: :input),
|
7
|
-
disabled:
|
7
|
+
disabled: @field.is_readonly?,
|
8
8
|
style: @field.get_html(:style, view: view, element: :input)
|
9
9
|
%>
|
10
10
|
</div>
|
@@ -20,7 +20,7 @@
|
|
20
20
|
<%= check_box_tag "#{model_param_key}[#{@field.id}][]", id, checked, {
|
21
21
|
class: "w-4 h-4 #{@field.get_html(:classes, view: view, element: :input)}",
|
22
22
|
data: @field.get_html(:data, view: view, element: :input),
|
23
|
-
disabled:
|
23
|
+
disabled: @field.is_readonly?,
|
24
24
|
id: "#{model_param_key}_#{@field.id}_#{id}",
|
25
25
|
style: @field.get_html(:style, view: view, element: :input)
|
26
26
|
} %> <%= label %>
|
@@ -8,12 +8,12 @@
|
|
8
8
|
language: @field.language,
|
9
9
|
theme: @field.theme,
|
10
10
|
'tab-size': @field.tab_size,
|
11
|
-
'read-only':
|
11
|
+
'read-only': @field.is_readonly?,
|
12
12
|
'indent-with-tabs': @field.indent_with_tabs,
|
13
13
|
'line-wrapping': @field.line_wrapping,
|
14
14
|
**@field.get_html(:data, view: view, element: :input),
|
15
15
|
},
|
16
|
-
disabled:
|
16
|
+
disabled: @field.is_readonly?,
|
17
17
|
placeholder: @field.placeholder,
|
18
18
|
style: @field.get_html(:style, view: view, element: :input)
|
19
19
|
%>
|
@@ -8,7 +8,7 @@
|
|
8
8
|
},
|
9
9
|
class: classes("w-full"),
|
10
10
|
data: @field.get_html(:data, view: view, element: :input),
|
11
|
-
disabled:
|
11
|
+
disabled: @field.is_readonly?,
|
12
12
|
style: @field.get_html(:style, view: view, element: :input),
|
13
13
|
placeholder: @field.include_blank.present? ? nil : @field.placeholder
|
14
14
|
%>
|
@@ -18,7 +18,7 @@
|
|
18
18
|
placeholder: @field.placeholder,
|
19
19
|
**@field.get_html(:data, view: view, element: :input)
|
20
20
|
},
|
21
|
-
disabled:
|
21
|
+
disabled: @field.is_readonly?,
|
22
22
|
placeholder: @field.placeholder,
|
23
23
|
style: @field.get_html(:style, view: view, element: :input)
|
24
24
|
%>
|
@@ -30,7 +30,7 @@
|
|
30
30
|
placeholder: @field.placeholder,
|
31
31
|
**@field.get_html(:data, view: view, element: :input)
|
32
32
|
},
|
33
|
-
disabled:
|
33
|
+
disabled: @field.is_readonly?,
|
34
34
|
placeholder: @field.placeholder,
|
35
35
|
style: @field.get_html(:style, view: view, element: :input)
|
36
36
|
%>
|
@@ -20,7 +20,7 @@
|
|
20
20
|
placeholder: @field.placeholder,
|
21
21
|
**@field.get_html(:data, view: view, element: :input)
|
22
22
|
},
|
23
|
-
disabled:
|
23
|
+
disabled: @field.is_readonly?,
|
24
24
|
placeholder: @field.placeholder,
|
25
25
|
style: @field.get_html(:style, view: view, element: :input)
|
26
26
|
%>
|
@@ -32,7 +32,7 @@
|
|
32
32
|
placeholder: @field.placeholder,
|
33
33
|
**@field.get_html(:data, view: view, element: :input)
|
34
34
|
},
|
35
|
-
disabled:
|
35
|
+
disabled: @field.is_readonly?,
|
36
36
|
placeholder: @field.placeholder,
|
37
37
|
style: @field.get_html(:style, view: view, element: :input)
|
38
38
|
%>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<%= @form.text_field @field.id,
|
3
3
|
class: classes("w-full"),
|
4
4
|
data: @field.get_html(:data, view: view, element: :input),
|
5
|
-
disabled:
|
5
|
+
disabled: @field.is_readonly?,
|
6
6
|
placeholder: @field.placeholder,
|
7
7
|
style: @field.get_html(:style, view: view, element: :input)
|
8
8
|
%>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
accept: @field.accept,
|
11
11
|
data: @field.get_html(:data, view: view, element: :input),
|
12
12
|
direct_upload: @field.direct_upload,
|
13
|
-
disabled:
|
13
|
+
disabled: @field.is_readonly?,
|
14
14
|
style: @field.get_html(:style, view: view, element: :input),
|
15
15
|
class: "w-full"
|
16
16
|
%>
|
@@ -7,7 +7,7 @@
|
|
7
7
|
accept: @field.accept,
|
8
8
|
data: @field.get_html(:data, view: view, element: :input),
|
9
9
|
direct_upload: @field.direct_upload,
|
10
|
-
disabled:
|
10
|
+
disabled: @field.is_readonly?,
|
11
11
|
multiple: true,
|
12
12
|
style: @field.get_html(:style, view: view, element: :input),
|
13
13
|
class: "w-full"
|
@@ -5,7 +5,7 @@
|
|
5
5
|
<% else %>
|
6
6
|
<%= render Avo::PanelComponent.new(name: @field.name) do |c| %>
|
7
7
|
<% c.tools do %>
|
8
|
-
<% if !@field.is_readonly? &&
|
8
|
+
<% if !@field.is_readonly? && can_attach? %>
|
9
9
|
<%= a_link attach_path,
|
10
10
|
icon: 'heroicons/outline/link',
|
11
11
|
color: :primary,
|
@@ -13,7 +13,7 @@
|
|
13
13
|
<%= t('avo.attach_item', item: @field.name.downcase) %>
|
14
14
|
<% end %>
|
15
15
|
<% end %>
|
16
|
-
<% if !@field.is_readonly? &&
|
16
|
+
<% if !@field.is_readonly? && can_see_the_create_button? %>
|
17
17
|
<%= a_link create_path,
|
18
18
|
icon: 'heroicons/outline/plus',
|
19
19
|
'data-target': 'create',
|
@@ -27,7 +27,7 @@
|
|
27
27
|
|
28
28
|
<% c.body do %>
|
29
29
|
<div class="py-8 flex justify-center items-center">
|
30
|
-
<%= empty_state
|
30
|
+
<%= empty_state resource_name: @field.id, related_name: params[:related_name] %>
|
31
31
|
</div>
|
32
32
|
<% end %>
|
33
33
|
<% end %>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<%= text_area_tag @field.id, @field.value,
|
4
4
|
class: helpers.input_classes('w-full js-has-simple-mde-editor'),
|
5
5
|
placeholder: @field.placeholder,
|
6
|
-
disabled:
|
6
|
+
disabled: @field.is_readonly?,
|
7
7
|
'data-simple-mde-target': 'element',
|
8
8
|
'data-component-options': @field.options.to_json,
|
9
9
|
'data-view': :show %>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<%= @form.password_field @field.id,
|
3
3
|
class: classes("w-full"),
|
4
4
|
data: @field.get_html(:data, view: view, element: :input),
|
5
|
-
disabled:
|
5
|
+
disabled: @field.is_readonly?,
|
6
6
|
placeholder: @field.placeholder,
|
7
7
|
style: @field.get_html(:style, view: view, element: :input)
|
8
8
|
%>
|
@@ -7,7 +7,7 @@
|
|
7
7
|
<%= @form.range_field @field.id,
|
8
8
|
class: "w-full #{@field.get_html(:classes, view: view, element: :input)}",
|
9
9
|
data: @field.get_html(:data, view: view, element: :input),
|
10
|
-
disabled:
|
10
|
+
disabled: @field.is_readonly?,
|
11
11
|
max: @field.max,
|
12
12
|
min: 0,
|
13
13
|
placeholder: @field.placeholder,
|
@@ -7,7 +7,7 @@
|
|
7
7
|
},
|
8
8
|
class: classes("w-full"),
|
9
9
|
data: @field.get_html(:data, view: view, element: :input),
|
10
|
-
disabled:
|
10
|
+
disabled: @field.is_readonly?,
|
11
11
|
style: @field.get_html(:style, view: view, element: :input),
|
12
12
|
value: @field.model.present? ? @field.model[@field.id] : @field.value,
|
13
13
|
placeholder: @field.include_blank.present? ? nil : @field.placeholder
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<%= @form.text_field @field.id,
|
3
3
|
class: classes("w-full"),
|
4
4
|
data: @field.get_html(:data, view: view, element: :input),
|
5
|
-
disabled:
|
5
|
+
disabled: @field.is_readonly?,
|
6
6
|
placeholder: @field.placeholder,
|
7
7
|
style: @field.get_html(:style, view: view, element: :input),
|
8
8
|
value: @resource.model.present? ? @resource.model[@field.id] : @field.value
|
@@ -6,7 +6,7 @@
|
|
6
6
|
data: {
|
7
7
|
'tags-field-target': 'fakeInput',
|
8
8
|
},
|
9
|
-
disabled:
|
9
|
+
disabled: @field.is_readonly?,
|
10
10
|
placeholder: @field.placeholder,
|
11
11
|
style: @field.get_html(:style, view: view, element: :input),
|
12
12
|
value: ''
|
@@ -22,7 +22,7 @@
|
|
22
22
|
'delimiters': @field.delimiters,
|
23
23
|
'close-on-select': @field.close_on_select ? 1 : 0,
|
24
24
|
},
|
25
|
-
disabled:
|
25
|
+
disabled: @field.is_readonly?,
|
26
26
|
placeholder: @field.placeholder,
|
27
27
|
style: @field.get_html(:style, view: view, element: :input),
|
28
28
|
value: @field.field_value.to_json
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<%= form.text_field @field.id,
|
3
3
|
class: classes("w-full"),
|
4
4
|
data: @field.get_html(:data, view: view, element: :input),
|
5
|
-
disabled:
|
5
|
+
disabled: @field.is_readonly?,
|
6
6
|
placeholder: @field.placeholder,
|
7
7
|
style: @field.get_html(:style, view: view, element: :input),
|
8
8
|
# value: @field.value,
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<%= @form.text_area @field.id,
|
3
3
|
class: classes("w-full"),
|
4
4
|
data: @field.get_html(:data, view: view, element: :input),
|
5
|
-
disabled:
|
5
|
+
disabled: @field.is_readonly?,
|
6
6
|
placeholder: @field.placeholder,
|
7
7
|
rows: @field.rows,
|
8
8
|
style: @field.get_html(:style, view: view, element: :input)
|
@@ -20,7 +20,7 @@
|
|
20
20
|
placeholder: @field.placeholder,
|
21
21
|
**@field.get_html(:data, view: view, element: :input)
|
22
22
|
},
|
23
|
-
disabled:
|
23
|
+
disabled: @field.is_readonly?,
|
24
24
|
placeholder: @field.placeholder,
|
25
25
|
style: @field.get_html(:style, view: view, element: :input)
|
26
26
|
%>
|
@@ -32,7 +32,7 @@
|
|
32
32
|
placeholder: @field.placeholder,
|
33
33
|
**@field.get_html(:data, view: view, element: :input)
|
34
34
|
},
|
35
|
-
disabled:
|
35
|
+
disabled: @field.is_readonly?,
|
36
36
|
placeholder: @field.placeholder,
|
37
37
|
style: @field.get_html(:style, view: view, element: :input)
|
38
38
|
%>
|
@@ -1,6 +1,5 @@
|
|
1
1
|
<%= field_wrapper **field_wrapper_args, full_width: true do %>
|
2
|
-
<%= content_tag :div,
|
3
|
-
class: "relative block overflow-x-auto max-w-full",
|
2
|
+
<%= content_tag :div, class: "relative block overflow-x-auto max-w-full",
|
4
3
|
data: {
|
5
4
|
controller: "trix-field",
|
6
5
|
trix_field_target: "controller",
|
@@ -25,7 +24,7 @@
|
|
25
24
|
<%= @form.text_area @field.id,
|
26
25
|
class: classes("w-full hidden"),
|
27
26
|
data: @field.get_html(:data, view: view, element: :input),
|
28
|
-
disabled:
|
27
|
+
disabled: @field.is_readonly?,
|
29
28
|
id: trix_id,
|
30
29
|
placeholder: @field.placeholder,
|
31
30
|
style: @field.get_html(:style, view: view, element: :input)
|
@@ -20,10 +20,6 @@ class Avo::Fields::TrixField::EditComponent < Avo::Fields::EditComponent
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def trix_id
|
23
|
-
|
24
|
-
"trix_#{resource_name}_#{@field.id}"
|
25
|
-
elsif form.present?
|
26
|
-
"trix_#{form.index}_#{@field.id}"
|
27
|
-
end
|
23
|
+
"trix_#{resource_name}_#{@field.id}"
|
28
24
|
end
|
29
25
|
end
|
@@ -9,6 +9,6 @@
|
|
9
9
|
</div>
|
10
10
|
<% else %>
|
11
11
|
<div class="bg-white rounded shadow-panel">
|
12
|
-
<%= helpers.empty_state
|
12
|
+
<%= helpers.empty_state resource_name: @resource.name.downcase.pluralize, related_name: params[:related_name], view_type: :grid %>
|
13
13
|
</div>
|
14
14
|
<% end %>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
class Avo::Index::ResourceTableComponent < ViewComponent::Base
|
4
4
|
include Avo::ApplicationHelper
|
5
|
-
attr_reader :pagy
|
5
|
+
attr_reader :pagy
|
6
6
|
|
7
7
|
def initialize(resources: nil, resource: nil, reflection: nil, parent_model: nil, parent_resource: nil, pagy: nil, query: nil)
|
8
8
|
@resources = resources
|
@@ -15,10 +15,10 @@ class Avo::Index::ResourceTableComponent < ViewComponent::Base
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def encrypted_query
|
18
|
-
return
|
18
|
+
return if @query.nil?
|
19
19
|
|
20
20
|
Avo::Services::EncryptionService.encrypt(
|
21
|
-
message: query.all.to_sql,
|
21
|
+
message: @query.all.to_sql,
|
22
22
|
purpose: :select_all
|
23
23
|
)
|
24
24
|
end
|
@@ -25,7 +25,11 @@
|
|
25
25
|
%> <%= t('avo.per_page').downcase %>
|
26
26
|
</div>
|
27
27
|
<% per_page_options.each do |option| %>
|
28
|
-
|
28
|
+
<% if parent_model.present? %>
|
29
|
+
<%= link_to "Change to #{option} items per page", helpers.related_resources_path(parent_model, parent_model, per_page: option, keep_query_params: true, page: 1), class: 'hidden', 'data-per-page-option': option, 'data-turbo-frame': turbo_frame %>
|
30
|
+
<% else %>
|
31
|
+
<%= link_to "Change to #{option} items per page", helpers.resources_path(resource: resource, per_page: option, keep_query_params: true, page: 1), class: 'hidden', 'data-per-page-option': option, 'data-turbo-frame': turbo_frame %>
|
32
|
+
<% end %>
|
29
33
|
<% end %>
|
30
34
|
</div>
|
31
35
|
</div>
|
@@ -16,12 +16,4 @@ class Avo::PaginatorComponent < ViewComponent::Base
|
|
16
16
|
@parent_model = parent_model
|
17
17
|
@discreet_pagination = discreet_pagination
|
18
18
|
end
|
19
|
-
|
20
|
-
def change_items_per_page_url(option)
|
21
|
-
if parent_model.present?
|
22
|
-
helpers.related_resources_path(parent_model, parent_model, per_page: option, keep_query_params: true, page: 1)
|
23
|
-
else
|
24
|
-
helpers.resources_path(resource: resource, per_page: option, keep_query_params: true, page: 1)
|
25
|
-
end
|
26
|
-
end
|
27
19
|
end
|
@@ -53,7 +53,6 @@ class Avo::ResourceComponent < Avo::BaseComponent
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
# Ex: A Post has many Comments
|
57
56
|
def authorize_association_for(policy_method)
|
58
57
|
policy_result = true
|
59
58
|
|
@@ -68,25 +67,11 @@ class Avo::ResourceComponent < Avo::BaseComponent
|
|
68
67
|
|
69
68
|
if association_name.present?
|
70
69
|
method_name = "#{policy_method}_#{association_name}?".to_sym
|
71
|
-
|
72
|
-
# Use the policy methods from the parent (Post)
|
70
|
+
# Prepare the authorization service
|
73
71
|
service = reflection_resource.authorization
|
74
72
|
|
75
73
|
if service.has_method?(method_name, raise_exception: false)
|
76
|
-
|
77
|
-
# Example: Post->has_many->Comments
|
78
|
-
# When you want to authorize the creation/attaching of a Comment, you don't have the Comment instance.
|
79
|
-
# But you do have the Post instance and you can get that in your policy to authorize against.
|
80
|
-
parent_policy_methods = [:view, :create, :attach, :act_on]
|
81
|
-
|
82
|
-
record = if parent_policy_methods.include?(policy_method)
|
83
|
-
# Use the parent record (Post)
|
84
|
-
reflection_resource.model
|
85
|
-
else
|
86
|
-
# Override the record with the child record (Comment)
|
87
|
-
resource.model
|
88
|
-
end
|
89
|
-
policy_result = service.authorize_action(method_name, record: record, raise_exception: false)
|
74
|
+
policy_result = service.authorize_action(method_name, raise_exception: false)
|
90
75
|
end
|
91
76
|
end
|
92
77
|
end
|
@@ -52,7 +52,7 @@
|
|
52
52
|
<%= render(Avo::Index::ResourceTableComponent.new(resources: @resources, resource: @resource, reflection: @reflection, parent_model: @parent_model, parent_resource: @parent_resource, pagy: @pagy, query: @query)) %>
|
53
53
|
</div>
|
54
54
|
<% else %>
|
55
|
-
<%= helpers.empty_state
|
55
|
+
<%= helpers.empty_state resource_name: @resource.name.downcase.pluralize, related_name: params[:related_name], view_type: view_type, add_background: true %>
|
56
56
|
<% end %>
|
57
57
|
<% end %>
|
58
58
|
<% end %>
|
@@ -10,10 +10,6 @@ module Avo
|
|
10
10
|
blob = ActiveStorage::Blob.create_and_upload! io: params[:file], filename: params[:filename]
|
11
11
|
association_name = BaseResource.valid_attachment_name(@model, params[:attachment_key])
|
12
12
|
|
13
|
-
if association_name.blank?
|
14
|
-
raise ActionController::BadRequest.new("Could not find the attachment association for #{params[:attachment_key]} (check the `attachment_key` for this Trix field)")
|
15
|
-
end
|
16
|
-
|
17
13
|
@model.send(association_name).attach blob
|
18
14
|
|
19
15
|
render json: {
|
@@ -14,7 +14,6 @@ module Avo
|
|
14
14
|
before_action :fill_model, only: [:create, :update]
|
15
15
|
# Don't run base authorizations for associations
|
16
16
|
before_action :authorize_base_action, if: -> { controller_name != "associations" }
|
17
|
-
before_action :set_pagy_locale, only: :index
|
18
17
|
|
19
18
|
def index
|
20
19
|
@page_title = @resource.plural_name.humanize
|
@@ -224,11 +223,11 @@ module Avo
|
|
224
223
|
# In case there's an error somewhere else than the model
|
225
224
|
# Example: When you save a license that should create a user for it and creating that user throws and error.
|
226
225
|
# Example: When you Try to delete a record and has a foreign key constraint.
|
227
|
-
|
226
|
+
@errors = Array.wrap(exception.message)
|
228
227
|
end
|
229
228
|
|
230
229
|
# Add the errors from the model
|
231
|
-
@errors = @model.errors.full_messages.
|
230
|
+
@errors = Array.wrap([@errors, @model.errors.full_messages]).compact
|
232
231
|
|
233
232
|
succeeded
|
234
233
|
end
|
@@ -511,10 +510,5 @@ module Avo
|
|
511
510
|
def is_associated_record?
|
512
511
|
params[:via_relation_class].present? && params[:via_resource_id].present?
|
513
512
|
end
|
514
|
-
|
515
|
-
# Set pagy locale from params or from avo configuration, if both nil locale = "en"
|
516
|
-
def set_pagy_locale
|
517
|
-
@pagy_locale = locale.to_s || Avo.configuration.locale || "en"
|
518
|
-
end
|
519
513
|
end
|
520
514
|
end
|
@@ -44,33 +44,27 @@ module Avo
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def search_resource(resource)
|
47
|
-
query =
|
47
|
+
query = Avo::Hosts::SearchScopeHost.new(
|
48
48
|
block: resource.search_query,
|
49
49
|
params: params,
|
50
|
-
scope: resource.class.scope
|
50
|
+
scope: resource.class.scope.limit(8)
|
51
51
|
).handle
|
52
52
|
|
53
|
-
# Get the count
|
54
|
-
results_count = query.count
|
55
|
-
|
56
|
-
# Get the results
|
57
|
-
query = query.limit(8)
|
58
|
-
|
59
53
|
query = apply_scope(query) if should_apply_any_scope?
|
60
54
|
|
61
55
|
results = apply_search_metadata(query, resource)
|
62
56
|
|
63
57
|
header = resource.plural_name
|
64
58
|
|
65
|
-
if
|
66
|
-
header
|
59
|
+
if results.length > 0
|
60
|
+
header += " (#{results.length})"
|
67
61
|
end
|
68
62
|
|
69
63
|
result_object = {
|
70
64
|
header: header,
|
71
65
|
help: resource.class.search_query_help,
|
72
66
|
results: results,
|
73
|
-
count:
|
67
|
+
count: results.length
|
74
68
|
}
|
75
69
|
|
76
70
|
[resource.name.pluralize.downcase, result_object]
|
@@ -55,7 +55,7 @@ export default class extends Controller {
|
|
55
55
|
}
|
56
56
|
|
57
57
|
// Prevent file uploads for resources that haven't been saved yet.
|
58
|
-
if (
|
58
|
+
if (this.resourceId === '') {
|
59
59
|
event.preventDefault()
|
60
60
|
alert("You can't upload files into the Trix editor until you save the resource.")
|
61
61
|
|
@@ -63,7 +63,7 @@ export default class extends Controller {
|
|
63
63
|
}
|
64
64
|
|
65
65
|
// Prevent file uploads for fields without an attachment key.
|
66
|
-
if (
|
66
|
+
if (this.attachmentKey === '') {
|
67
67
|
event.preventDefault()
|
68
68
|
alert("You haven't set an `attachment_key` to this Trix field.")
|
69
69
|
}
|
@@ -93,10 +93,7 @@ export default class extends Controller {
|
|
93
93
|
|
94
94
|
xhr.open('POST', this.uploadUrl, true)
|
95
95
|
|
96
|
-
|
97
|
-
if (csrfToken) {
|
98
|
-
xhr.setRequestHeader('X-CSRF-Token', csrfToken)
|
99
|
-
}
|
96
|
+
xhr.setRequestHeader('X-CSRF-Token', document.querySelector('meta[name="csrf-token"]').content)
|
100
97
|
|
101
98
|
xhr.upload.addEventListener('progress', (event) => {
|
102
99
|
// eslint-disable-next-line no-mixed-operators
|