avo 3.0.1.beta8 → 3.0.1.beta10
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/Rakefile +2 -0
- data/app/assets/builds/avo.base.css +17 -10
- data/app/components/avo/field_wrapper_component.html.erb +1 -1
- data/app/components/avo/fields/boolean_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/common/badge_viewer_component.html.erb +1 -25
- data/app/components/avo/fields/common/badge_viewer_component.rb +24 -0
- data/app/components/avo/fields/common/boolean_check_component.html.erb +1 -12
- data/app/components/avo/fields/common/boolean_check_component.rb +2 -1
- data/app/components/avo/fields/common/gravatar_viewer_component.html.erb +1 -1
- data/app/components/avo/fields/common/gravatar_viewer_component.rb +2 -2
- data/app/components/avo/fields/common/heading_component.html.erb +3 -8
- data/app/components/avo/fields/common/heading_component.rb +1 -3
- data/app/components/avo/fields/external_image_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/file_field/index_component.html.erb +2 -2
- data/app/components/avo/fields/gravatar_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/heading_field/edit_component.html.erb +1 -1
- data/app/components/avo/fields/heading_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/id_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/text_field/index_component.html.erb +1 -1
- data/app/components/avo/index/resource_table_component.rb +2 -8
- data/app/components/avo/views/resource_edit_component.html.erb +9 -20
- data/app/controllers/avo/actions_controller.rb +8 -19
- data/app/controllers/avo/application_controller.rb +12 -0
- data/app/controllers/avo/search_controller.rb +2 -2
- data/app/views/layouts/avo/application.html.erb +1 -2
- data/bin/dev +2 -0
- data/lib/avo/base_action.rb +18 -23
- data/lib/avo/base_resource.rb +1 -1
- data/lib/avo/concerns/filters_session_handler.rb +3 -3
- data/lib/avo/concerns/has_items.rb +0 -4
- data/lib/avo/fields/badge_field.rb +1 -1
- data/lib/avo/fields/base_field.rb +12 -8
- data/lib/avo/fields/external_image_field.rb +2 -2
- data/lib/avo/fields/file_field.rb +2 -2
- data/lib/avo/fields/gravatar_field.rb +2 -2
- data/lib/avo/fields/heading_field.rb +5 -13
- data/lib/avo/fields/id_field.rb +2 -2
- data/lib/avo/fields/text_field.rb +2 -2
- data/lib/avo/resources/items/holder.rb +0 -6
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/js/install_generator.rb +2 -2
- data/lib/generators/avo/tailwindcss/install_generator.rb +58 -12
- data/lib/generators/avo/templates/tailwindcss/avo.tailwind.css +5 -3
- data/lib/generators/avo/templates/tailwindcss/tailwind.config.js +11 -0
- data/lib/tasks/avo_tasks.rake +33 -5
- data/public/avo-assets/avo.base.css +51 -3962
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d41facc3b8991d0d8f35381b5e802fc6e21dafc7cff9fbb0e30d45c4ee4b159
|
4
|
+
data.tar.gz: 986a54076e03412e55025a97019bcaad9b7a5f6777fdbf4be5926d42e8d52e29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7fa3479f4793ffb0bfaa0cb13c7b0c8cbe2aaec8fcdd1c9b87d8e8a3b11e31f0e9ae5327cec3ac0b31c8726dd6ffdae06380f7b291f191ca5d9c4b2a1d3068f
|
7
|
+
data.tar.gz: 0cd9c8dd5438cb08cb5321e347d91a5e76a564c78b694781111a6481134adb0c94e063dcfdd92e221ee972d51e01a16b5d561e0c24093d10e9f3db66af779eab
|
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
@@ -3393,7 +3393,7 @@ body.dark,body[data-theme=dark]{
|
|
3393
3393
|
transition:inherit
|
3394
3394
|
}
|
3395
3395
|
|
3396
|
-
/*! tailwindcss v3.3.
|
3396
|
+
/*! tailwindcss v3.3.3 | MIT License | https://tailwindcss.com
|
3397
3397
|
*/
|
3398
3398
|
|
3399
3399
|
/*
|
@@ -3583,6 +3583,10 @@ select,
|
|
3583
3583
|
textarea {
|
3584
3584
|
font-family: inherit;
|
3585
3585
|
/* 1 */
|
3586
|
+
font-feature-settings: inherit;
|
3587
|
+
/* 1 */
|
3588
|
+
font-variation-settings: inherit;
|
3589
|
+
/* 1 */
|
3586
3590
|
font-size: 100%;
|
3587
3591
|
/* 1 */
|
3588
3592
|
font-weight: inherit;
|
@@ -3733,6 +3737,14 @@ menu {
|
|
3733
3737
|
padding: 0;
|
3734
3738
|
}
|
3735
3739
|
|
3740
|
+
/*
|
3741
|
+
Reset default styling for dialogs.
|
3742
|
+
*/
|
3743
|
+
|
3744
|
+
dialog {
|
3745
|
+
padding: 0;
|
3746
|
+
}
|
3747
|
+
|
3736
3748
|
/*
|
3737
3749
|
Prevent resizing textareas horizontally by default.
|
3738
3750
|
*/
|
@@ -6665,10 +6677,6 @@ tag.tagify__tag{
|
|
6665
6677
|
float:right
|
6666
6678
|
}
|
6667
6679
|
|
6668
|
-
.float-left{
|
6669
|
-
float:left
|
6670
|
-
}
|
6671
|
-
|
6672
6680
|
.m-0{
|
6673
6681
|
margin:0px
|
6674
6682
|
}
|
@@ -7809,11 +7817,6 @@ tag.tagify__tag{
|
|
7809
7817
|
background-color:rgb(57 158 229 / var(--tw-bg-opacity))
|
7810
7818
|
}
|
7811
7819
|
|
7812
|
-
.bg-blue-50{
|
7813
|
-
--tw-bg-opacity:1;
|
7814
|
-
background-color:rgb(230 243 252 / var(--tw-bg-opacity))
|
7815
|
-
}
|
7816
|
-
|
7817
7820
|
.bg-blue-500{
|
7818
7821
|
--tw-bg-opacity:1;
|
7819
7822
|
background-color:rgb(8 134 222 / var(--tw-bg-opacity))
|
@@ -10226,6 +10229,10 @@ trix-editor {
|
|
10226
10229
|
width:66.666667%
|
10227
10230
|
}
|
10228
10231
|
|
10232
|
+
.md\:w-full{
|
10233
|
+
width:100%
|
10234
|
+
}
|
10235
|
+
|
10229
10236
|
.md\:grid-cols-3{
|
10230
10237
|
grid-template-columns:repeat(3, minmax(0, 1fr))
|
10231
10238
|
}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
class: classes,
|
3
3
|
style: style,
|
4
4
|
data: data do %>
|
5
|
-
<div class="h-full <% if stacked? %> md:pt-4 <% else %> md:pt-0 <% if short? %> md:h-10 <% else %> md:h-14 <% end %> <% end %> pt-4 flex self-start items-center flex-shrink-0 <%= @field.get_html(:classes, view: view, element: :label) %> w-48 <% if compact? %> md:w-48 xl:w-64 <% else %> md:w-64 <% end %> px-6 uppercase font-semibold text-gray-500 text-sm" data-slot="label">
|
5
|
+
<div class="h-full <% if stacked? %> md:pt-4 md:w-full <% else %> md:pt-0 <% if short? %> md:h-10 <% else %> md:h-14 <% end %> <% end %> pt-4 flex self-start items-center flex-shrink-0 <%= @field.get_html(:classes, view: view, element: :label) %> w-48 <% if compact? %> md:w-48 xl:w-64 <% else %> md:w-64 <% end %> px-6 uppercase font-semibold text-gray-500 text-sm" data-slot="label">
|
6
6
|
<% if form.present? %>
|
7
7
|
<%= form.label field.id, label %>
|
8
8
|
<% else %>
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<%= index_field_wrapper **field_wrapper_args, dash_if_blank: false,
|
1
|
+
<%= index_field_wrapper **field_wrapper_args, dash_if_blank: false, flush: true do %>
|
2
2
|
<%= render Avo::Fields::Common::BooleanCheckComponent.new checked: @field.value %>
|
3
3
|
<% end %>
|
@@ -1,25 +1 @@
|
|
1
|
-
|
2
|
-
backgrounds = {
|
3
|
-
info: 'bg-blue-500',
|
4
|
-
success: 'bg-green-500',
|
5
|
-
danger: 'bg-red-500',
|
6
|
-
warning: 'bg-yellow-500',
|
7
|
-
secondary: 'bg-gray-500',
|
8
|
-
}
|
9
|
-
|
10
|
-
label = @value
|
11
|
-
background = :info
|
12
|
-
|
13
|
-
@options.invert.each do |values, type|
|
14
|
-
if [values].flatten.map { |value| value }.include? @value
|
15
|
-
label = @value
|
16
|
-
background = type.to_sym
|
17
|
-
next
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
classes = 'whitespace-nowrap rounded-md uppercase px-2 py-1 text-xs font-bold block text-center truncate '
|
22
|
-
|
23
|
-
classes += "#{backgrounds[background]} text-white" if backgrounds[background].present?
|
24
|
-
%>
|
25
|
-
<span class="<%= classes %>" style="max-width: 120px;"><%= label %></span>
|
1
|
+
<span class="<%= classes %>" style="max-width: 120px;"><%= @value %></span>
|
@@ -4,5 +4,29 @@ class Avo::Fields::Common::BadgeViewerComponent < ViewComponent::Base
|
|
4
4
|
def initialize(value:, options:)
|
5
5
|
@value = value
|
6
6
|
@options = options
|
7
|
+
@backgrounds = {
|
8
|
+
info: "bg-blue-500",
|
9
|
+
success: "bg-green-500",
|
10
|
+
danger: "bg-red-500",
|
11
|
+
warning: "bg-yellow-500",
|
12
|
+
neutral: "bg-gray-500"
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
def classes
|
17
|
+
background = :info
|
18
|
+
|
19
|
+
@options.invert.each do |values, type|
|
20
|
+
if [values].flatten.map { |value| value }.include? @value
|
21
|
+
background = type.to_sym
|
22
|
+
next
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
classes = "whitespace-nowrap rounded-md uppercase px-2 py-1 text-xs font-bold block text-center truncate "
|
27
|
+
|
28
|
+
classes += "#{@backgrounds[background]} text-white" if @backgrounds[background].present?
|
29
|
+
|
30
|
+
classes
|
7
31
|
end
|
8
32
|
end
|
@@ -1,12 +1 @@
|
|
1
|
-
|
2
|
-
classes = 'h-6 float-left mr-1'
|
3
|
-
|
4
|
-
if @checked
|
5
|
-
classes += ' text-green-600'
|
6
|
-
icon = 'heroicons/outline/check-circle'
|
7
|
-
else
|
8
|
-
classes += ' text-red-500'
|
9
|
-
icon = 'heroicons/outline/x-circle'
|
10
|
-
end
|
11
|
-
%>
|
12
|
-
<%= helpers.svg "#{icon}.svg", class: classes %>
|
1
|
+
<%= helpers.svg "#{@icon}.svg", class: @classes %>
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
class Avo::Fields::Common::BooleanCheckComponent < ViewComponent::Base
|
4
4
|
def initialize(checked: false)
|
5
|
-
@
|
5
|
+
@icon = checked ? "heroicons/outline/check-circle" : "heroicons/outline/x-circle"
|
6
|
+
@classes = "h-6 #{checked ? "text-green-600" : "text-red-500"}"
|
6
7
|
end
|
7
8
|
end
|
@@ -9,4 +9,4 @@
|
|
9
9
|
url = URI::HTTPS.build(host: "www.gravatar.com", path: "/avatar/#{@md5}", query: query)
|
10
10
|
classes = @rounded ? 'rounded-full' : ''
|
11
11
|
%>
|
12
|
-
<%= link_to_if @
|
12
|
+
<%= link_to_if @link_to_record.present?, image_tag(url.to_s, class: classes, width: options[:size], height: options[:size]), @link, title: @title %>
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Avo::Fields::Common::GravatarViewerComponent < ViewComponent::Base
|
4
|
-
def initialize(md5: nil, link: nil, default: nil, size: nil, rounded: false,
|
4
|
+
def initialize(md5: nil, link: nil, default: nil, size: nil, rounded: false, link_to_record: false, title: nil)
|
5
5
|
@md5 = md5
|
6
6
|
@link = link
|
7
7
|
@default = default
|
8
8
|
@size = size
|
9
9
|
@rounded = rounded
|
10
|
-
@
|
10
|
+
@link_to_record = link_to_record
|
11
11
|
@title = title
|
12
12
|
end
|
13
13
|
end
|
@@ -1,14 +1,9 @@
|
|
1
1
|
<div class="flex items-start py-1 leading-tight bg-gray-100 text-gray-500 text-xs">
|
2
2
|
<div class="py-2 px-6 h-full w-full">
|
3
|
-
<% if
|
4
|
-
|
5
|
-
<% if as_html %>
|
6
|
-
<%= sanitize value %>
|
7
|
-
<% else %>
|
8
|
-
<div class="font-semibold uppercase"><%= value %></div>
|
9
|
-
<% end %>
|
3
|
+
<% if as_html %>
|
4
|
+
<%= sanitize value %>
|
10
5
|
<% else %>
|
11
|
-
|
6
|
+
<div class="font-semibold uppercase"><%= value %></div>
|
12
7
|
<% end %>
|
13
8
|
</div>
|
14
9
|
</div>
|
@@ -3,11 +3,9 @@
|
|
3
3
|
class Avo::Fields::Common::HeadingComponent < ViewComponent::Base
|
4
4
|
attr_reader :value
|
5
5
|
attr_reader :as_html
|
6
|
-
attr_reader :empty
|
7
6
|
|
8
|
-
def initialize(value:, as_html
|
7
|
+
def initialize(value:, as_html:)
|
9
8
|
@value = value
|
10
9
|
@as_html = as_html
|
11
|
-
@empty = empty
|
12
10
|
end
|
13
11
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<%= index_field_wrapper **field_wrapper_args, flush: true do %>
|
2
2
|
<% if @field.value.present? %>
|
3
|
-
<%= link_to_if @field.
|
3
|
+
<%= link_to_if @field.link_to_record.present?,
|
4
4
|
image_tag(@field.value,
|
5
5
|
height: @field.height,
|
6
6
|
style: "border-radius: #{@field.radius}px; max-height: #{@field.height}#{@field.height.to_s&.ends_with?('px') ? '' : 'px'};"),
|
@@ -1,9 +1,9 @@
|
|
1
1
|
<%= index_field_wrapper **field_wrapper_args, flush: flush? do %>
|
2
2
|
<% if @field.value.present? %>
|
3
3
|
<% if @field.value.attached? && @field.value.representable? && @field.is_image %>
|
4
|
-
<%= link_to_if @field.
|
4
|
+
<%= link_to_if @field.link_to_record, image_tag(helpers.main_app.url_for(@field.value), class: 'h-10'), resource_view_path, class: 'block' %>
|
5
5
|
<% elsif @field.value.attached? && @field.is_audio %>
|
6
|
-
<%= link_to_if @field.
|
6
|
+
<%= link_to_if @field.link_to_record, audio_tag(helpers.main_app.url_for(@field.value), controls: true, preload: false, class: 'max-h-full h-10'), resource_view_path, class: 'block h-8' %>
|
7
7
|
<% else %>
|
8
8
|
<%= @field.value.filename %>
|
9
9
|
<% end %>
|
@@ -1,3 +1,3 @@
|
|
1
1
|
<div <% if @index == 0 %> class="overflow-hidden rounded-t" <% end %> data-field-id="<%= @field.id %>">
|
2
|
-
<%= render Avo::Fields::Common::HeadingComponent.new value: @field.
|
2
|
+
<%= render Avo::Fields::Common::HeadingComponent.new value: @field.value, as_html: @field.as_html %>
|
3
3
|
</div>
|
@@ -1,3 +1,3 @@
|
|
1
1
|
<div <% if @index == 0 %> class="overflow-hidden rounded-t" <% end %> data-field-id="<%= @field.id %>">
|
2
|
-
<%= render Avo::Fields::Common::HeadingComponent.new value: @field.
|
2
|
+
<%= render Avo::Fields::Common::HeadingComponent.new value: @field.value, as_html: @field.as_html %>
|
3
3
|
</div>
|
@@ -1,3 +1,3 @@
|
|
1
1
|
<%= index_field_wrapper **field_wrapper_args, class: 'whitespace-no-wrap w-[1%]' do %>
|
2
|
-
<% link_to_if (@field.
|
2
|
+
<% link_to_if (@field.link_to_record or Avo.configuration.id_links_to_resource), @field.value, resource_view_path, title: t('avo.view_item', item: @resource.name).humanize %>
|
3
3
|
<% end %>
|
@@ -4,6 +4,6 @@
|
|
4
4
|
<% elsif @field.protocol.present? %>
|
5
5
|
<%= link_to @field.value, "#{@field.protocol}:#{@field.value}" %>
|
6
6
|
<% else %>
|
7
|
-
<%= link_to_if @field.
|
7
|
+
<%= link_to_if @field.link_to_record, @field.value, resource_view_path %>
|
8
8
|
<% end %>
|
9
9
|
<% end %>
|
@@ -18,17 +18,11 @@ class Avo::Index::ResourceTableComponent < ViewComponent::Base
|
|
18
18
|
def encrypted_query
|
19
19
|
# TODO: move this to the resource where we can apply the adapter pattern
|
20
20
|
if Module.const_defined?("Ransack::Search") && query.instance_of?(Ransack::Search)
|
21
|
-
@query = query.result
|
21
|
+
@query = @query.result
|
22
22
|
end
|
23
23
|
|
24
|
-
return :select_all_disabled if query.nil? || !query.respond_to?(:all) || !query.all.respond_to?(:to_sql)
|
25
|
-
|
26
|
-
serialized_query = query.all.to_sql
|
27
|
-
|
28
|
-
return if serialized_query.nil?
|
29
|
-
|
30
24
|
Avo::Services::EncryptionService.encrypt(
|
31
|
-
message:
|
25
|
+
message: Marshal.dump(@query),
|
32
26
|
purpose: :select_all
|
33
27
|
)
|
34
28
|
end
|
@@ -44,26 +44,6 @@
|
|
44
44
|
<%= render sidebar_component form: form %>
|
45
45
|
<% end %>
|
46
46
|
<% end %>
|
47
|
-
<% if Avo.configuration.buttons_on_form_footers %>
|
48
|
-
<% c.with_footer_tools do %>
|
49
|
-
<div class="mt-4">
|
50
|
-
<%= a_link back_path,
|
51
|
-
style: :text,
|
52
|
-
icon: 'arrow-left' do %>
|
53
|
-
<%= t('avo.cancel').capitalize %>
|
54
|
-
<% end %>
|
55
|
-
<% if can_see_the_save_button? %>
|
56
|
-
<%= a_button color: :primary,
|
57
|
-
style: :primary,
|
58
|
-
loading: true,
|
59
|
-
type: :submit,
|
60
|
-
icon: 'save' do %>
|
61
|
-
<%= t('avo.save').capitalize %>
|
62
|
-
<% end %>
|
63
|
-
<% end %>
|
64
|
-
</div>
|
65
|
-
<% end %>
|
66
|
-
<% end %>
|
67
47
|
<% end %>
|
68
48
|
<%= content_tag :div, class: 'space-y-12' do %>
|
69
49
|
<% @resource.get_items.each_with_index do |item, index| %>
|
@@ -71,6 +51,15 @@
|
|
71
51
|
<%= render Avo::ItemSwitcherComponent.new resource: @resource, item: item, index: index + 1, view: view, form: form %>
|
72
52
|
<% end %>
|
73
53
|
<% end %>
|
54
|
+
<% if Avo.configuration.buttons_on_form_footers %>
|
55
|
+
<%= render Avo::PanelComponent.new do |c| %>
|
56
|
+
<% c.with_footer_tools do %>
|
57
|
+
<% @resource.render_edit_controls.each do |control| %>
|
58
|
+
<%= render_control control %>
|
59
|
+
<% end %>
|
60
|
+
<% end %>
|
61
|
+
<% end %>
|
62
|
+
<% end %>
|
74
63
|
<% end %>
|
75
64
|
<% end %>
|
76
65
|
<% end %>
|
@@ -21,23 +21,13 @@ module Avo
|
|
21
21
|
|
22
22
|
def handle
|
23
23
|
resource_ids = action_params[:fields][:avo_resource_ids].split(",")
|
24
|
-
@selected_query = action_params[:fields][:avo_selected_query]
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
args = {
|
29
|
-
fields: fields,
|
25
|
+
performed_action = @action.handle_action(
|
26
|
+
fields: action_params[:fields].except(:avo_resource_ids, :avo_selected_query),
|
30
27
|
current_user: _current_user,
|
31
|
-
resource: resource
|
32
|
-
|
33
|
-
|
34
|
-
args[:records] = if @selected_query.present?
|
35
|
-
@resource.model_class.find_by_sql decrypted_query
|
36
|
-
else
|
37
|
-
@resource.find_record resource_ids, params: params
|
38
|
-
end
|
39
|
-
|
40
|
-
performed_action = @action.handle_action(**args)
|
28
|
+
resource: resource,
|
29
|
+
query: decrypted_query || @resource.find_record(resource_ids, params: params)
|
30
|
+
)
|
41
31
|
|
42
32
|
respond performed_action.response
|
43
33
|
end
|
@@ -106,10 +96,9 @@ module Avo
|
|
106
96
|
end
|
107
97
|
|
108
98
|
def decrypted_query
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
)
|
99
|
+
return if (encrypted_query = action_params[:fields][:avo_selected_query]).blank?
|
100
|
+
|
101
|
+
Marshal.load(Avo::Services::EncryptionService.decrypt(message: encrypted_query, purpose: :select_all))
|
113
102
|
end
|
114
103
|
|
115
104
|
def decrypted_arguments
|
@@ -25,6 +25,7 @@ module Avo
|
|
25
25
|
before_action :add_initial_breadcrumbs
|
26
26
|
before_action :set_view
|
27
27
|
before_action :set_sidebar_open
|
28
|
+
before_action :set_stylesheet_assets_path
|
28
29
|
|
29
30
|
rescue_from Avo::NotAuthorizedError, with: :render_unauthorized
|
30
31
|
rescue_from ActiveRecord::RecordInvalid, with: :exception_logger
|
@@ -314,5 +315,16 @@ module Avo
|
|
314
315
|
rescue => exception
|
315
316
|
Avo.logger.debug "Failed to set ActiveStorage::Current.url_options, #{exception.inspect}"
|
316
317
|
end
|
318
|
+
|
319
|
+
def set_stylesheet_assets_path
|
320
|
+
# Prefer the user's tailwind config if it exists, otherwise use the default one from Avo
|
321
|
+
@stylesheet_assets_path = if Rails.root.join("config", "avo", "tailwind.config.js").exist?
|
322
|
+
"avo.tailwind"
|
323
|
+
elsif Avo::PACKED
|
324
|
+
"/avo-assets/avo.base"
|
325
|
+
else
|
326
|
+
"avo.base"
|
327
|
+
end
|
328
|
+
end
|
317
329
|
end
|
318
330
|
end
|
@@ -42,14 +42,14 @@ module Avo
|
|
42
42
|
query: resource.query_scope
|
43
43
|
).handle
|
44
44
|
|
45
|
+
query = apply_scope(query) if should_apply_any_scope?
|
46
|
+
|
45
47
|
# Get the count
|
46
48
|
results_count = query.reselect(resource.model_class.primary_key).count
|
47
49
|
|
48
50
|
# Get the results
|
49
51
|
query = query.limit(8)
|
50
52
|
|
51
|
-
query = apply_scope(query) if should_apply_any_scope?
|
52
|
-
|
53
53
|
results = apply_search_metadata(query, resource)
|
54
54
|
|
55
55
|
header = resource.plural_name
|
@@ -10,12 +10,11 @@
|
|
10
10
|
<%= render partial: 'avo/partials/branding' %>
|
11
11
|
<%= render partial: 'avo/partials/pre_head' %>
|
12
12
|
<%= render Avo::AssetManager::StylesheetComponent.new asset_manager: Avo.asset_manager %>
|
13
|
+
<%= stylesheet_link_tag @stylesheet_assets_path, "data-turbo-track": "reload", defer: true %>
|
13
14
|
<% if Avo::PACKED %>
|
14
15
|
<%= javascript_include_tag "/avo-assets/avo.base", "data-turbo-track": "reload", defer: true %>
|
15
|
-
<%= stylesheet_link_tag "/avo-assets/avo.base", "data-turbo-track": "reload", defer: true %>
|
16
16
|
<% else %>
|
17
17
|
<%= javascript_include_tag "avo.base", "data-turbo-track": "reload", defer: true %>
|
18
|
-
<%= stylesheet_link_tag "avo.base", "data-turbo-track": "reload", defer: true %>
|
19
18
|
<% if Rails.env.development? %>
|
20
19
|
<%= javascript_include_tag "hotwire-livereload", defer: true %>
|
21
20
|
<% end %>
|
data/bin/dev
CHANGED
data/lib/avo/base_action.rb
CHANGED
@@ -101,39 +101,34 @@ module Avo
|
|
101
101
|
end
|
102
102
|
|
103
103
|
def handle_action(**args)
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
104
|
+
processed_fields = if args[:fields].present?
|
105
|
+
# Fetching the field definitions and not the actual fields (get_fields) because they will break if the user uses a `visible` block and adds a condition using the `params` variable. The params are different in the show method and the handle method.
|
106
|
+
action_fields = get_field_definitions.map { |field| [field.id, field] }.to_h
|
107
|
+
|
108
|
+
# For some fields, like belongs_to, the id and database_id differ (user vs user_id).
|
109
|
+
# That's why we need to fetch the database_id for when we process the action.
|
110
|
+
action_fields_by_database_id = action_fields.map do |id, value|
|
111
|
+
[value.database_id.to_sym, value]
|
112
|
+
end.to_h
|
113
113
|
|
114
|
-
|
115
|
-
processed_fields = fields.to_unsafe_h.map do |name, value|
|
114
|
+
args[:fields].to_unsafe_h.map do |name, value|
|
116
115
|
field = action_fields_by_database_id[name.to_sym]
|
117
116
|
|
118
117
|
next if field.blank?
|
119
118
|
|
120
119
|
[name, field.resolve_attribute(value)]
|
121
|
-
end
|
122
|
-
|
123
|
-
processed_fields = processed_fields.reject(&:blank?).to_h
|
120
|
+
end.reject(&:blank?).to_h
|
124
121
|
else
|
125
|
-
|
122
|
+
{}
|
126
123
|
end
|
127
124
|
|
128
|
-
|
125
|
+
handle(
|
129
126
|
fields: processed_fields.with_indifferent_access,
|
130
|
-
current_user: current_user,
|
131
|
-
resource: resource
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
handle(**args)
|
127
|
+
current_user: args[:current_user],
|
128
|
+
resource: args[:resource],
|
129
|
+
records: args[:query],
|
130
|
+
query: args[:query]
|
131
|
+
)
|
137
132
|
|
138
133
|
self
|
139
134
|
end
|
data/lib/avo/base_resource.rb
CHANGED
@@ -26,16 +26,16 @@ module Avo
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def filters_session_key
|
29
|
-
@filters_session_key ||=
|
29
|
+
@filters_session_key ||= "/filters/" << %w[
|
30
30
|
turbo_frame controller resource_name related_name
|
31
31
|
action id
|
32
|
-
].map { |key| params[key] }.compact.join(
|
32
|
+
].map { |key| params[key] }.compact.join("/")
|
33
33
|
end
|
34
34
|
|
35
35
|
def cache_resource_filters?
|
36
36
|
Avo::ExecutionContext.new(
|
37
37
|
target: Avo.configuration.cache_resource_filters,
|
38
|
-
current_user:
|
38
|
+
current_user: _current_user,
|
39
39
|
resource: @resource
|
40
40
|
).handle
|
41
41
|
end
|
@@ -8,7 +8,7 @@ module Avo
|
|
8
8
|
|
9
9
|
hide_on [:edit, :new]
|
10
10
|
|
11
|
-
default_options = {info: :info, success: :success, danger: :danger, warning: :warning,
|
11
|
+
default_options = {info: :info, success: :success, danger: :danger, warning: :warning, neutral: :neutral}
|
12
12
|
@options = args[:options].present? ? default_options.merge(args[:options]) : default_options
|
13
13
|
end
|
14
14
|
end
|
@@ -158,14 +158,7 @@ module Avo
|
|
158
158
|
|
159
159
|
# Run computable callback block if present
|
160
160
|
if computable && block.present?
|
161
|
-
final_value =
|
162
|
-
target: block,
|
163
|
-
record: record,
|
164
|
-
resource: @resource,
|
165
|
-
view: @view,
|
166
|
-
field: self,
|
167
|
-
include: self.class.included_modules
|
168
|
-
).handle
|
161
|
+
final_value = execute_block
|
169
162
|
end
|
170
163
|
|
171
164
|
# Run the value through resolver if present
|
@@ -184,6 +177,17 @@ module Avo
|
|
184
177
|
final_value
|
185
178
|
end
|
186
179
|
|
180
|
+
def execute_block
|
181
|
+
Avo::ExecutionContext.new(
|
182
|
+
target: block,
|
183
|
+
record: record,
|
184
|
+
resource: resource,
|
185
|
+
view: view,
|
186
|
+
field: self,
|
187
|
+
include: self.class.included_modules
|
188
|
+
).handle
|
189
|
+
end
|
190
|
+
|
187
191
|
# Fills the record with the received value on create and update actions.
|
188
192
|
def fill_field(record, key, value, params)
|
189
193
|
return record unless record.methods.include? key.to_sym
|