avo 3.0.0.pre13 → 3.0.0.pre14
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 +1 -1
- data/Gemfile.lock +2 -1
- data/app/components/avo/alert_component.html.erb +1 -1
- data/app/components/avo/base_component.rb +7 -7
- data/app/components/avo/field_wrapper_component.rb +1 -1
- data/app/components/avo/fields/area_field/edit_component.html.erb +1 -1
- data/app/components/avo/fields/belongs_to_field/edit_component.html.erb +5 -5
- data/app/components/avo/fields/belongs_to_field/edit_component.rb +4 -4
- data/app/components/avo/fields/boolean_field/edit_component.html.erb +1 -0
- 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 +1 -0
- data/app/components/avo/fields/country_field/edit_component.html.erb +1 -0
- data/app/components/avo/fields/file_field/index_component.rb +2 -2
- data/app/components/avo/fields/has_one_field/show_component.html.erb +1 -0
- data/app/components/avo/fields/index_component.rb +1 -0
- data/app/components/avo/fields/location_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/markdown_field/edit_component.html.erb +1 -0
- data/app/components/avo/fields/number_field/edit_component.html.erb +1 -0
- data/app/components/avo/fields/password_field/edit_component.html.erb +1 -0
- data/app/components/avo/fields/progress_bar_field/edit_component.html.erb +1 -0
- data/app/components/avo/fields/status_field/edit_component.html.erb +1 -1
- 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 -0
- data/app/components/avo/fields/trix_field/edit_component.html.erb +2 -1
- data/app/components/avo/fields/trix_field/show_component.html.erb +1 -1
- data/app/components/avo/index/resource_controls_component.rb +6 -6
- data/app/components/avo/item_switcher_component.html.erb +9 -4
- data/app/components/avo/item_switcher_component.rb +2 -1
- data/app/components/avo/resource_component.rb +5 -3
- data/app/components/avo/resource_sidebar_component.rb +1 -1
- data/app/components/avo/row_component.html.erb +3 -0
- data/app/components/avo/row_component.rb +12 -0
- data/app/components/avo/sidebar/link_component.html.erb +2 -0
- data/app/components/avo/sidebar/link_component.rb +5 -3
- data/app/components/avo/sidebar_component.html.erb +3 -3
- data/app/components/avo/sidebar_component.rb +4 -4
- data/app/components/avo/sidebar_profile_component.html.erb +3 -3
- data/app/components/avo/views/resource_edit_component.rb +1 -1
- data/app/components/avo/views/resource_index_component.html.erb +1 -1
- data/app/components/avo/views/resource_index_component.rb +8 -8
- data/app/controllers/avo/actions_controller.rb +11 -7
- data/app/controllers/avo/application_controller.rb +71 -66
- data/app/controllers/avo/associations_controller.rb +4 -6
- data/app/controllers/avo/attachments_controller.rb +1 -1
- data/app/controllers/avo/base_controller.rb +22 -15
- data/app/controllers/avo/home_controller.rb +1 -1
- data/app/controllers/avo/search_controller.rb +14 -12
- data/app/controllers/concerns/avo/initializes_avo.rb +2 -5
- data/app/javascript/js/controllers/fields/easy_mde_controller.js +1 -0
- data/app/views/avo/associations/new.html.erb +1 -1
- data/app/views/avo/debug/status.html.erb +1 -1
- data/app/views/avo/partials/_custom_tools_alert.html.erb +2 -2
- data/app/views/avo/partials/_footer.html.erb +1 -1
- data/app/views/avo/partials/_javascript.html.erb +1 -1
- data/app/views/avo/partials/_navbar.html.erb +1 -1
- data/app/views/layouts/avo/application.html.erb +2 -2
- data/avo.gemspec +1 -0
- data/config/initializers/pagy.rb +12 -10
- data/config/routes.rb +3 -3
- data/db/factories.rb +2 -1
- data/lib/avo/base_action.rb +4 -1
- data/lib/avo/base_resource.rb +118 -89
- data/lib/avo/concerns/has_item_type.rb +4 -0
- data/lib/avo/concerns/has_items.rb +20 -15
- data/lib/avo/concerns/model_class_constantized.rb +0 -2
- data/lib/avo/current.rb +22 -1
- data/lib/avo/dsl/field_parser.rb +1 -1
- data/lib/avo/dynamic_router.rb +12 -1
- data/lib/avo/engine.rb +4 -7
- data/lib/avo/fields/base_field.rb +25 -3
- data/lib/avo/fields/belongs_to_field.rb +8 -7
- data/lib/avo/fields/concerns/is_searchable.rb +1 -1
- data/lib/avo/fields/concerns/use_resource.rb +1 -1
- data/lib/avo/fields/field_manager.rb +13 -3
- data/lib/avo/fields/has_base_field.rb +4 -4
- data/lib/avo/fields/has_one_field.rb +1 -1
- data/lib/avo/fields/location_field.rb +18 -1
- data/lib/avo/licensing/h_q.rb +11 -6
- data/lib/avo/licensing/license.rb +1 -1
- data/lib/avo/licensing/license_manager.rb +1 -1
- data/lib/avo/licensing/{null_license.rb → nil_license.rb} +1 -1
- data/lib/avo/loaders/fields_loader.rb +7 -1
- data/lib/avo/plugin_manager.rb +2 -4
- data/lib/avo/reloader.rb +1 -1
- data/lib/avo/resources/items/holder.rb +5 -1
- data/lib/avo/resources/items/item_group.rb +1 -0
- data/lib/avo/resources/items/row.rb +54 -0
- data/lib/avo/resources/resource_manager.rb +4 -7
- data/lib/avo/services/debug_service.rb +6 -6
- data/lib/avo/services/telemetry_service.rb +3 -3
- data/lib/avo/version.rb +1 -1
- data/lib/avo.rb +107 -25
- data/lib/generators/avo/action_generator.rb +8 -8
- data/lib/generators/avo/card_generator.rb +27 -0
- data/lib/generators/avo/filter_generator.rb +8 -8
- data/lib/generators/avo/templates/action.tt +3 -3
- 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/generators/avo/templates/cards/partial_card.tt +1 -1
- data/lib/generators/avo/templates/cards/partial_card_sample.tt +1 -1
- data/lib/generators/avo/templates/dashboards/dashboard.tt +1 -1
- data/lib/generators/avo/templates/scope.tt +1 -1
- data/lib/tasks/avo_tasks.rake +1 -28
- data/public/avo-assets/avo.base.css +26 -31
- data/public/avo-assets/avo.base.js +281 -280
- data/public/avo-assets/avo.base.js.map +3 -3
- metadata +21 -8
- data/lib/avo/app.rb +0 -170
- data/lib/generators/avo/card/chartkick_generator.rb +0 -18
- data/lib/generators/avo/card/metric_generator.rb +0 -18
- data/lib/generators/avo/card/partial_generator.rb +0 -19
- data/lib/generators/avo/templates/standalone_action.tt +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0b96922b610c34442f4ef39940c378a6b5acc2638954c7eae30217fcfef32c4
|
4
|
+
data.tar.gz: '092dfa026329552be2be791d9493b4c0ca8db46caf72f7bb494e59aceab32275'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1a47cfffce993596d1fd2edb977c4207ced53a597e174917848f69d3586a8d337dfcf7b131c4720cef4119ce5ff8d16577304533c4776e3e807b6307606396c
|
7
|
+
data.tar.gz: 94699f2123e35d23c0572d73137c86e025fa493c6f0637d9b7ea04ecbb93daef27ecaac42e818f3cdf01aba2dc2420aed7b18de6bb72cd87d8995afb29026ad1
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -4,7 +4,7 @@ class Avo::BaseComponent < ViewComponent::Base
|
|
4
4
|
include Turbo::FramesHelper
|
5
5
|
|
6
6
|
def has_with_trial(ability)
|
7
|
-
|
7
|
+
Avo.license.has_with_trial(ability)
|
8
8
|
end
|
9
9
|
|
10
10
|
private
|
@@ -18,7 +18,7 @@ class Avo::BaseComponent < ViewComponent::Base
|
|
18
18
|
|
19
19
|
# Fetch the resource and hydrate it with the record
|
20
20
|
def association_resource
|
21
|
-
resource =
|
21
|
+
resource = Avo.resource_manager.get_resource(params[:via_resource_class])
|
22
22
|
|
23
23
|
model_class = if params[:via_relation_class].present?
|
24
24
|
::Avo::BaseResource.get_model_by_name params[:via_relation_class]
|
@@ -26,23 +26,23 @@ class Avo::BaseComponent < ViewComponent::Base
|
|
26
26
|
resource.model_class
|
27
27
|
end
|
28
28
|
|
29
|
-
resource =
|
29
|
+
resource = Avo.resource_manager.get_resource_by_model_class model_class if resource.blank?
|
30
30
|
|
31
31
|
record = resource.find_record params[:via_record_id], query: model_class, params: params
|
32
32
|
|
33
|
-
resource.
|
33
|
+
resource.new record: record
|
34
34
|
end
|
35
35
|
|
36
36
|
# Get the resource for the resource using the klass attribute so we get the namespace too
|
37
37
|
def reflection_resource
|
38
|
-
|
38
|
+
Avo.resource_manager.get_resource_by_model_class(@reflection.klass.to_s)
|
39
39
|
rescue
|
40
40
|
nil
|
41
41
|
end
|
42
42
|
|
43
43
|
# Get the resource for the resource using the klass attribute so we get the namespace too
|
44
44
|
def reflection_parent_resource
|
45
|
-
|
45
|
+
Avo.resource_manager.get_resource_by_model_class(@reflection.active_record.to_s)
|
46
46
|
rescue
|
47
47
|
nil
|
48
48
|
end
|
@@ -51,7 +51,7 @@ class Avo::BaseComponent < ViewComponent::Base
|
|
51
51
|
return @resource unless link_to_child_resource_is_enabled?
|
52
52
|
return @resource if @resource.record.class.base_class == @resource.record.class
|
53
53
|
|
54
|
-
|
54
|
+
Avo.resource_manager.get_resource_by_model_class(@resource.record.class) || @resource
|
55
55
|
end
|
56
56
|
|
57
57
|
def link_to_child_resource_is_enabled?
|
@@ -43,7 +43,7 @@ class Avo::FieldWrapperComponent < ViewComponent::Base
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def classes(extra_classes = "")
|
46
|
-
"field-wrapper relative flex flex-col
|
46
|
+
"field-wrapper relative flex flex-col grow pb-2 md:pb-0 leading-tight min-h-14 h-full #{stacked? ? "field-wrapper-layout-stacked" : "field-wrapper-layout-inline md:flex-row md:items-center"} #{compact? ? "field-wrapper-size-compact" : "field-wrapper-size-regular"} #{full_width? ? "field-width-full" : "field-width-regular"} #{@classes || ""} #{extra_classes || ""} #{@field.get_html(:classes, view: view, element: :wrapper)}"
|
47
47
|
end
|
48
48
|
|
49
49
|
def style
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<%
|
3
3
|
# Set the model keys so we can pass them over
|
4
4
|
model_keys = @field.types.map do |type|
|
5
|
-
resource = Avo
|
5
|
+
resource = Avo.resource_manager.get_resource_by_model_class(type.to_s)
|
6
6
|
[type.to_s, resource.model_key]
|
7
7
|
end.to_h
|
8
8
|
%>
|
@@ -13,7 +13,7 @@
|
|
13
13
|
data-association-class="<%= @field&.target_resource&.model_class || nil %>"
|
14
14
|
>
|
15
15
|
<%= field_wrapper **field_wrapper_args, help: @field.polymorphic_help || '' do %>
|
16
|
-
<%= @form.select @field.type_input_foreign_key, @field.types.map { |type| [
|
16
|
+
<%= @form.select @field.type_input_foreign_key, @field.types.map { |type| [Avo.resource_manager.get_resource_by_model_class(type.to_s).name, type.to_s] },
|
17
17
|
{
|
18
18
|
value: @field.value,
|
19
19
|
include_blank: @field.placeholder,
|
@@ -40,9 +40,9 @@
|
|
40
40
|
data-belongs-to-field-target="type"
|
41
41
|
data-type="<%= type %>"
|
42
42
|
>
|
43
|
-
<%= field_wrapper **field_wrapper_args, label:
|
43
|
+
<%= field_wrapper **field_wrapper_args, label: Avo.resource_manager.get_resource_by_model_class(type.to_s).name do %>
|
44
44
|
<% if @field.is_searchable? %>
|
45
|
-
<%= render
|
45
|
+
<%= render Avo::Pro::SearchableAssociations::AutocompleteComponent.new form: @form,
|
46
46
|
disabled: disabled,
|
47
47
|
field: @field,
|
48
48
|
foreign_key: @field.id_input_foreign_key,
|
@@ -81,7 +81,7 @@
|
|
81
81
|
<% else %>
|
82
82
|
<%= field_wrapper **field_wrapper_args do %>
|
83
83
|
<% if @field.is_searchable? %>
|
84
|
-
<%= render
|
84
|
+
<%= render Avo::Pro::SearchableAssociations::AutocompleteComponent.new form: @form,
|
85
85
|
field: @field,
|
86
86
|
model_key: @field.target_resource&.model_key,
|
87
87
|
foreign_key: @field.id_input_foreign_key,
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Avo::Fields::BelongsToField::EditComponent < Avo::Fields::EditComponent
|
4
|
-
def initialize(
|
5
|
-
super
|
4
|
+
def initialize(...)
|
5
|
+
super(...)
|
6
6
|
|
7
7
|
@polymorphic_record = nil
|
8
8
|
end
|
@@ -32,7 +32,7 @@ class Avo::Fields::BelongsToField::EditComponent < Avo::Fields::EditComponent
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def polymorphic_resource
|
35
|
-
Avo
|
35
|
+
Avo.resource_manager.get_resource_by_model_class(polymorphic_class)
|
36
36
|
end
|
37
37
|
|
38
38
|
# Get the polymorphic id
|
@@ -60,6 +60,6 @@ class Avo::Fields::BelongsToField::EditComponent < Avo::Fields::EditComponent
|
|
60
60
|
private
|
61
61
|
|
62
62
|
def visit_through_association?
|
63
|
-
@field.target_resource.
|
63
|
+
@field.target_resource.to_s == params[:via_resource_class].to_s
|
64
64
|
end
|
65
65
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
<%= field_wrapper **field_wrapper_args, dash_if_blank: false do %>
|
2
2
|
<div class="h-8 flex items-center">
|
3
3
|
<%= @form.check_box @field.id,
|
4
|
+
value: @field.value,
|
4
5
|
checked: @field.value,
|
5
6
|
class: "text-lg h-4 w-4 checked:bg-primary-400 focus:checked:!bg-primary-400 rounded #{@field.get_html(:classes, view: view, element: :input)}",
|
6
7
|
data: @field.get_html(:data, view: view, element: :input),
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<div class="flex items-center">
|
3
3
|
<div class="space-y-2">
|
4
4
|
<% model_param_key = model_name_from_record_or_class(@resource.record).param_key %>
|
5
|
-
<%= check_box_tag "#{
|
5
|
+
<%= check_box_tag "#{model_param_key}[#{@field.id}][]", '', true, { class: "hidden" } %>
|
6
6
|
<% @field.options.each do |id, label| %>
|
7
7
|
<%
|
8
8
|
checked = false
|
@@ -6,10 +6,10 @@ class Avo::Fields::FileField::IndexComponent < Avo::Fields::IndexComponent
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def has_image_tag?
|
9
|
-
|
9
|
+
field.value.present? && field.value.attached? && field.value.representable? && field.is_image
|
10
10
|
end
|
11
11
|
|
12
12
|
def has_audio_tag?
|
13
|
-
|
13
|
+
field.value.present? && field.value.attached? && field.is_audio
|
14
14
|
end
|
15
15
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<%= field_wrapper **field_wrapper_args do %>
|
2
2
|
<% if field.value_present? %>
|
3
|
-
<%= js_map [{latitude: field.value[0], longitude: field.value[1]}], id: "location-map" %>
|
3
|
+
<%= js_map [{latitude: field.value[0], longitude: field.value[1]}], id: "location-map", zoom: field.zoom, controls: true %>
|
4
4
|
<% else %>
|
5
5
|
—
|
6
6
|
<% end %>
|
@@ -1,11 +1,11 @@
|
|
1
1
|
<%= field_wrapper **field_wrapper_args do %>
|
2
2
|
<%= form.text_field @field.id,
|
3
|
+
value: @field.value,
|
3
4
|
class: classes("w-full"),
|
4
5
|
data: @field.get_html(:data, view: view, element: :input),
|
5
6
|
disabled: disabled?,
|
6
7
|
placeholder: @field.placeholder,
|
7
8
|
style: @field.get_html(:style, view: view, element: :input),
|
8
|
-
# value: @field.value,
|
9
9
|
multiple: multiple,
|
10
10
|
autocomplete: @field.autocomplete
|
11
11
|
%>
|
@@ -20,9 +20,10 @@
|
|
20
20
|
},
|
21
21
|
input: trix_id,
|
22
22
|
placeholder: @field.placeholder do %>
|
23
|
-
<%= sanitize @field.value %>
|
23
|
+
<%= sanitize @field.value.to_s %>
|
24
24
|
<% end %>
|
25
25
|
<%= @form.text_area @field.id,
|
26
|
+
value: @field.value,
|
26
27
|
class: classes("w-full hidden"),
|
27
28
|
data: @field.get_html(:data, view: view, element: :input),
|
28
29
|
disabled: disabled?,
|
@@ -8,7 +8,7 @@
|
|
8
8
|
<%= link_to t('avo.show_content'), 'javascript:void(0);', class: 'font-bold inline-block', data: { action: 'click->hidden-input#showContent' } %>
|
9
9
|
<% end %>
|
10
10
|
<div class="<%= content_classes %> " data-hidden-input-target="content">
|
11
|
-
<%= sanitize @field.value %>
|
11
|
+
<%= sanitize @field.value.to_s %>
|
12
12
|
</div>
|
13
13
|
</div>
|
14
14
|
<% end %>
|
@@ -44,7 +44,7 @@ class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent
|
|
44
44
|
}
|
45
45
|
end
|
46
46
|
|
47
|
-
helpers.resource_path(record: @resource.record, resource: parent_or_child_resource
|
47
|
+
helpers.resource_path(record: @resource.record, resource: parent_or_child_resource, **args)
|
48
48
|
end
|
49
49
|
|
50
50
|
def edit_path
|
@@ -73,7 +73,7 @@ class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent
|
|
73
73
|
return @parent_resource if @parent_resource.present?
|
74
74
|
return nil if @parent_record.blank?
|
75
75
|
|
76
|
-
|
76
|
+
Avo.resource_manager.get_resource_by_model_class @parent_record.class
|
77
77
|
end
|
78
78
|
|
79
79
|
def is_has_many_association
|
@@ -81,11 +81,11 @@ class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def referrer_path
|
84
|
-
Avo
|
84
|
+
Avo.root_path(paths: ["resources", params[:resource_name], params[:id], params[:related_name]], query: request.query_parameters.to_h)
|
85
85
|
end
|
86
86
|
|
87
87
|
def can_reorder?
|
88
|
-
return false unless Object.const_defined? "
|
88
|
+
return false unless Object.const_defined? "Avo::Pro::Ordering"
|
89
89
|
|
90
90
|
return authorize_association_for(:reorder) if @reflection.present?
|
91
91
|
|
@@ -167,13 +167,13 @@ class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent
|
|
167
167
|
target: "control:detach",
|
168
168
|
control: :detach,
|
169
169
|
"resource-id": @resource.record.id,
|
170
|
-
|
170
|
+
tippy: :tooltip,
|
171
171
|
}
|
172
172
|
end
|
173
173
|
|
174
174
|
def render_order_controls(control)
|
175
175
|
if can_reorder?
|
176
|
-
render
|
176
|
+
render Avo::Pro::Ordering::ButtonsComponent.new resource: @resource, reflection: @reflection, view_type: @view_type
|
177
177
|
end
|
178
178
|
end
|
179
179
|
|
@@ -7,10 +7,7 @@
|
|
7
7
|
<% c.with_body do %>
|
8
8
|
<div class="divide-y">
|
9
9
|
<% item.visible_items.each_with_index do |field, index| %>
|
10
|
-
<%= render field
|
11
|
-
.hydrate(resource: @resource, record: @resource.record, user: resource.user, view: view)
|
12
|
-
.component_for_view(view)
|
13
|
-
.new(field: field, resource: @resource, index: index, form: form) %>
|
10
|
+
<%= render Avo::ItemSwitcherComponent.new resource: @resource, item: field, index: index, view: @view, form: form %>
|
14
11
|
<% end %>
|
15
12
|
</div>
|
16
13
|
<% end %>
|
@@ -19,4 +16,12 @@
|
|
19
16
|
<%= render tab_group_component %>
|
20
17
|
<% elsif item.is_field? %>
|
21
18
|
<%= render field_component %>
|
19
|
+
<% elsif item.is_row? %>
|
20
|
+
<%= render Avo::RowComponent.new do |c| %>
|
21
|
+
<% c.with_body do %>
|
22
|
+
<% item.visible_items.each_with_index do |field, index| %>
|
23
|
+
<%= render Avo::ItemSwitcherComponent.new resource: @resource, item: field, index: index, view: @view, form: form %>
|
24
|
+
<% end %>
|
25
|
+
<% end %>
|
26
|
+
<% end %>
|
22
27
|
<% end %>
|
@@ -42,6 +42,7 @@ class Avo::ItemSwitcherComponent < Avo::BaseComponent
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def field_component
|
45
|
-
item.
|
45
|
+
final_item = item.dup.hydrate(resource: @resource, record: @resource.record, user: resource.user, view: view)
|
46
|
+
final_item.component_for_view(@view).new(field: final_item, resource: @resource, index: index, form: form)
|
46
47
|
end
|
47
48
|
end
|
@@ -102,7 +102,7 @@ class Avo::ResourceComponent < Avo::BaseComponent
|
|
102
102
|
end
|
103
103
|
|
104
104
|
def sidebar
|
105
|
-
return if Avo
|
105
|
+
return if Avo.license.lacks_with_trial(:resource_sidebar)
|
106
106
|
|
107
107
|
@sidebar ||= search_for_sidebar
|
108
108
|
end
|
@@ -113,7 +113,8 @@ class Avo::ResourceComponent < Avo::BaseComponent
|
|
113
113
|
|
114
114
|
def has_reflection_and_is_read_only
|
115
115
|
if @reflection.present? && @reflection.active_record.name && @reflection.name
|
116
|
-
|
116
|
+
resource = Avo.resource_manager.get_resource_by_model_class(@reflection.active_record.name).new(params: helpers.params, view: view, user: helpers.current_user)
|
117
|
+
fields = resource.get_field_definitions
|
117
118
|
filtered_fields = fields.filter { |f| f.id == @reflection.name }
|
118
119
|
else
|
119
120
|
return false
|
@@ -287,7 +288,8 @@ class Avo::ResourceComponent < Avo::BaseComponent
|
|
287
288
|
end
|
288
289
|
|
289
290
|
def render_action(action)
|
290
|
-
return
|
291
|
+
return if !can_see_the_actions_button?
|
292
|
+
return if !action.action.visible_in_view(parent_resource: @parent_resource)
|
291
293
|
|
292
294
|
a_link action.path,
|
293
295
|
color: action.color,
|
@@ -1,5 +1,6 @@
|
|
1
1
|
<% if path.present? %>
|
2
2
|
<%= send link_method, path, class: classes, active: active, target: target, data: data do %>
|
3
|
+
<%= helpers.svg icon, class: "h-4 text-gray-700" if icon.present? %>
|
3
4
|
<%= label %>
|
4
5
|
<% if target == :_blank %>
|
5
6
|
<%= helpers.svg('heroicons/outline/external-link', class: 'self-center ml-auto h-3 mr-2') %>
|
@@ -7,6 +8,7 @@
|
|
7
8
|
<% end %>
|
8
9
|
<% else %>
|
9
10
|
<%= content_tag :div, class: classes, active: active, target: target, data: data do %>
|
11
|
+
<%= helpers.svg icon, class: "h-4 text-gray-700" if icon.present? %>
|
10
12
|
<%= label %>
|
11
13
|
<% end %>
|
12
14
|
<% end %>
|
@@ -6,18 +6,20 @@ class Avo::Sidebar::LinkComponent < ViewComponent::Base
|
|
6
6
|
attr_reader :label
|
7
7
|
attr_reader :path
|
8
8
|
attr_reader :data
|
9
|
+
attr_reader :icon
|
9
10
|
|
10
|
-
def initialize(label: nil, path: nil, active: :inclusive, target: nil, data: {})
|
11
|
+
def initialize(label: nil, path: nil, active: :inclusive, target: nil, data: {}, icon: nil)
|
11
12
|
@label = label
|
12
13
|
@path = path
|
13
14
|
@active = active
|
14
15
|
@target = target
|
15
16
|
@data = data
|
17
|
+
@icon = icon
|
16
18
|
end
|
17
19
|
|
18
20
|
def is_external?
|
19
21
|
# If the path contains the scheme, check if it includes the root path or not
|
20
|
-
return !path.include?(Avo
|
22
|
+
return !path.include?(Avo.mount_path) if URI(path).scheme.present?
|
21
23
|
|
22
24
|
false
|
23
25
|
end
|
@@ -28,6 +30,6 @@ class Avo::Sidebar::LinkComponent < ViewComponent::Base
|
|
28
30
|
end
|
29
31
|
|
30
32
|
def classes
|
31
|
-
"px-4 pr-0 flex-1 flex mx-6 leading-none py-2 text-black rounded font-medium hover:bg-gray-100"
|
33
|
+
"px-4 pr-0 flex-1 flex mx-6 leading-none py-2 text-black rounded font-medium hover:bg-gray-100 gap-1"
|
32
34
|
end
|
33
35
|
end
|
@@ -13,8 +13,8 @@
|
|
13
13
|
<div class="space-y-6 mb-4">
|
14
14
|
<%= render Avo::Sidebar::LinkComponent.new label: 'Get started', path: helpers.avo.root_path, active: :exclusive if Rails.env.development? && Avo.configuration.home_path.nil? %>
|
15
15
|
|
16
|
-
<% if Avo.plugin_manager.installed?(
|
17
|
-
<% Avo
|
16
|
+
<% if Avo.plugin_manager.installed?("avo-menu") && Avo.has_main_menu? %>
|
17
|
+
<% Avo.main_menu.items.each do |item| %>
|
18
18
|
<%= render Avo::Sidebar::ItemSwitcherComponent.new item: item %>
|
19
19
|
<% end %>
|
20
20
|
<% else %>
|
@@ -60,7 +60,7 @@
|
|
60
60
|
<% if Rails.env.development? %>
|
61
61
|
<div class="p-4 border-t group">
|
62
62
|
<%= link_to helpers.avo.avo_private_status_path, class: "block px-4 py-2 border rounded flex justify-between items-center w-full text-black text-sm" do %>
|
63
|
-
<span>Avo Status</span> <span><div class="rounded-full w-4 h-4 <%= Avo
|
63
|
+
<span>Avo Status</span> <span><div class="rounded-full w-4 h-4 <%= Avo.app_status ? "bg-green-400" : "bg-orange-400" %>"></div></span>
|
64
64
|
<% end %>
|
65
65
|
<div class="absolute text-xs text-gray-700 group-hover:block hidden text-center w-full -ml-4">👆Visible only in development👆</div>
|
66
66
|
</div>
|
@@ -7,17 +7,17 @@ class Avo::SidebarComponent < ViewComponent::Base
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def dashboards
|
10
|
-
return [] unless defined?(
|
10
|
+
return [] unless defined?(Avo::Dashboards)
|
11
11
|
|
12
|
-
|
12
|
+
Avo::Dashboards.dashboard_manager.dashboards_for_navigation
|
13
13
|
end
|
14
14
|
|
15
15
|
def resources
|
16
|
-
Avo
|
16
|
+
Avo.resource_manager.resources_for_navigation helpers._current_user
|
17
17
|
end
|
18
18
|
|
19
19
|
def tools
|
20
|
-
Avo
|
20
|
+
Avo.tool_manager.tools_for_navigation
|
21
21
|
end
|
22
22
|
|
23
23
|
def stimulus_target
|
@@ -30,10 +30,10 @@
|
|
30
30
|
data-transition-leave-start="transform opacity-100 translate-y-0"
|
31
31
|
data-transition-leave-end="transform opacity-0 translate-y-1"
|
32
32
|
>
|
33
|
-
<% if Avo.plugin_manager.installed?(
|
33
|
+
<% if Avo.plugin_manager.installed?("avo-menu") && Avo.has_profile_menu? %>
|
34
34
|
<div class="text-black space-y-4">
|
35
|
-
<% Avo
|
36
|
-
<% if item.is_a?
|
35
|
+
<% Avo.profile_menu.items.each do |item| %>
|
36
|
+
<% if item.is_a? Avo::Menu::Link %>
|
37
37
|
<%= render Avo::ProfileItemComponent.new label: item.name, path: item.path, icon: item.icon %>
|
38
38
|
<% end %>
|
39
39
|
<% end %>
|
@@ -79,6 +79,6 @@ class Avo::Views::ResourceEditComponent < Avo::ResourceComponent
|
|
79
79
|
|
80
80
|
# Render :show view for read only trix fields
|
81
81
|
def view_for(field)
|
82
|
-
|
82
|
+
field.is_a?(Avo::Fields::TrixField) && field.is_disabled? ? :show : view
|
83
83
|
end
|
84
84
|
end
|
@@ -34,7 +34,7 @@
|
|
34
34
|
</div>
|
35
35
|
</div>
|
36
36
|
<% if Avo.avo_filters_installed? && resource.has_filters? %>
|
37
|
-
<%= render
|
37
|
+
<%= render Avo::DynamicFilters::FiltersComponent.new resource: resource, turbo_frame: turbo_frame %>
|
38
38
|
<% end %>
|
39
39
|
</div>
|
40
40
|
</div>
|