avo 2.7.1.pre.1 → 2.8.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 +2 -0
- data/Gemfile.lock +5 -5
- data/app/components/avo/alert_component.rb +6 -0
- data/app/components/avo/card_component.html.erb +2 -2
- data/app/components/avo/common_field_wrapper_component.html.erb +10 -3
- data/app/components/avo/common_field_wrapper_component.rb +27 -1
- data/app/components/avo/edit/field_wrapper_component.html.erb +1 -1
- data/app/components/avo/fields/badge_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/badge_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/belongs_to_field/autocomplete_component.html.erb +21 -10
- data/app/components/avo/fields/belongs_to_field/autocomplete_component.rb +7 -1
- data/app/components/avo/fields/belongs_to_field/edit_component.html.erb +27 -15
- data/app/components/avo/fields/belongs_to_field/edit_component.rb +4 -0
- data/app/components/avo/fields/belongs_to_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/belongs_to_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/boolean_field/edit_component.html.erb +4 -2
- data/app/components/avo/fields/boolean_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/boolean_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/boolean_group_field/edit_component.html.erb +7 -1
- data/app/components/avo/fields/boolean_group_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/boolean_group_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/code_field/edit_component.html.erb +7 -5
- data/app/components/avo/fields/code_field/show_component.html.erb +2 -2
- data/app/components/avo/fields/common/key_value_component.html.erb +10 -4
- data/app/components/avo/fields/common/key_value_component.rb +2 -0
- data/app/components/avo/fields/country_field/edit_component.html.erb +4 -2
- data/app/components/avo/fields/country_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/country_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/date_field/edit_component.html.erb +6 -4
- data/app/components/avo/fields/date_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/date_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/date_time_field/edit_component.html.erb +6 -4
- data/app/components/avo/fields/date_time_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/date_time_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/edit_component.rb +7 -0
- data/app/components/avo/fields/external_image_field/edit_component.html.erb +5 -2
- data/app/components/avo/fields/external_image_field/index_component.html.erb +6 -4
- data/app/components/avo/fields/external_image_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/file_field/edit_component.html.erb +6 -1
- data/app/components/avo/fields/file_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/file_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/files_field/edit_component.html.erb +7 -1
- data/app/components/avo/fields/files_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/files_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/gravatar_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/gravatar_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/has_one_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/hidden_field/edit_component.html.erb +5 -1
- data/app/components/avo/fields/id_field/edit_component.html.erb +1 -1
- data/app/components/avo/fields/id_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/id_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/index_component.rb +3 -0
- data/app/components/avo/fields/key_value_field/edit_component.html.erb +1 -1
- data/app/components/avo/fields/key_value_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/markdown_field/edit_component.html.erb +8 -5
- data/app/components/avo/fields/markdown_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/number_field/edit_component.html.erb +7 -4
- data/app/components/avo/fields/number_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/number_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/password_field/edit_component.html.erb +4 -2
- data/app/components/avo/fields/progress_bar_field/edit_component.html.erb +7 -4
- data/app/components/avo/fields/progress_bar_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/progress_bar_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/select_field/edit_component.html.erb +9 -3
- data/app/components/avo/fields/select_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/select_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/show_component.rb +3 -0
- data/app/components/avo/fields/status_field/edit_component.html.erb +6 -3
- data/app/components/avo/fields/status_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/status_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/tags_field/edit_component.html.erb +19 -11
- data/app/components/avo/fields/tags_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/tags_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/text_field/edit_component.html.erb +5 -2
- data/app/components/avo/fields/text_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/text_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/textarea_field/edit_component.html.erb +6 -3
- data/app/components/avo/fields/textarea_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/trix_field/edit_component.html.erb +13 -4
- data/app/components/avo/fields/trix_field/edit_component.rb +3 -0
- data/app/components/avo/fields/trix_field/show_component.html.erb +1 -1
- data/app/components/avo/index/field_wrapper_component.html.erb +12 -5
- data/app/components/avo/index/field_wrapper_component.rb +27 -3
- data/app/components/avo/panel_component.rb +4 -3
- data/app/components/avo/resource_component.rb +1 -0
- data/app/components/avo/show/field_wrapper_component.html.erb +1 -1
- data/app/components/avo/show/field_wrapper_component.rb +2 -1
- data/app/components/avo/views/resource_edit_component.html.erb +7 -4
- data/app/components/avo/views/resource_edit_component.rb +2 -1
- data/app/components/avo/views/resource_index_component.html.erb +6 -3
- data/app/components/avo/views/resource_index_component.rb +7 -1
- data/app/components/avo/views/resource_new_component.html.erb +7 -2
- data/app/components/avo/views/resource_new_component.rb +2 -1
- data/app/components/avo/views/resource_show_component.html.erb +9 -7
- data/app/components/avo/views/resource_show_component.rb +1 -0
- data/app/controllers/avo/actions_controller.rb +4 -1
- data/app/controllers/avo/base_controller.rb +14 -8
- data/app/controllers/avo/search_controller.rb +7 -1
- data/app/javascript/js/controllers/custom/course_resource_controller.js +102 -0
- data/app/javascript/js/controllers/fields/code_field_controller.js +7 -1
- data/app/javascript/js/controllers/fields/key_value_controller.js +1 -0
- data/app/javascript/js/controllers/fields/tags_field_controller.js +0 -1
- data/app/javascript/js/controllers/menu_controller.js +4 -3
- data/app/javascript/js/controllers/resource_edit_controller.js +72 -0
- data/app/javascript/js/controllers/resource_index_controller.js +4 -0
- data/app/javascript/js/controllers/resource_show_controller.js +4 -0
- data/app/javascript/js/controllers/search_controller.js +28 -5
- data/app/javascript/js/controllers.js +10 -0
- data/app/views/avo/associations/new.html.erb +2 -1
- data/app/views/avo/base/_select_filter.html.erb +1 -1
- data/app/views/avo/base/_text_filter.html.erb +1 -0
- data/app/views/avo/partials/_logo.html.erb +3 -2
- data/app/views/avo/partials/_navbar.html.erb +1 -1
- data/config/routes.rb +1 -1
- data/db/factories.rb +1 -0
- data/lib/avo/base_action.rb +9 -2
- data/lib/avo/base_card.rb +0 -23
- data/lib/avo/base_resource.rb +17 -15
- data/lib/avo/concerns/has_fields.rb +93 -0
- data/lib/avo/concerns/has_html_attributes.rb +110 -0
- data/lib/avo/concerns/has_stimulus_controllers.rb +42 -0
- data/lib/avo/fields/base_field.rb +23 -13
- data/lib/avo/fields/select_field.rb +1 -1
- data/lib/avo/grid_collector.rb +4 -4
- data/lib/avo/html/builder.rb +117 -0
- data/lib/avo/licensing/pro_license.rb +1 -0
- data/lib/avo/version.rb +1 -1
- data/lib/avo.rb +4 -0
- data/lib/generators/avo/templates/cards/chartkick_card_sample.tt +11 -1
- data/lib/generators/avo/templates/cards/metric_card_sample.tt +11 -1
- data/lib/generators/avo/templates/field/components/edit_component.html.erb.tt +1 -1
- data/lib/generators/avo/templates/field/components/index_component.html.erb.tt +1 -1
- data/lib/generators/avo/templates/field/components/show_component.html.erb.tt +1 -1
- data/lib/generators/avo/templates/initializer/avo.tt +1 -1
- data/lib/generators/avo/templates/locales/avo.en.yml +3 -3
- data/public/avo-assets/avo.css +28 -8
- data/public/avo-assets/avo.js +148 -148
- data/public/avo-assets/avo.js.map +3 -3
- data/public/avo-assets/logomark.png +0 -0
- metadata +13 -10
- data/app/assets/builds/action_cable.js +0 -2
- data/app/assets/builds/action_cable.js.map +0 -7
- data/app/assets/builds/avo.css +0 -9610
- data/app/assets/builds/avo.js +0 -512
- data/app/assets/builds/avo.js.map +0 -7
- data/lib/avo/fields_collector.rb +0 -70
@@ -1,8 +1,10 @@
|
|
1
|
-
<%= index_field_wrapper field: @field, flush: true do %>
|
1
|
+
<%= index_field_wrapper field: @field, resource: @resource, flush: true do %>
|
2
2
|
<% if @field.value.present? %>
|
3
|
-
<%=
|
4
|
-
|
5
|
-
|
3
|
+
<%= link_to_if @field.link_to_resource.present?,
|
4
|
+
image_tag(@field.value,
|
5
|
+
height: @field.height,
|
6
|
+
style: "border-radius: #{@field.radius}px; max-height: #{@field.height}#{@field.height.to_s&.ends_with?('px') ? '' : 'px'};"),
|
7
|
+
resource_path
|
6
8
|
%>
|
7
9
|
<% end %>
|
8
10
|
<% end %>
|
@@ -6,6 +6,11 @@
|
|
6
6
|
<% end %>
|
7
7
|
|
8
8
|
<% if @resource.authorization.authorize_action(:upload_attachments?, raise_exception: false) %>
|
9
|
-
<%= @form.file_field @field.id,
|
9
|
+
<%= @form.file_field @field.id,
|
10
|
+
data: @field.get_html(:data, view: view, element: :input),
|
11
|
+
direct_upload: @field.direct_upload,
|
12
|
+
disabled: @field.readonly,
|
13
|
+
style: @field.get_html(:style, view: view, element: :input)
|
14
|
+
%>
|
10
15
|
<% end %>
|
11
16
|
<% end %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= index_field_wrapper field: @field, flush: flush? do %>
|
1
|
+
<%= index_field_wrapper field: @field, resource: @resource, flush: flush? do %>
|
2
2
|
<% if @field.value.present? %>
|
3
3
|
<% if @field.value.attached? && @field.value.representable? && @field.is_image %>
|
4
4
|
<%= link_to_if @field.link_to_resource, image_tag(helpers.main_app.url_for(@field.value), class: 'h-10'), resource_path, class: 'block' %>
|
@@ -3,7 +3,13 @@
|
|
3
3
|
|
4
4
|
<% if @resource.authorization.authorize_action(:upload_attachments?, raise_exception: false) %>
|
5
5
|
<div class="mt-2">
|
6
|
-
<%= @form.file_field @field.id,
|
6
|
+
<%= @form.file_field @field.id,
|
7
|
+
data: @field.get_html(:data, view: view, element: :input),
|
8
|
+
direct_upload: @field.direct_upload,
|
9
|
+
disabled: @field.readonly,
|
10
|
+
multiple: true,
|
11
|
+
style: @field.get_html(:style, view: view, element: :input)
|
12
|
+
%>
|
7
13
|
</div>
|
8
14
|
<% end %>
|
9
15
|
<% end %>
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<%= show_field_wrapper field: @field, full_width: true do %>
|
1
|
+
<%= show_field_wrapper field: @field, resource: @resource, full_width: true do %>
|
2
2
|
<%= render Avo::Fields::Common::FilesListViewerComponent.new(field: @field, resource: @resource) if @field.value.present? %>
|
3
3
|
<% end %>
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<%= index_field_wrapper field: @field, class: 'whitespace-no-wrap w-[1%]' do %>
|
1
|
+
<%= index_field_wrapper field: @field, resource: @resource, class: 'whitespace-no-wrap w-[1%]' do %>
|
2
2
|
<% link_to_if (@field.link_to_resource or Avo.configuration.id_links_to_resource), @field.value, resource_path, title: t('avo.view_item', item: @resource.name).humanize %>
|
3
3
|
<% end %>
|
@@ -3,11 +3,14 @@
|
|
3
3
|
class Avo::Fields::IndexComponent < ViewComponent::Base
|
4
4
|
include Avo::ResourcesHelper
|
5
5
|
|
6
|
+
attr_reader :view
|
7
|
+
|
6
8
|
def initialize(field: nil, resource: nil, index: 0, parent_model: nil)
|
7
9
|
@field = field
|
8
10
|
@resource = resource
|
9
11
|
@index = index
|
10
12
|
@parent_model = parent_model
|
13
|
+
@view = :index
|
11
14
|
end
|
12
15
|
|
13
16
|
def resource_path
|
@@ -1,3 +1,3 @@
|
|
1
1
|
<%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, displayed_in_modal: @displayed_in_modal, full_width: true do %>
|
2
|
-
<%= render Avo::Fields::Common::KeyValueComponent.new field: @field, form: @form, view:
|
2
|
+
<%= render Avo::Fields::Common::KeyValueComponent.new field: @field, form: @form, view: @resource.view %>
|
3
3
|
<% end %>
|
@@ -1,12 +1,15 @@
|
|
1
1
|
<%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, displayed_in_modal: @displayed_in_modal, full_width: true do %>
|
2
2
|
<div data-controller="simple-mde">
|
3
3
|
<%= @form.text_area @field.id,
|
4
|
-
class:
|
5
|
-
|
4
|
+
class: classes("w-full js-has-simple-mde-editor"),
|
5
|
+
data: {
|
6
|
+
view: @resource.view,
|
7
|
+
'simple-mde-target': 'element',
|
8
|
+
'component-options': @field.options.to_json,
|
9
|
+
},
|
6
10
|
disabled: @field.readonly,
|
7
|
-
|
8
|
-
|
9
|
-
'data-view': :edit
|
11
|
+
placeholder: @field.placeholder,
|
12
|
+
style: @field.get_html(:style, view: view, element: :input)
|
10
13
|
%>
|
11
14
|
</div>
|
12
15
|
<% end %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= show_field_wrapper field: @field, index: @index, full_width: true do %>
|
1
|
+
<%= show_field_wrapper field: @field, resource: @resource, index: @index, full_width: true do %>
|
2
2
|
<div data-controller="simple-mde">
|
3
3
|
<%= text_area_tag @field.id, @field.value,
|
4
4
|
class: helpers.input_classes('w-full js-has-simple-mde-editor'),
|
@@ -1,9 +1,12 @@
|
|
1
1
|
<%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, displayed_in_modal: @displayed_in_modal do %>
|
2
2
|
<%= @form.number_field @field.id,
|
3
|
-
class:
|
4
|
-
|
3
|
+
class: classes("w-full"),
|
4
|
+
data: @field.get_html(:data, view: view, element: :input),
|
5
5
|
disabled: @field.readonly,
|
6
|
-
min: @field.min,
|
7
6
|
max: @field.max,
|
8
|
-
|
7
|
+
min: @field.min,
|
8
|
+
placeholder: @field.placeholder,
|
9
|
+
step: @field.step,
|
10
|
+
style: @field.get_html(:style, view: view, element: :input)
|
11
|
+
%>
|
9
12
|
<% end %>
|
@@ -1,7 +1,9 @@
|
|
1
1
|
<%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, displayed_in_modal: @displayed_in_modal do %>
|
2
2
|
<%= @form.password_field @field.id,
|
3
|
-
class:
|
3
|
+
class: classes("w-full"),
|
4
|
+
data: @field.get_html(:data, view: view, element: :input),
|
5
|
+
disabled: @field.readonly,
|
4
6
|
placeholder: @field.placeholder,
|
5
|
-
|
7
|
+
style: @field.get_html(:style, view: view, element: :input)
|
6
8
|
%>
|
7
9
|
<% end %>
|
@@ -5,12 +5,15 @@
|
|
5
5
|
</div>
|
6
6
|
<% end %>
|
7
7
|
<%= @form.range_field @field.id,
|
8
|
-
|
8
|
+
class: "w-full #{@field.get_html(:classes, view: view, element: :input)}",
|
9
|
+
data: @field.get_html(:data, view: view, element: :input),
|
10
|
+
disabled: @field.readonly,
|
9
11
|
max: @field.max,
|
10
|
-
|
11
|
-
class: 'w-full',
|
12
|
+
min: 0,
|
12
13
|
placeholder: @field.placeholder,
|
13
|
-
|
14
|
+
step: @field.step,
|
15
|
+
style: @field.get_html(:style, view: view, element: :input)
|
16
|
+
%>
|
14
17
|
<% end %>
|
15
18
|
|
16
19
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= index_field_wrapper field: @field, flush: true do %>
|
1
|
+
<%= index_field_wrapper field: @field, resource: @resource, flush: true do %>
|
2
2
|
<% if @field.display_value %>
|
3
3
|
<div class="text-center text-sm font-semibold w-full leading-none mb-1">
|
4
4
|
<%= @field.value %><%= @field.value_suffix if @field.value_suffix.present? %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= show_field_wrapper field: @field, index: @index do %>
|
1
|
+
<%= show_field_wrapper field: @field, resource: @resource, index: @index do %>
|
2
2
|
<% if @field.display_value %>
|
3
3
|
<div class="text-center text-sm font-semibold w-full leading-none mb-1">
|
4
4
|
<%= @field.value %><%= @field.value_suffix if @field.value_suffix.present? %>
|
@@ -1,6 +1,12 @@
|
|
1
1
|
<%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, displayed_in_modal: @displayed_in_modal do %>
|
2
2
|
<%= @form.select @field.id, @field.options_for_select, { selected: @field.value, prompt: @field.placeholder }, {
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
aria: {
|
4
|
+
placeholder: @field.placeholder
|
5
|
+
},
|
6
|
+
class: classes("w-full"),
|
7
|
+
data: @field.get_html(:data, view: view, element: :input),
|
8
|
+
disabled: @field.readonly,
|
9
|
+
style: @field.get_html(:style, view: view, element: :input),
|
10
|
+
value: @field.model.present? ? @field.model[@field.id] : @field.value
|
11
|
+
} %>
|
6
12
|
<% end %>
|
@@ -1,7 +1,10 @@
|
|
1
1
|
<%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, displayed_in_modal: @displayed_in_modal do %>
|
2
2
|
<%= @form.text_field @field.id,
|
3
|
-
class:
|
4
|
-
|
3
|
+
class: classes("w-full"),
|
4
|
+
data: @field.get_html(:data, view: view, element: :input),
|
5
5
|
disabled: @field.readonly,
|
6
|
-
|
6
|
+
placeholder: @field.placeholder,
|
7
|
+
style: @field.get_html(:style, view: view, element: :input),
|
8
|
+
value: @resource.model.present? ? @resource.model[@field.id] : @field.value
|
9
|
+
%>
|
7
10
|
<% end %>
|
@@ -1,20 +1,23 @@
|
|
1
|
-
<%= edit_field_wrapper field: @field,
|
1
|
+
<%= edit_field_wrapper field: @field,
|
2
|
+
index: @index,
|
3
|
+
form: @form,
|
4
|
+
resource: @resource,
|
5
|
+
displayed_in_modal: @displayed_in_modal do %>
|
2
6
|
<div data-controller="tags-field">
|
3
7
|
<%# dummy field %>
|
4
8
|
<%= text_field_tag "#{@field.id}-dummy", '',
|
5
|
-
class:
|
6
|
-
placeholder: @field.placeholder,
|
7
|
-
disabled: @field.readonly,
|
8
|
-
value: '',
|
9
|
+
class: classes("w-full"),
|
9
10
|
data: {
|
10
11
|
'tags-field-target': 'fakeInput',
|
11
|
-
}
|
12
|
+
},
|
13
|
+
disabled: @field.readonly,
|
14
|
+
placeholder: @field.placeholder,
|
15
|
+
style: @field.get_html(:style, view: view, element: :input),
|
16
|
+
value: ''
|
17
|
+
%>
|
12
18
|
<%# real field %>
|
13
19
|
<%= @form.text_field @field.id,
|
14
|
-
class:
|
15
|
-
placeholder: @field.placeholder,
|
16
|
-
disabled: @field.readonly,
|
17
|
-
value: @field.field_value.to_json,
|
20
|
+
class: classes("hidden w-full"),
|
18
21
|
data: {
|
19
22
|
'tags-field-target': 'input',
|
20
23
|
'whitelist-items': @field.suggestions.to_json,
|
@@ -22,6 +25,11 @@
|
|
22
25
|
'enforce-suggestions': @field.enforce_suggestions ? 1 : 0,
|
23
26
|
'delimiters': @field.delimiters,
|
24
27
|
'close-on-select': @field.close_on_select ? 1 : 0,
|
25
|
-
}
|
28
|
+
},
|
29
|
+
disabled: @field.readonly,
|
30
|
+
placeholder: @field.placeholder,
|
31
|
+
style: @field.get_html(:style, view: view, element: :input),
|
32
|
+
value: @field.field_value.to_json
|
33
|
+
%>
|
26
34
|
</div>
|
27
35
|
<% end %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= index_field_wrapper field: @field, flush: true do %>
|
1
|
+
<%= index_field_wrapper field: @field, resource: @resource, flush: true do %>
|
2
2
|
<div class="flex gap-1 items-center flex-nowrap">
|
3
3
|
<% value.take(3).each do |item| %>
|
4
4
|
<%= render Avo::Fields::TagsField::TagComponent.new(label: label_from_item(item)) %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= show_field_wrapper field: @field, index: @index do %>
|
1
|
+
<%= show_field_wrapper field: @field, resource: @resource, index: @index do %>
|
2
2
|
<div class="flex gap-1 items-center flex-wrap">
|
3
3
|
<% @field.field_value.each do |item| %>
|
4
4
|
<%= render Avo::Fields::TagsField::TagComponent.new(label: label_from_item(item)) %>
|
@@ -1,6 +1,9 @@
|
|
1
1
|
<%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, displayed_in_modal: @displayed_in_modal do %>
|
2
2
|
<%= @form.text_field @field.id,
|
3
|
-
class:
|
3
|
+
class: classes("w-full"),
|
4
|
+
data: @field.get_html(:data, view: view, element: :input),
|
5
|
+
disabled: @field.readonly,
|
4
6
|
placeholder: @field.placeholder,
|
5
|
-
|
7
|
+
style: @field.get_html(:style, view: view, element: :input)
|
8
|
+
%>
|
6
9
|
<% end %>
|
@@ -1,7 +1,10 @@
|
|
1
1
|
<%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, displayed_in_modal: @displayed_in_modal do %>
|
2
2
|
<%= @form.text_area @field.id,
|
3
|
-
class:
|
4
|
-
|
3
|
+
class: classes("w-full"),
|
4
|
+
data: @field.get_html(:data, view: view, element: :input),
|
5
5
|
disabled: @field.readonly,
|
6
|
-
|
6
|
+
placeholder: @field.placeholder,
|
7
|
+
rows: @field.rows,
|
8
|
+
style: @field.get_html(:style, view: view, element: :input)
|
9
|
+
%>
|
7
10
|
<% end %>
|
@@ -11,13 +11,22 @@
|
|
11
11
|
data-hide-attachment-url="<%= @field.hide_attachment_url %>"
|
12
12
|
class="relative block overflow-x-auto max-w-full"
|
13
13
|
>
|
14
|
-
|
15
|
-
|
14
|
+
<%= content_tag 'trix-editor',
|
15
|
+
data: {
|
16
|
+
"trix-field-target": "editor",
|
17
|
+
**@field.get_html(:data, view: view, element: :input)
|
18
|
+
},
|
19
|
+
input: trix_id,
|
20
|
+
placeholder: @field.placeholder do %>
|
21
|
+
<%== @field.value %>
|
22
|
+
<% end %>
|
16
23
|
<%= @form.text_area @field.id,
|
24
|
+
class: classes("w-full hidden"),
|
25
|
+
data: @field.get_html(:data, view: view, element: :input),
|
26
|
+
disabled: @field.readonly,
|
17
27
|
id: trix_id,
|
18
|
-
class: helpers.input_classes('w-full hidden', has_error: (@resource.model.present? and @resource.model.errors.include?(@field.id))),
|
19
28
|
placeholder: @field.placeholder,
|
20
|
-
|
29
|
+
style: @field.get_html(:style, view: view, element: :input)
|
21
30
|
%>
|
22
31
|
</div>
|
23
32
|
<% end %>
|
@@ -1,13 +1,20 @@
|
|
1
|
-
|
1
|
+
<%= content_tag :td,
|
2
|
+
class: "min-h-[3rem] px-3 leading-tight whitespace-nowrap h-full text-slate-800 text-base #{classes}",
|
3
|
+
data: {
|
4
|
+
field_id: @field.id,
|
5
|
+
field_type: @field.type,
|
6
|
+
**stimulus_attributes
|
7
|
+
},
|
8
|
+
style: style do %>
|
2
9
|
<% if @field.value.blank? && @dash_if_blank %>
|
3
10
|
—
|
4
11
|
<% else %>
|
5
12
|
<% if @center_content %>
|
6
|
-
|
7
|
-
|
8
|
-
|
13
|
+
<div class="flex items-center justify-center">
|
14
|
+
<%= content %>
|
15
|
+
</div>
|
9
16
|
<% else %>
|
10
17
|
<%= content %>
|
11
18
|
<% end %>
|
12
19
|
<% end %>
|
13
|
-
|
20
|
+
<% end %>
|
@@ -1,13 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Avo::Index::FieldWrapperComponent < ViewComponent::Base
|
4
|
-
|
4
|
+
attr_reader :view
|
5
|
+
|
6
|
+
def initialize(field: nil, resource: nil, dash_if_blank: true, center_content: false, flush: false, **args)
|
5
7
|
@field = field
|
8
|
+
@resource = resource
|
6
9
|
@dash_if_blank = dash_if_blank
|
7
10
|
@center_content = center_content
|
8
11
|
@classes = args[:class].present? ? args[:class] : ""
|
9
12
|
@args = args
|
10
13
|
@flush = flush
|
14
|
+
@view = :index
|
11
15
|
end
|
12
16
|
|
13
17
|
def classes
|
@@ -18,18 +22,38 @@ class Avo::Index::FieldWrapperComponent < ViewComponent::Base
|
|
18
22
|
end
|
19
23
|
|
20
24
|
result += " #{text_align_classes}"
|
25
|
+
result += " #{@field.get_html(:classes, view: view, element: :wrapper)}"
|
21
26
|
|
22
27
|
result
|
23
28
|
end
|
24
29
|
|
30
|
+
def style
|
31
|
+
@field.get_html(:style, view: view, element: :wrapper)
|
32
|
+
end
|
33
|
+
|
34
|
+
def stimulus_attributes
|
35
|
+
attributes = {}
|
36
|
+
|
37
|
+
@resource.get_stimulus_controllers.split(" ").each do |controller|
|
38
|
+
attributes["#{controller}-target"] = "#{@field.id.to_s.underscore}_#{@field.type.to_s.underscore}_wrapper".camelize(:lower)
|
39
|
+
end
|
40
|
+
|
41
|
+
wrapper_data_attributes = @field.get_html :data, view: view, element: :wrapper
|
42
|
+
if wrapper_data_attributes.present?
|
43
|
+
attributes.merge! wrapper_data_attributes
|
44
|
+
end
|
45
|
+
|
46
|
+
attributes
|
47
|
+
end
|
48
|
+
|
25
49
|
private
|
26
50
|
|
27
51
|
def text_align_classes
|
28
52
|
case @field.index_text_align.to_sym
|
29
53
|
when :right
|
30
|
-
|
54
|
+
"text-right"
|
31
55
|
when :center
|
32
|
-
|
56
|
+
"text-center"
|
33
57
|
end
|
34
58
|
end
|
35
59
|
end
|
@@ -25,9 +25,10 @@ class Avo::PanelComponent < ViewComponent::Base
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def data_attributes
|
28
|
-
@data.merge({
|
29
|
-
|
30
|
-
|
28
|
+
@data.merge({"panel-index": @index})
|
29
|
+
.map do |key, value|
|
30
|
+
" data-#{key}=\"#{value}\""
|
31
|
+
end.join
|
31
32
|
end
|
32
33
|
|
33
34
|
def display_breadcrumbs?
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= render Avo::CommonFieldWrapperComponent.new(field: @field, dash_if_blank: @dash_if_blank, full_width: @full_width) do %>
|
1
|
+
<%= render Avo::CommonFieldWrapperComponent.new(field: @field, resource: @resource, dash_if_blank: @dash_if_blank, full_width: @full_width, view: :show) do %>
|
2
2
|
<div class="self-center <% if @full_width %> w-full <% else %> w-full md:w-8/12 <% end %>" data-slot="value">
|
3
3
|
<% if @field.value.blank? and @dash_if_blank %>
|
4
4
|
—
|
@@ -1,8 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Avo::Show::FieldWrapperComponent < ViewComponent::Base
|
4
|
-
def initialize(field: nil, dash_if_blank: true, full_width: false, **args)
|
4
|
+
def initialize(field: nil, resource: nil, dash_if_blank: true, full_width: false, **args)
|
5
5
|
@field = field
|
6
|
+
@resource = resource
|
6
7
|
@dash_if_blank = dash_if_blank
|
7
8
|
@classes = args[:class].present? ? args[:class] : ""
|
8
9
|
@args = args
|