avo 3.0.0.beta1 → 3.0.0.pre1
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 +5 -5
- data/Gemfile.lock +81 -92
- data/{public/avo-assets/avo.css → app/assets/builds/avo.base.css} +686 -728
- data/app/assets/builds/avo.base.js +93804 -0
- data/app/assets/builds/avo.base.js.map +7 -0
- data/app/assets/stylesheets/avo.base.css +2 -1
- data/app/assets/svgs/failed_to_load.svg +1 -0
- data/app/assets/svgs/grid-empty-state.svg +1 -0
- data/app/assets/svgs/table-empty-state.svg +1 -0
- data/app/assets/svgs/triangle-up.svg +1 -1
- data/app/components/avo/actions_component.html.erb +1 -1
- data/app/components/avo/actions_component.rb +16 -42
- 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.html.erb +4 -4
- data/app/components/avo/field_wrapper_component.rb +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 -8
- data/app/components/avo/fields/boolean_field/edit_component.html.erb +0 -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 +0 -1
- data/app/components/avo/fields/common/files_list_viewer_component.html.erb +5 -0
- data/app/components/avo/fields/common/files_list_viewer_component.rb +8 -0
- data/app/components/avo/fields/common/heading_component.html.erb +1 -1
- data/app/components/avo/fields/common/single_file_viewer_component.html.erb +56 -0
- data/app/components/avo/fields/common/single_file_viewer_component.rb +55 -0
- data/app/components/avo/fields/country_field/edit_component.html.erb +1 -3
- data/app/components/avo/fields/file_field/edit_component.html.erb +2 -4
- data/app/components/avo/fields/file_field/edit_component.rb +0 -1
- data/app/components/avo/fields/file_field/index_component.rb +2 -2
- data/app/components/avo/fields/file_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/files_field/edit_component.html.erb +2 -4
- data/app/components/avo/fields/files_field/edit_component.rb +0 -1
- data/app/components/avo/fields/files_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/has_many_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/has_one_field/show_component.html.erb +4 -5
- data/app/components/avo/fields/has_one_field/show_component.rb +2 -6
- data/app/components/avo/fields/index_component.rb +0 -1
- data/app/components/avo/fields/markdown_field/edit_component.html.erb +3 -4
- data/app/components/avo/fields/markdown_field/show_component.html.erb +3 -3
- data/app/components/avo/fields/number_field/edit_component.html.erb +1 -3
- data/app/components/avo/fields/password_field/edit_component.html.erb +1 -3
- data/app/components/avo/fields/progress_bar_field/edit_component.html.erb +0 -1
- data/app/components/avo/fields/select_field/edit_component.html.erb +1 -2
- data/app/components/avo/fields/status_field/edit_component.html.erb +1 -1
- data/app/components/avo/fields/text_field/edit_component.html.erb +2 -3
- data/app/components/avo/fields/textarea_field/edit_component.html.erb +0 -1
- data/app/components/avo/fields/trix_field/edit_component.html.erb +1 -2
- data/app/components/avo/fields/trix_field/show_component.html.erb +1 -1
- data/app/components/avo/index/field_wrapper_component.html.erb +1 -1
- data/app/components/avo/index/field_wrapper_component.rb +12 -0
- data/app/components/avo/index/grid_item_component.html.erb +35 -9
- data/app/components/avo/index/grid_item_component.rb +10 -36
- data/app/components/avo/index/resource_controls_component.rb +11 -8
- data/app/components/avo/index/resource_table_component.rb +1 -1
- data/app/components/avo/item_switcher_component.html.erb +5 -10
- data/app/components/avo/item_switcher_component.rb +1 -2
- data/app/components/avo/modal_component.html.erb +1 -1
- data/app/components/avo/panel_component.html.erb +1 -6
- data/app/components/avo/panel_component.rb +0 -1
- data/app/components/avo/profile_item_component.html.erb +2 -17
- data/app/components/avo/profile_item_component.rb +1 -13
- data/app/components/avo/referrer_params_component.html.erb +0 -2
- data/app/components/avo/resource_component.rb +6 -69
- data/app/components/avo/resource_sidebar_component.rb +1 -1
- data/app/components/avo/sidebar/link_component.html.erb +0 -2
- data/app/components/avo/sidebar/link_component.rb +3 -5
- 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 +27 -27
- data/app/components/avo/views/resource_edit_component.html.erb +5 -5
- data/app/components/avo/views/resource_edit_component.rb +1 -1
- data/app/components/avo/views/resource_index_component.html.erb +10 -19
- data/app/components/avo/views/resource_index_component.rb +16 -22
- data/app/components/avo/views/resource_show_component.html.erb +4 -4
- data/app/controllers/avo/actions_controller.rb +20 -20
- data/app/controllers/avo/application_controller.rb +67 -90
- data/app/controllers/avo/associations_controller.rb +7 -5
- data/app/controllers/avo/attachments_controller.rb +7 -22
- data/app/controllers/avo/base_controller.rb +35 -47
- data/app/controllers/avo/home_controller.rb +1 -1
- data/app/controllers/avo/search_controller.rb +16 -20
- data/app/controllers/concerns/avo/initializes_avo.rb +8 -3
- data/app/helpers/avo/application_helper.rb +6 -13
- data/app/javascript/js/application.js +0 -2
- data/app/javascript/js/controllers/fields/{easy_mde_controller.js → simple_mde_controller.js} +3 -4
- data/app/javascript/js/controllers/search_controller.js +1 -3
- data/app/javascript/js/controllers.js +2 -2
- data/app/views/avo/actions/show.html.erb +3 -5
- data/app/views/avo/associations/new.html.erb +3 -3
- data/app/views/avo/debug/status.html.erb +5 -6
- data/app/views/avo/home/index.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/avo/partials/_table_header.html.erb +8 -0
- data/app/views/avo/partials/_view_toggle_button.html.erb +0 -9
- data/app/views/avo/private/design.html.erb +2 -2
- data/app/views/layouts/avo/application.html.erb +3 -2
- data/avo.gemspec +1 -2
- data/config/initializers/pagy.rb +10 -12
- data/config/routes.rb +5 -5
- data/db/factories.rb +0 -17
- data/lib/avo/app.rb +165 -0
- data/lib/avo/base_action.rb +18 -31
- data/lib/avo/base_resource.rb +213 -238
- data/lib/avo/concerns/breadcrumbs.rb +2 -2
- data/lib/avo/concerns/can_replace_items.rb +7 -3
- data/lib/avo/concerns/filters_session_handler.rb +4 -5
- data/lib/avo/concerns/has_item_type.rb +0 -4
- data/lib/avo/concerns/has_items.rb +115 -93
- data/lib/avo/concerns/is_visible.rb +1 -1
- data/lib/avo/concerns/model_class_constantized.rb +2 -0
- data/lib/avo/configuration.rb +8 -9
- data/lib/avo/current.rb +1 -35
- data/lib/avo/dsl/field_parser.rb +1 -1
- data/lib/avo/dynamic_router.rb +2 -13
- data/lib/avo/engine.rb +13 -11
- data/lib/avo/execution_context.rb +2 -4
- data/lib/avo/fields/base_field.rb +14 -51
- data/lib/avo/fields/belongs_to_field.rb +13 -20
- data/lib/avo/fields/concerns/is_searchable.rb +1 -1
- data/lib/avo/fields/concerns/use_resource.rb +1 -1
- data/lib/avo/fields/date_field.rb +3 -16
- data/lib/avo/fields/field_manager.rb +3 -13
- data/lib/avo/fields/file_field.rb +0 -2
- data/lib/avo/fields/files_field.rb +0 -6
- data/lib/avo/fields/has_base_field.rb +5 -5
- data/lib/avo/fields/has_one_field.rb +1 -2
- data/lib/avo/fields/id_field.rb +1 -2
- data/lib/avo/filters/base_filter.rb +0 -9
- data/lib/avo/grid_collector.rb +40 -0
- data/lib/avo/html/builder.rb +1 -3
- data/lib/avo/licensing/h_q.rb +6 -11
- data/lib/avo/licensing/license.rb +1 -1
- data/lib/avo/licensing/license_manager.rb +1 -1
- data/lib/avo/licensing/{nil_license.rb → null_license.rb} +1 -1
- data/lib/avo/loaders/fields_loader.rb +1 -7
- data/lib/avo/plugin.rb +0 -10
- data/lib/avo/plugin_manager.rb +4 -2
- data/lib/avo/reloader.rb +1 -1
- data/lib/avo/resources/controls/actions_list.rb +1 -2
- data/lib/avo/resources/controls/create_button.rb +1 -1
- data/lib/avo/resources/controls/delete_button.rb +1 -1
- data/lib/avo/resources/controls/detach_button.rb +1 -1
- data/lib/avo/resources/controls/edit_button.rb +1 -1
- data/lib/avo/resources/controls/show_button.rb +1 -1
- data/lib/avo/resources/items/holder.rb +5 -13
- data/lib/avo/resources/items/item_group.rb +0 -1
- data/lib/avo/resources/resource_manager.rb +18 -11
- data/lib/avo/services/debug_service.rb +5 -6
- data/lib/avo/services/telemetry_service.rb +2 -3
- data/lib/avo/version.rb +1 -1
- data/lib/avo.rb +25 -109
- data/lib/generators/avo/action_generator.rb +8 -8
- data/lib/generators/avo/card/chartkick_generator.rb +18 -0
- data/lib/generators/avo/card/metric_generator.rb +18 -0
- data/lib/generators/avo/card/partial_generator.rb +19 -0
- data/lib/generators/avo/eject_generator.rb +0 -1
- data/lib/generators/avo/filter_generator.rb +8 -8
- data/lib/generators/avo/install_generator.rb +1 -11
- data/lib/generators/avo/resource_generator.rb +4 -22
- data/lib/generators/avo/tailwindcss/install_generator.rb +1 -4
- data/lib/generators/avo/templates/action.tt +5 -7
- 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 +3 -5
- data/lib/generators/avo/templates/initializer/avo.tt +2 -4
- data/lib/generators/avo/templates/resource/resource.tt +6 -6
- data/lib/generators/avo/templates/scope.tt +1 -1
- data/lib/generators/avo/templates/standalone_action.tt +8 -0
- data/lib/generators/avo/templates/tailwindcss/Procfile.dev +1 -1
- data/lib/tasks/avo_tasks.rake +0 -5
- metadata +19 -56
- data/app/assets/svgs/map-empty-state.svg +0 -35
- data/app/assets/svgs/map-view-type.svg +0 -3
- data/app/components/avo/fields/area_field/edit_component.html.erb +0 -7
- data/app/components/avo/fields/area_field/edit_component.rb +0 -4
- data/app/components/avo/fields/area_field/show_component.html.erb +0 -8
- data/app/components/avo/fields/area_field/show_component.rb +0 -4
- data/app/components/avo/fields/common/files/controls_component.html.erb +0 -29
- data/app/components/avo/fields/common/files/controls_component.rb +0 -19
- data/app/components/avo/fields/common/files/list_viewer_component.html.erb +0 -20
- data/app/components/avo/fields/common/files/list_viewer_component.rb +0 -41
- data/app/components/avo/fields/common/files/view_type/grid_component.html.erb +0 -27
- data/app/components/avo/fields/common/files/view_type/grid_component.rb +0 -51
- data/app/components/avo/fields/common/files/view_type/list_component.html.erb +0 -22
- data/app/components/avo/fields/common/files/view_type/list_component.rb +0 -15
- data/app/components/avo/fields/location_field/edit_component.html.erb +0 -22
- data/app/components/avo/fields/location_field/edit_component.rb +0 -4
- data/app/components/avo/fields/location_field/show_component.html.erb +0 -7
- data/app/components/avo/fields/location_field/show_component.rb +0 -4
- data/app/components/avo/index/resource_map_component.html.erb +0 -16
- data/app/components/avo/index/resource_map_component.rb +0 -109
- data/app/components/avo/row_component.html.erb +0 -3
- data/app/components/avo/row_component.rb +0 -12
- data/app/views/avo/attachments/destroy.turbo_stream.erb +0 -7
- data/app/views/avo/partials/_profile_menu_extra.html.erb +0 -2
- data/lib/avo/concerns/has_description.rb +0 -23
- data/lib/avo/fields/area_field.rb +0 -39
- data/lib/avo/fields/concerns/file_authorization.rb +0 -31
- data/lib/avo/fields/location_field.rb +0 -86
- data/lib/avo/resources/items/row.rb +0 -54
- data/lib/generators/avo/card_generator.rb +0 -27
- data/public/avo-assets/avo.base.css +0 -10542
- data/public/avo-assets/avo.base.js +0 -949
- data/public/avo-assets/avo.base.js.map +0 -7
- data/public/avo-assets/avo.js +0 -513
- data/public/avo-assets/avo.js.map +0 -7
@@ -36,15 +36,11 @@ class Avo::Fields::HasOneField::ShowComponent < Avo::Fields::ShowComponent
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def create_path
|
39
|
-
association_id = @field.resource.model_class._reflections[@field.id.to_s].inverse_of.name
|
40
|
-
|
41
39
|
args = {
|
42
|
-
via_relation:
|
40
|
+
via_relation: @resource.singular_model_key,
|
43
41
|
via_relation_class: @resource.model_class.to_s,
|
44
|
-
via_record_id: @resource.record.to_param
|
45
|
-
via_association_type: :has_one
|
42
|
+
via_record_id: @resource.record.to_param
|
46
43
|
}
|
47
|
-
|
48
44
|
helpers.new_resource_path(resource: @field.target_resource, **args)
|
49
45
|
end
|
50
46
|
end
|
@@ -1,11 +1,10 @@
|
|
1
1
|
<%= field_wrapper **field_wrapper_args, full_width: true do %>
|
2
|
-
<div data-controller="
|
2
|
+
<div data-controller="simple-mde">
|
3
3
|
<%= @form.text_area @field.id,
|
4
|
-
|
5
|
-
class: classes("w-full js-has-easy-mde-editor"),
|
4
|
+
class: classes("w-full js-has-simple-mde-editor"),
|
6
5
|
data: {
|
7
6
|
view: view,
|
8
|
-
'
|
7
|
+
'simple-mde-target': 'element',
|
9
8
|
'component-options': @field.options.to_json,
|
10
9
|
},
|
11
10
|
disabled: disabled?,
|
@@ -1,10 +1,10 @@
|
|
1
1
|
<%= field_wrapper **field_wrapper_args, full_width: true do %>
|
2
|
-
<div data-controller="
|
2
|
+
<div data-controller="simple-mde">
|
3
3
|
<%= text_area_tag @field.id, @field.value,
|
4
|
-
class: helpers.input_classes('w-full js-has-
|
4
|
+
class: helpers.input_classes('w-full js-has-simple-mde-editor'),
|
5
5
|
placeholder: @field.placeholder,
|
6
6
|
disabled: disabled?,
|
7
|
-
'data-
|
7
|
+
'data-simple-mde-target': 'element',
|
8
8
|
'data-component-options': @field.options.to_json,
|
9
9
|
'data-view': :show %>
|
10
10
|
</div>
|
@@ -1,6 +1,5 @@
|
|
1
1
|
<%= field_wrapper **field_wrapper_args do %>
|
2
2
|
<%= @form.number_field @field.id,
|
3
|
-
value: @field.value,
|
4
3
|
class: classes("w-full"),
|
5
4
|
data: @field.get_html(:data, view: view, element: :input),
|
6
5
|
disabled: disabled?,
|
@@ -8,7 +7,6 @@
|
|
8
7
|
min: @field.min,
|
9
8
|
placeholder: @field.placeholder,
|
10
9
|
step: @field.step,
|
11
|
-
style: @field.get_html(:style, view: view, element: :input)
|
12
|
-
autocomplete: @field.autocomplete
|
10
|
+
style: @field.get_html(:style, view: view, element: :input)
|
13
11
|
%>
|
14
12
|
<% end %>
|
@@ -1,11 +1,9 @@
|
|
1
1
|
<%= field_wrapper **field_wrapper_args do %>
|
2
2
|
<%= @form.password_field @field.id,
|
3
|
-
value: @field.value,
|
4
3
|
class: classes("w-full"),
|
5
4
|
data: @field.get_html(:data, view: view, element: :input),
|
6
5
|
disabled: disabled?,
|
7
6
|
placeholder: @field.placeholder,
|
8
|
-
style: @field.get_html(:style, view: view, element: :input)
|
9
|
-
autocomplete: @field.autocomplete
|
7
|
+
style: @field.get_html(:style, view: view, element: :input)
|
10
8
|
%>
|
11
9
|
<% end %>
|
@@ -10,7 +10,6 @@
|
|
10
10
|
disabled: disabled?,
|
11
11
|
style: @field.get_html(:style, view: view, element: :input),
|
12
12
|
value: @field.record.present? ? @field.record[@field.id] : @field.value,
|
13
|
-
placeholder: @field.include_blank.present? ? nil : @field.placeholder
|
14
|
-
autocomplete: @field.autocomplete
|
13
|
+
placeholder: @field.include_blank.present? ? nil : @field.placeholder
|
15
14
|
%>
|
16
15
|
<% end %>
|
@@ -1,12 +1,11 @@
|
|
1
1
|
<%= field_wrapper **field_wrapper_args do %>
|
2
2
|
<%= form.text_field @field.id,
|
3
|
-
value: @field.value,
|
4
3
|
class: classes("w-full"),
|
5
4
|
data: @field.get_html(:data, view: view, element: :input),
|
6
5
|
disabled: disabled?,
|
7
6
|
placeholder: @field.placeholder,
|
8
7
|
style: @field.get_html(:style, view: view, element: :input),
|
9
|
-
|
10
|
-
|
8
|
+
# value: @field.value,
|
9
|
+
multiple: multiple
|
11
10
|
%>
|
12
11
|
<% end %>
|
@@ -20,10 +20,9 @@
|
|
20
20
|
},
|
21
21
|
input: trix_id,
|
22
22
|
placeholder: @field.placeholder do %>
|
23
|
-
|
23
|
+
<%== @field.value %>
|
24
24
|
<% end %>
|
25
25
|
<%= @form.text_area @field.id,
|
26
|
-
value: @field.value,
|
27
26
|
class: classes("w-full hidden"),
|
28
27
|
data: @field.get_html(:data, view: view, element: :input),
|
29
28
|
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
|
-
|
11
|
+
<%== @field.value %>
|
12
12
|
</div>
|
13
13
|
</div>
|
14
14
|
<% end %>
|
@@ -21,6 +21,7 @@ class Avo::Index::FieldWrapperComponent < ViewComponent::Base
|
|
21
21
|
result += " py-3"
|
22
22
|
end
|
23
23
|
|
24
|
+
result += " #{text_align_classes}"
|
24
25
|
result += " #{@field.get_html(:classes, view: view, element: :wrapper)}"
|
25
26
|
|
26
27
|
result
|
@@ -44,4 +45,15 @@ class Avo::Index::FieldWrapperComponent < ViewComponent::Base
|
|
44
45
|
|
45
46
|
attributes
|
46
47
|
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def text_align_classes
|
52
|
+
case @field.index_text_align.to_sym
|
53
|
+
when :right
|
54
|
+
"text-right"
|
55
|
+
when :center
|
56
|
+
"text-center"
|
57
|
+
end
|
58
|
+
end
|
47
59
|
end
|
@@ -5,19 +5,45 @@
|
|
5
5
|
data-resource-name="<%= @resource.class.to_s %>"
|
6
6
|
data-record-id="<%= @resource.record.id %>"
|
7
7
|
>
|
8
|
-
<%= content_tag :div,
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
<%= content_tag :div, class: "relative w-full pb-3/4 rounded-t overflow-hidden #{cover.present? ? cover.get_html(:classes, view: :index, element: :wrapper) : ""}", style: cover.present? ? cover.get_html(:style, view: :index, element: :wrapper) : "" do %>
|
9
|
+
<% if @resource.record_selector %>
|
10
|
+
<%== item_selector_input floating: true, size: :lg %>
|
11
|
+
<% end %>
|
12
|
+
<% if cover.blank? %>
|
13
|
+
<%= link_to resource_view_path do %>
|
14
|
+
<%= render Avo::Index::GridCoverEmptyStateComponent.new %>
|
15
|
+
<% end %>
|
16
|
+
<% elsif cover.respond_to?(:to_image) && cover.to_image.present? %>
|
17
|
+
<%= link_to_if cover.link_to_resource, image_tag(cover.to_image, class: 'absolute h-full w-full object-cover'), resource_view_path, class: 'absolute h-full w-full object-cover', title: title.value %>
|
18
|
+
<% elsif cover.type == 'file' %>
|
19
|
+
<% if cover.value.attached? && cover.value.representable? %>
|
20
|
+
<%= link_to_if cover.link_to_resource, image_tag(helpers.main_app.url_for(cover.value.variant(resize_to_limit: [480, 480])), class: 'absolute h-full w-full object-cover'), resource_view_path, class: 'absolute h-full w-full object-cover', title: title.value %>
|
21
|
+
<% else %>
|
22
|
+
<%= link_to resource_view_path do %>
|
23
|
+
<%= render Avo::Index::GridCoverEmptyStateComponent.new %>
|
24
|
+
<% end %>
|
25
|
+
<% end %>
|
26
|
+
<% elsif cover.value.present? %>
|
27
|
+
<%= link_to_if cover.link_to_resource, image_tag(cover.value, class: 'absolute h-full w-full object-cover'), resource_view_path, class: 'absolute h-full w-full object-cover', title: title.value %>
|
28
|
+
<% else %>
|
29
|
+
<%= render Avo::Index::GridCoverEmptyStateComponent.new %>
|
30
|
+
<% end %>
|
13
31
|
<% end %>
|
14
|
-
|
32
|
+
<%= content_tag :div, class: "grid grid-cols-1 place-content-between p-4 h-full" do %>
|
15
33
|
<div class="mb-4 h-full flex flex-col space-between">
|
16
|
-
|
17
|
-
|
34
|
+
<% if title.present? %>
|
35
|
+
<%= content_tag :div, class: "grid font-semibold leading-tight text-lg mb-2 #{title.get_html(:classes, view: :index, element: :wrapper)}", style: title.get_html(:style, view: :index, element: :wrapper) do %>
|
36
|
+
<%= link_to_if title.link_to_resource, title.value, resource_view_path %>
|
37
|
+
<% end %>
|
38
|
+
<% end %>
|
39
|
+
<% if body.present? %>
|
40
|
+
<%= content_tag :div, class: "text-sm break-words text-gray-500 #{body.get_html(:classes, view: :index, element: :wrapper)}", style: body.get_html(:style, view: :index, element: :wrapper) do %>
|
41
|
+
<%= body.value %>
|
42
|
+
<% end %>
|
43
|
+
<% end %>
|
18
44
|
</div>
|
19
45
|
<div class="w-full place-self-end">
|
20
46
|
<%= render(Avo::Index::ResourceControlsComponent.new(resource: @resource, reflection: @reflection, parent_record: @parent_record, parent_resource: @parent_resource, view_type: :grid, actions: actions)) %>
|
21
47
|
</div>
|
22
|
-
|
48
|
+
<% end %>
|
23
49
|
</div>
|
@@ -2,26 +2,30 @@
|
|
2
2
|
|
3
3
|
class Avo::Index::GridItemComponent < Avo::BaseComponent
|
4
4
|
include Avo::ResourcesHelper
|
5
|
-
include Avo::Fields::Concerns::HasHTMLAttributes
|
6
5
|
|
7
6
|
attr_reader :parent_resource, :actions
|
8
7
|
|
9
8
|
def initialize(resource: nil, reflection: nil, parent_record: nil, parent_resource: nil, actions: nil)
|
10
9
|
@resource = resource
|
11
10
|
@reflection = reflection
|
11
|
+
@grid_fields = resource.get_grid_fields
|
12
12
|
@parent_record = parent_record
|
13
13
|
@parent_resource = parent_resource
|
14
14
|
@actions = actions
|
15
|
-
@card = Avo::ExecutionContext.new(target: resource.grid_view[:card], resource: resource, record: resource.record).handle
|
16
|
-
@whole_html = Avo::ExecutionContext.new(target: resource.grid_view[:html], resource: resource, record: resource.record).handle
|
17
15
|
end
|
18
16
|
|
19
17
|
private
|
20
18
|
|
21
|
-
def
|
22
|
-
|
19
|
+
def cover
|
20
|
+
@grid_fields.cover_field
|
21
|
+
end
|
22
|
+
|
23
|
+
def title
|
24
|
+
@grid_fields.title_field
|
25
|
+
end
|
23
26
|
|
24
|
-
|
27
|
+
def body
|
28
|
+
@grid_fields.body_field
|
25
29
|
end
|
26
30
|
|
27
31
|
def resource_view_path
|
@@ -36,34 +40,4 @@ class Avo::Index::GridItemComponent < Avo::BaseComponent
|
|
36
40
|
|
37
41
|
helpers.resource_view_path(record: @resource.record, resource: parent_or_child_resource, **args)
|
38
42
|
end
|
39
|
-
|
40
|
-
def render_cover
|
41
|
-
return link_to_cover if @card[:cover_url].present?
|
42
|
-
|
43
|
-
link_to resource_view_path do
|
44
|
-
render Avo::Index::GridCoverEmptyStateComponent.new
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def link_to_cover
|
49
|
-
classes = "absolute h-full w-full object-cover"
|
50
|
-
|
51
|
-
link_to image_tag(@card[:cover_url], class: classes), resource_view_path, class: classes, title: @card[:title]
|
52
|
-
end
|
53
|
-
|
54
|
-
def render_title
|
55
|
-
return if @card[:title].blank?
|
56
|
-
|
57
|
-
content_tag :div, class: "grid font-semibold leading-tight text-lg mb-2 #{html(:title, :classes)}", style: html(:title, :style) do
|
58
|
-
link_to @card[:title], resource_view_path
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def render_body
|
63
|
-
return if @card[:body].blank?
|
64
|
-
|
65
|
-
content_tag :div, class: "text-sm break-words text-gray-500 #{html(:body, :classes)}", style: html(:body, :style) do
|
66
|
-
@card[:body]
|
67
|
-
end
|
68
|
-
end
|
69
43
|
end
|
@@ -13,7 +13,10 @@ class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def can_detach?
|
16
|
-
|
16
|
+
@reflection.present? &&
|
17
|
+
@resource.record.present? &&
|
18
|
+
is_has_many_association &&
|
19
|
+
authorize_association_for(:detach)
|
17
20
|
end
|
18
21
|
|
19
22
|
def can_edit?
|
@@ -41,7 +44,7 @@ class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent
|
|
41
44
|
}
|
42
45
|
end
|
43
46
|
|
44
|
-
helpers.resource_path(record: @resource.record, resource: parent_or_child_resource, **args)
|
47
|
+
helpers.resource_path(record: @resource.record, resource: parent_or_child_resource , **args)
|
45
48
|
end
|
46
49
|
|
47
50
|
def edit_path
|
@@ -70,19 +73,19 @@ class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent
|
|
70
73
|
return @parent_resource if @parent_resource.present?
|
71
74
|
return nil if @parent_record.blank?
|
72
75
|
|
73
|
-
Avo.
|
76
|
+
::Avo::App.resources.get_resource_by_model_class @parent_record.class
|
74
77
|
end
|
75
78
|
|
76
|
-
def is_has_many_association
|
79
|
+
def is_has_many_association
|
77
80
|
@reflection.is_a?(::ActiveRecord::Reflection::HasManyReflection) || @reflection.is_a?(::ActiveRecord::Reflection::ThroughReflection)
|
78
81
|
end
|
79
82
|
|
80
83
|
def referrer_path
|
81
|
-
Avo.root_path(paths: ["resources", params[:resource_name], params[:id], params[:related_name]], query: request.query_parameters.to_h)
|
84
|
+
Avo::App.root_path(paths: ["resources", params[:resource_name], params[:id], params[:related_name]], query: request.query_parameters.to_h)
|
82
85
|
end
|
83
86
|
|
84
87
|
def can_reorder?
|
85
|
-
return false unless Object.const_defined? "
|
88
|
+
return false unless Object.const_defined? "AvoPro::Ordering"
|
86
89
|
|
87
90
|
return authorize_association_for(:reorder) if @reflection.present?
|
88
91
|
|
@@ -164,13 +167,13 @@ class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent
|
|
164
167
|
target: "control:detach",
|
165
168
|
control: :detach,
|
166
169
|
"resource-id": @resource.record.id,
|
167
|
-
tippy:
|
170
|
+
"tippy": "tooltip",
|
168
171
|
}
|
169
172
|
end
|
170
173
|
|
171
174
|
def render_order_controls(control)
|
172
175
|
if can_reorder?
|
173
|
-
render
|
176
|
+
render AvoPro::Ordering::ButtonsComponent.new resource: @resource, reflection: @reflection, view_type: @view_type
|
174
177
|
end
|
175
178
|
end
|
176
179
|
|
@@ -17,7 +17,7 @@ class Avo::Index::ResourceTableComponent < ViewComponent::Base
|
|
17
17
|
|
18
18
|
def encrypted_query
|
19
19
|
# TODO: move this to the resource where we can apply the adapter pattern
|
20
|
-
serialized_query = if
|
20
|
+
serialized_query = if query.instance_of?(Ransack::Search)
|
21
21
|
query.context.object.to_sql
|
22
22
|
else
|
23
23
|
return :select_all_disabled if query.nil? || !query.respond_to?(:all) || !query.all.respond_to?(:to_sql)
|
@@ -4,10 +4,13 @@
|
|
4
4
|
<% end %>
|
5
5
|
<% elsif item.is_panel? %>
|
6
6
|
<%= render Avo::PanelComponent.new(name: item.name, description: item.description, index: index) do |c| %>
|
7
|
-
<% c.
|
7
|
+
<% c.body do %>
|
8
8
|
<div class="divide-y">
|
9
9
|
<% item.visible_items.each_with_index do |field, index| %>
|
10
|
-
<%= render
|
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) %>
|
11
14
|
<% end %>
|
12
15
|
</div>
|
13
16
|
<% end %>
|
@@ -16,12 +19,4 @@
|
|
16
19
|
<%= render tab_group_component %>
|
17
20
|
<% elsif item.is_field? %>
|
18
21
|
<%= 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 %>
|
27
22
|
<% end %>
|
@@ -42,7 +42,6 @@ class Avo::ItemSwitcherComponent < Avo::BaseComponent
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def field_component
|
45
|
-
|
46
|
-
final_item.component_for_view(@view).new(field: final_item, resource: @resource, index: index, form: form)
|
45
|
+
item.component_for_view(@view).new(field: item.hydrate(resource: @resource, view: @view, record: @resource.record), resource: @resource, index: index, form: form)
|
47
46
|
end
|
48
47
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
data-modal-target="modal"
|
4
4
|
>
|
5
5
|
<div aria-expanded="true" class="modal-overlay absolute w-full h-full bg-opacity-25 bg-gray-800 flex justify-center items-center" data-action="click->modal#close"></div>
|
6
|
-
<div aria-expanded="true" role="dialog" aria-modal="true" class="modal-body rounded-lg inset-auto w-11/12 lg:w-1/2 sm:max-w-168 min-h-1/4 bg-white flex z-50 relative shadow-modal
|
6
|
+
<div aria-expanded="true" role="dialog" aria-modal="true" class="modal-body rounded-lg overflow-hidden inset-auto w-11/12 lg:w-1/2 sm:max-w-168 min-h-1/4 bg-white flex z-50 relative shadow-modal">
|
7
7
|
<div class="flex-1 flex flex-col justify-between">
|
8
8
|
<div>
|
9
9
|
<div class="p-6 text-2xl tracking-normal font-semibold text-black">
|
@@ -25,7 +25,7 @@
|
|
25
25
|
<% end %>
|
26
26
|
<% if body? %>
|
27
27
|
<div data-target="panel-body" class="flex flex-col sm:flex-row space-y-4 sm:space-y-0 sm:gap-4 w-full">
|
28
|
-
<div class="relative flex-1
|
28
|
+
<div class="relative flex-1 <% if sidebar? %> w-2/3 <% else %> w-full <% end %>">
|
29
29
|
<% # The body is wrapped inside another div in order to avoid long & tall panels next to sidebars when the sidebar taller. %>
|
30
30
|
<div class="relative <%= white_panel_classes %> <%= @body_classes %>">
|
31
31
|
<%= body %>
|
@@ -36,11 +36,6 @@
|
|
36
36
|
<%= sidebar %>
|
37
37
|
</div>
|
38
38
|
<% end %>
|
39
|
-
<% if bare_sidebar? %>
|
40
|
-
<div class="w-full sm:w-1/3 flex-shrink-0 h-full">
|
41
|
-
<%= bare_sidebar %>
|
42
|
-
</div>
|
43
|
-
<% end %>
|
44
39
|
</div>
|
45
40
|
<% end %>
|
46
41
|
<% if bare_content? %>
|
@@ -1,18 +1,3 @@
|
|
1
|
-
|
2
|
-
<%=
|
3
|
-
form_class: "flex-1 flex",
|
4
|
-
class: button_classes,
|
5
|
-
target: target,
|
6
|
-
title: title,
|
7
|
-
method: method,
|
8
|
-
params: params do %>
|
9
|
-
<%= helpers.svg(icon, class: 'h-4 mr-1') if icon.present? %> <%= label %>
|
10
|
-
<% end %>
|
11
|
-
<% else %>
|
12
|
-
<%= link_to path,
|
13
|
-
class: button_classes,
|
14
|
-
target: target,
|
15
|
-
title: title do %>
|
16
|
-
<%= helpers.svg(icon, class: 'h-4 mr-1') if icon.present? %> <%= label %>
|
17
|
-
<% end %>
|
1
|
+
<%= link_to path, class: "flex-1 flex items-center justify-center bg-white text-left cursor-pointer text-gray-800 font-semibold hover:bg-primary-100 block px-4 py-1 w-full py-3 text-center rounded w-full", target: target, title: title do %>
|
2
|
+
<%= helpers.svg(icon, class: 'h-4 mr-1') if icon.present? %> <%= label %>
|
18
3
|
<% end %>
|
@@ -6,29 +6,17 @@ class Avo::ProfileItemComponent < ViewComponent::Base
|
|
6
6
|
attr_reader :path
|
7
7
|
attr_reader :active
|
8
8
|
attr_reader :target
|
9
|
-
attr_reader :method
|
10
|
-
attr_reader :params
|
11
|
-
attr_reader :classes
|
12
9
|
|
13
|
-
def initialize(label: nil, icon: nil, path: nil, active: :inclusive, target: nil, title: nil
|
10
|
+
def initialize(label: nil, icon: nil, path: nil, active: :inclusive, target: nil, title: nil)
|
14
11
|
@label = label
|
15
12
|
@icon = icon
|
16
13
|
@path = path
|
17
14
|
@active = active
|
18
15
|
@target = target
|
19
16
|
@title = title
|
20
|
-
@method = method
|
21
|
-
@params = params
|
22
|
-
@classes = classes
|
23
17
|
end
|
24
18
|
|
25
19
|
def title
|
26
20
|
@title || @label
|
27
21
|
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def button_classes
|
32
|
-
"flex-1 flex items-center justify-center bg-white text-left cursor-pointer text-gray-800 font-semibold hover:bg-primary-100 block px-4 py-1 w-full py-3 text-center rounded w-full"
|
33
|
-
end
|
34
22
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
<%# via_association_type is used in has_one create actions %>
|
2
|
-
<%= hidden_field_tag :via_association_type, params[:via_association_type] if params[:via_association_type] %>
|
3
1
|
<%= hidden_field_tag :via_resource_class, params[:via_resource_class] if params[:via_resource_class] %>
|
4
2
|
<%= hidden_field_tag :via_record_id, params[:via_record_id] if params[:via_record_id] %>
|
5
3
|
<%= hidden_field_tag :via_relation, params[:via_relation] if params[:via_relation] %>
|