avo 2.5.2.pre.7 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of avo might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/assets/stylesheets/avo.css +33 -1
- data/app/assets/stylesheets/css/search.css +1 -1
- data/app/assets/svgs/heroicons/solid/user-remove.svg +1 -1
- data/app/components/avo/actions_component.html.erb +3 -2
- data/app/components/avo/alert_component.html.erb +1 -1
- data/app/components/avo/alert_component.rb +24 -5
- data/app/components/avo/button_component.rb +50 -17
- data/app/components/avo/card_component.rb +12 -0
- data/app/components/avo/fields/concerns/item_labels.rb +40 -0
- data/app/components/avo/fields/tags_field/edit_component.html.erb +1 -1
- data/app/components/avo/fields/tags_field/index_component.html.erb +1 -5
- data/app/components/avo/fields/tags_field/index_component.rb +2 -0
- data/app/components/avo/fields/tags_field/show_component.rb +3 -7
- data/app/components/avo/fields/tags_field/tag_component.html.erb +1 -1
- data/app/components/avo/filters_component.html.erb +1 -1
- data/app/components/avo/index/field_wrapper_component.html.erb +1 -1
- data/app/components/avo/index/grid_cover_empty_state_component.html.erb +1 -1
- data/app/components/avo/index/table_row_component.html.erb +1 -1
- data/app/components/avo/panel_component.html.erb +3 -3
- data/app/components/avo/panel_component.rb +1 -1
- data/app/components/avo/resource_component.rb +50 -0
- data/app/components/avo/sidebar/group_component.html.erb +4 -2
- data/app/components/avo/sidebar/heading_component.html.erb +1 -1
- data/app/components/avo/sidebar/link_component.html.erb +1 -1
- data/app/components/avo/sidebar/link_component.rb +1 -1
- data/app/components/avo/sidebar_component.html.erb +5 -13
- data/app/components/avo/sidebar_profile_component.html.erb +1 -1
- data/app/components/avo/views/resource_edit_component.html.erb +28 -3
- data/app/components/avo/views/resource_edit_component.rb +4 -6
- data/app/components/avo/views/resource_index_component.html.erb +17 -9
- data/app/components/avo/views/resource_new_component.html.erb +8 -2
- data/app/components/avo/views/resource_show_component.html.erb +16 -6
- data/app/components/avo/views/resource_show_component.rb +0 -45
- data/app/controllers/avo/actions_controller.rb +23 -8
- data/app/controllers/avo/associations_controller.rb +3 -3
- data/app/controllers/avo/base_controller.rb +11 -21
- data/app/controllers/avo/private_controller.rb +1 -0
- data/app/controllers/avo/search_controller.rb +2 -2
- data/app/helpers/avo/application_helper.rb +1 -1
- data/app/javascript/js/controllers/fields/key_value_controller.js +1 -1
- data/app/javascript/js/controllers/fields/tags_field_controller.js +3 -3
- data/app/javascript/js/controllers/filter_controller.js +4 -1
- data/app/javascript/js/controllers.js +0 -2
- data/app/views/avo/actions/show.html.erb +5 -2
- data/app/views/avo/dashboards/_chartkick_card.html.erb +1 -1
- data/app/views/avo/dashboards/_metric_card.html.erb +1 -1
- data/app/views/avo/partials/_logo.html.erb +1 -1
- data/app/views/avo/partials/_navbar.html.erb +9 -6
- data/app/views/avo/partials/_table_header.html.erb +3 -2
- data/app/views/avo/private/_links_and_buttons.html.erb +2 -2
- data/app/views/layouts/avo/application.html.erb +50 -53
- data/lib/avo/base_action.rb +24 -6
- data/lib/avo/engine.rb +1 -1
- data/lib/avo/fields/belongs_to_field.rb +4 -4
- data/lib/avo/fields/has_and_belongs_to_many_field.rb +2 -2
- data/lib/avo/fields/has_base_field.rb +2 -0
- data/lib/avo/fields/has_many_field.rb +2 -2
- data/lib/avo/fields/has_one_field.rb +2 -2
- data/lib/avo/fields/tags_field.rb +5 -5
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/templates/cards/chartkick_card.tt +1 -1
- data/lib/generators/avo/templates/cards/chartkick_card_sample.tt +1 -1
- data/lib/generators/avo/templates/cards/metric_card.tt +1 -1
- data/lib/generators/avo/templates/cards/metric_card_sample.tt +1 -1
- data/lib/tasks/avo_tasks.rake +7 -3
- data/public/avo-assets/avo.css +233 -176
- data/public/avo-assets/avo.js +63 -63
- data/public/avo-assets/avo.js.map +3 -3
- metadata +5 -9
- data/app/assets/builds/avo.css +0 -9557
- data/app/assets/builds/avo.js +0 -512
- data/app/assets/builds/avo.js.map +0 -7
- data/app/assets/stylesheets/css/alerts.css +0 -35
- data/app/javascript/js/controllers/alerts_controller.js +0 -26
@@ -1,60 +1,57 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html>
|
3
|
-
<head>
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
<% if Rails.env.development? %>
|
20
|
-
<%= javascript_include_tag "hotwire-livereload", defer: true %>
|
3
|
+
<head>
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
5
|
+
<%= display_meta_tags site: Avo.configuration.app_name, reverse: true, separator: "—" %>
|
6
|
+
<%= csrf_meta_tags %>
|
7
|
+
<%= csp_meta_tag %>
|
8
|
+
<%= render partial: 'avo/partials/javascript' %>
|
9
|
+
<%= render partial: 'avo/partials/head' %>
|
10
|
+
<% if Avo::PACKED %>
|
11
|
+
<%= javascript_include_tag "/avo-assets/avo", "data-turbo-track": "reload", defer: true %>
|
12
|
+
<%= stylesheet_link_tag "/avo-assets/avo", "data-turbo-track": "reload", defer: true %>
|
13
|
+
<% else %>
|
14
|
+
<%= javascript_include_tag "avo", "data-turbo-track": "reload", defer: true %>
|
15
|
+
<%= stylesheet_link_tag "avo", "data-turbo-track": "reload", defer: true %>
|
16
|
+
<% if Rails.env.development? %>
|
17
|
+
<%= javascript_include_tag "hotwire-livereload", defer: true %>
|
18
|
+
<% end %>
|
21
19
|
<% end %>
|
22
|
-
|
23
|
-
|
24
|
-
<
|
25
|
-
<div class="
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
20
|
+
</head>
|
21
|
+
<body class="bg-gray-25 os-mac">
|
22
|
+
<div class="relative flex flex-1 w-full min-h-full" data-controller="mobile">
|
23
|
+
<div class="flex-1 flex flex-col max-w-full">
|
24
|
+
<%= render partial: "avo/partials/navbar" %>
|
25
|
+
<div class="flex-1 flex pt-16 relative">
|
26
|
+
<%= render Avo::SidebarComponent.new %>
|
27
|
+
<div class="lg:pl-64 flex-1 flex flex-col min-h-full max-w-full">
|
28
|
+
<div class="content p-4 lg:p-6 flex-1 flex flex-col justify-between items-stretch <%= @container_classes %>">
|
29
|
+
<%= render partial: "avo/partials/custom_tools_alert" if @custom_tools_alert_visible %>
|
30
|
+
<div class="flex flex-1 flex-col justify-between items-stretch space-y-8">
|
31
|
+
<%= yield %>
|
32
|
+
<%= render partial: "avo/partials/footer" %>
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
</div>
|
36
|
+
</div>
|
37
37
|
</div>
|
38
38
|
</div>
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
<%= turbo_frame_tag '
|
43
|
-
<%=
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
<% if @errors.present? %>
|
51
|
-
<% @errors.each do |message| %>
|
52
|
-
<%= render Avo::AlertComponent.new :error, message %>
|
39
|
+
<%= turbo_frame_tag 'actions_show' %>
|
40
|
+
<%= turbo_frame_tag 'attach_modal' %>
|
41
|
+
<%= turbo_frame_tag 'destroy_attachment_form' %>
|
42
|
+
<%= turbo_frame_tag 'alerts', class: "fixed inset-0 bottom-0 flex flex-col space-y-4 items-end justify-right px-4 py-6 sm:p-6 justify-end z-50 pointer-events-none" do %>
|
43
|
+
<%= render Avo::FlashAlertsComponent.new flashes: flash %>
|
44
|
+
<% # In case we have other general error messages %>
|
45
|
+
<% if @errors.present? %>
|
46
|
+
<% @errors.each do |message| %>
|
47
|
+
<%= render Avo::AlertComponent.new :error, message %>
|
48
|
+
<% end %>
|
49
|
+
<% end %>
|
53
50
|
<% end %>
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
<!--
|
59
|
-
</body>
|
51
|
+
<%= render partial: "avo/partials/scripts" %>
|
52
|
+
<!-- Avo version: <%= Avo::VERSION %> -->
|
53
|
+
<!-- Environment: <%= Rails.env %> -->
|
54
|
+
<!-- License ID: <%= Avo::App.license.id %> -->
|
55
|
+
<!-- License valid?: <%= Avo::App.license.valid ? "valid" : "invalid" %> -->
|
56
|
+
</body>
|
60
57
|
</html>
|
data/lib/avo/base_action.rb
CHANGED
@@ -61,8 +61,7 @@ module Avo
|
|
61
61
|
self.class.cancel_button_label ||= I18n.t("avo.cancel")
|
62
62
|
|
63
63
|
@response ||= {}
|
64
|
-
@response[:
|
65
|
-
@response[:message] ||= I18n.t("avo.action_ran_successfully")
|
64
|
+
@response[:messages] = []
|
66
65
|
end
|
67
66
|
|
68
67
|
def context
|
@@ -131,15 +130,25 @@ module Avo
|
|
131
130
|
end
|
132
131
|
|
133
132
|
def succeed(text)
|
134
|
-
|
135
|
-
response[:message] = text
|
133
|
+
add_message text, :success
|
136
134
|
|
137
135
|
self
|
138
136
|
end
|
139
137
|
|
140
138
|
def fail(text)
|
141
|
-
|
142
|
-
|
139
|
+
add_message text, :error
|
140
|
+
|
141
|
+
self
|
142
|
+
end
|
143
|
+
|
144
|
+
def inform(text)
|
145
|
+
add_message text, :info
|
146
|
+
|
147
|
+
self
|
148
|
+
end
|
149
|
+
|
150
|
+
def warn(text)
|
151
|
+
add_message text, :warning
|
143
152
|
|
144
153
|
self
|
145
154
|
end
|
@@ -168,5 +177,14 @@ module Avo
|
|
168
177
|
|
169
178
|
self
|
170
179
|
end
|
180
|
+
|
181
|
+
private
|
182
|
+
|
183
|
+
def add_message(body, type = :info)
|
184
|
+
response[:messages] << {
|
185
|
+
type: type,
|
186
|
+
body: body
|
187
|
+
}
|
188
|
+
end
|
171
189
|
end
|
172
190
|
end
|
data/lib/avo/engine.rb
CHANGED
@@ -62,7 +62,7 @@ module Avo
|
|
62
62
|
attr_reader :relation_method
|
63
63
|
attr_reader :types # for Polymorphic associations
|
64
64
|
attr_reader :allow_via_detaching
|
65
|
-
attr_reader :
|
65
|
+
attr_reader :attach_scope
|
66
66
|
attr_reader :polymorphic_help
|
67
67
|
|
68
68
|
def initialize(id, **args, &block)
|
@@ -75,7 +75,7 @@ module Avo
|
|
75
75
|
@types = args[:types]
|
76
76
|
@relation_method = id.to_s.parameterize.underscore
|
77
77
|
@allow_via_detaching = args[:allow_via_detaching] == true
|
78
|
-
@
|
78
|
+
@attach_scope = args[:attach_scope]
|
79
79
|
@polymorphic_help = args[:polymorphic_help]
|
80
80
|
end
|
81
81
|
|
@@ -117,8 +117,8 @@ module Avo
|
|
117
117
|
|
118
118
|
query = Avo::Services::AuthorizationService.apply_policy(user, resource.class.query_scope)
|
119
119
|
|
120
|
-
if
|
121
|
-
query = Avo::Hosts::AssociationScopeHost.new(block:
|
120
|
+
if attach_scope.present?
|
121
|
+
query = Avo::Hosts::AssociationScopeHost.new(block: attach_scope, query: query, parent: get_model).handle
|
122
122
|
end
|
123
123
|
|
124
124
|
query.all.map do |model|
|
@@ -3,12 +3,14 @@ module Avo
|
|
3
3
|
class HasBaseField < BaseField
|
4
4
|
attr_accessor :display
|
5
5
|
attr_accessor :scope
|
6
|
+
attr_accessor :attach_scope
|
6
7
|
attr_accessor :description
|
7
8
|
|
8
9
|
def initialize(id, **args, &block)
|
9
10
|
super(id, **args, &block)
|
10
11
|
|
11
12
|
@scope = args[:scope].present? ? args[:scope] : nil
|
13
|
+
@attach_scope = args[:attach_scope].present? ? args[:attach_scope] : nil
|
12
14
|
@display = args[:display].present? ? args[:display] : :show
|
13
15
|
@searchable = args[:searchable] == true
|
14
16
|
@description = args[:description]
|
@@ -4,10 +4,10 @@ module Avo
|
|
4
4
|
attr_accessor :relation_method
|
5
5
|
|
6
6
|
def initialize(id, **args, &block)
|
7
|
-
super(id, **args, &block)
|
8
|
-
|
9
7
|
hide_on :new, :edit
|
10
8
|
|
9
|
+
super(id, **args, &block)
|
10
|
+
|
11
11
|
@placeholder ||= I18n.t "avo.choose_an_option"
|
12
12
|
|
13
13
|
@relation_method = name.to_s.parameterize.underscore
|
@@ -12,7 +12,7 @@ module Avo
|
|
12
12
|
add_boolean_prop args, :close_on_select
|
13
13
|
add_boolean_prop args, :enforce_suggestions
|
14
14
|
add_string_prop args, :acts_as_taggable_on
|
15
|
-
add_array_prop args, :
|
15
|
+
add_array_prop args, :disallowed
|
16
16
|
add_array_prop args, :delimiters, [","]
|
17
17
|
add_array_prop args, :suggestions
|
18
18
|
end
|
@@ -51,11 +51,11 @@ module Avo
|
|
51
51
|
[]
|
52
52
|
end
|
53
53
|
|
54
|
-
def
|
55
|
-
return @
|
54
|
+
def disallowed
|
55
|
+
return @disallowed if @disallowed.is_a? Array
|
56
56
|
|
57
|
-
if @
|
58
|
-
return Avo::Hosts::RecordHost.new(block: @
|
57
|
+
if @disallowed.respond_to? :call
|
58
|
+
return Avo::Hosts::RecordHost.new(block: @disallowed, record: model).handle
|
59
59
|
end
|
60
60
|
|
61
61
|
[]
|
data/lib/avo/version.rb
CHANGED
@@ -9,7 +9,7 @@ class <%= class_name.camelize %> < Avo::Dashboards::ChartkickCard
|
|
9
9
|
# self.chart_options = { library: { plugins: { legend: { display: true } } } }
|
10
10
|
# self.flush = true
|
11
11
|
|
12
|
-
query
|
12
|
+
def query
|
13
13
|
points = 16
|
14
14
|
i = Time.new.year.to_i - points
|
15
15
|
base_data = Array.new(points).map do
|
data/lib/tasks/avo_tasks.rake
CHANGED
@@ -5,11 +5,14 @@
|
|
5
5
|
|
6
6
|
desc 'Installs Avo assets and bundles them for when you want to use the GitHub repo in your app'
|
7
7
|
task 'avo:build-assets' do
|
8
|
+
spec = get_gem_spec 'avo'
|
9
|
+
# Uncomment to enable only when the source is github.com
|
10
|
+
# enabled = spec.source.to_s.include?('https://github.com/avo-hq/avo')
|
8
11
|
enabled = true
|
9
12
|
|
10
13
|
if enabled
|
11
14
|
puts "Starting avo:build-assets"
|
12
|
-
path =
|
15
|
+
path = spec.full_gem_path
|
13
16
|
|
14
17
|
Dir.chdir(path) do
|
15
18
|
system 'yarn'
|
@@ -24,11 +27,12 @@ end
|
|
24
27
|
|
25
28
|
# From
|
26
29
|
# https://stackoverflow.com/questions/9322078/programmatically-determine-gems-path-using-bundler
|
27
|
-
def
|
30
|
+
def get_gem_spec(name)
|
28
31
|
spec = Bundler.load.specs.find{|s| s.name == name }
|
29
32
|
raise GemNotFound, "Could not find gem '#{name}' in the current bundle." unless spec
|
30
33
|
if spec.name == 'bundler'
|
31
34
|
return File.expand_path('../../../', __FILE__)
|
32
35
|
end
|
33
|
-
|
36
|
+
|
37
|
+
spec
|
34
38
|
end
|