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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '083a689ccb76278fae699dd89eb21f5cf1dc86a306e2d25c1015a9297eb6f171'
|
4
|
+
data.tar.gz: ba27d9448b88241853e50a260764f70e232b566352b959c1b8265c5d547d3fea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cd68a6ab28242fcd7db9706e58e0ce49575acd055bdddf4be7231092301b46a218ac492b6634b041b8e181ddfc3871e968b280188025d1d05ba715e5c8d94bb
|
7
|
+
data.tar.gz: 5aff67676e320a05f76c5403124470f6c2ab027dc16853c74eeb991a26d22f8259014e26aae581e9ac6b39f7ed8837379359ae525560632039728148e7a14857
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
avo (2.
|
4
|
+
avo (2.8.0)
|
5
5
|
active_link_to
|
6
6
|
addressable
|
7
7
|
breadcrumbs_on_rails
|
@@ -167,6 +167,7 @@ GEM
|
|
167
167
|
dotenv (= 2.7.6)
|
168
168
|
railties (>= 3.2)
|
169
169
|
dry-initializer (3.1.1)
|
170
|
+
erb-formatter (0.3.0)
|
170
171
|
erubi (1.10.0)
|
171
172
|
factory_bot (6.2.0)
|
172
173
|
activesupport (>= 5.0.0)
|
@@ -210,7 +211,7 @@ GEM
|
|
210
211
|
io-wait (0.2.1)
|
211
212
|
iso (0.4.0)
|
212
213
|
i18n
|
213
|
-
jmespath (1.
|
214
|
+
jmespath (1.6.1)
|
214
215
|
jsbundling-rails (1.0.0)
|
215
216
|
railties (>= 6.0.0)
|
216
217
|
launchy (2.5.0)
|
@@ -251,8 +252,6 @@ GEM
|
|
251
252
|
nokogiri (1.13.4)
|
252
253
|
mini_portile2 (~> 2.8.0)
|
253
254
|
racc (~> 1.4)
|
254
|
-
nokogiri (1.13.4-x86_64-linux)
|
255
|
-
racc (~> 1.4)
|
256
255
|
orm_adapter (0.5.0)
|
257
256
|
pagy (5.10.1)
|
258
257
|
activesupport
|
@@ -266,7 +265,7 @@ GEM
|
|
266
265
|
pundit (2.2.0)
|
267
266
|
activesupport (>= 3.0.0)
|
268
267
|
racc (1.6.0)
|
269
|
-
rack (2.2.3)
|
268
|
+
rack (2.2.3.1)
|
270
269
|
rack-test (1.1.0)
|
271
270
|
rack (>= 1.0, < 3)
|
272
271
|
rails (6.1.4.6)
|
@@ -443,6 +442,7 @@ DEPENDENCIES
|
|
443
442
|
database_cleaner
|
444
443
|
devise
|
445
444
|
dotenv-rails
|
445
|
+
erb-formatter
|
446
446
|
factory_bot_rails
|
447
447
|
faker
|
448
448
|
friendly_id (~> 5.4.0)
|
@@ -21,6 +21,8 @@ class Avo::AlertComponent < ViewComponent::Base
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def classes
|
24
|
+
return "hidden" if is_empty?
|
25
|
+
|
24
26
|
result = "max-w-lg w-full shadow-lg rounded px-4 py-3 rounded relative border text-white pointer-events-auto"
|
25
27
|
|
26
28
|
result += if is_error?
|
@@ -51,4 +53,8 @@ class Avo::AlertComponent < ViewComponent::Base
|
|
51
53
|
def is_warning?
|
52
54
|
type.to_sym == :warning
|
53
55
|
end
|
56
|
+
|
57
|
+
def is_empty?
|
58
|
+
message.nil?
|
59
|
+
end
|
54
60
|
end
|
@@ -11,8 +11,8 @@
|
|
11
11
|
<%= @card.label %>
|
12
12
|
</div>
|
13
13
|
<div data-controller="select">
|
14
|
-
<% if @card.type
|
15
|
-
<%= select_tag "#{@card.id}_#{@card.index}_range", options_for_select(@card.
|
14
|
+
<% if @card.type.in?([:metric, :chartkick, :partial]) && @card.ranges.present? %>
|
15
|
+
<%= select_tag "#{@card.id}_#{@card.index}_range", options_for_select(@card.ranges, @card.range),
|
16
16
|
class: 'appearance-none inline-flex bg-blue-gray-100 disabled:bg-blue-gray-300 disabled:cursor-not-allowed focus:bg-white text-sm text-blue-gray-700 disabled:text-blue-gray-700 leading-none rounded-md py-px px-2 leading-tight border outline-none outline w-24',
|
17
17
|
data: {
|
18
18
|
target: 'select',
|
@@ -1,5 +1,12 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
<%= content_tag :div,
|
2
|
+
class: classes("relative flex flex-col md:flex-row md:items-center pb-2 md:pb-0 leading-tight min-h-14"),
|
3
|
+
style: style,
|
4
|
+
data: {
|
5
|
+
field_id: @field.id,
|
6
|
+
field_type: @field.type,
|
7
|
+
**stimulus_attributes,
|
8
|
+
} do %>
|
9
|
+
<div class="h-full pt-4 md:pt-0 md:h-14 flex self-start items-center text-slate-800">
|
3
10
|
<div class="<% if @displayed_in_modal %> md:w-48 <% else %> md:w-64 px-6 md:px-6 <% end %> w-48 flex uppercase font-semibold text-gray-500 text-sm" data-slot="label">
|
4
11
|
<% if @form.present? %>
|
5
12
|
<%= @form.label @field.id, label %>
|
@@ -12,4 +19,4 @@
|
|
12
19
|
<div class="flex-1 flex flex-row md:min-h-inherit py-2 <% unless @displayed_in_modal %> px-6 <% end %>">
|
13
20
|
<%= content %>
|
14
21
|
</div>
|
15
|
-
|
22
|
+
<% end %>
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Avo::CommonFieldWrapperComponent < ViewComponent::Base
|
4
|
-
|
4
|
+
attr_reader :view
|
5
|
+
|
6
|
+
def initialize(field: nil, dash_if_blank: true, full_width: false, displayed_in_modal: false, form: nil, resource: nil, label: nil, view: nil, **args)
|
5
7
|
@field = field
|
6
8
|
@dash_if_blank = dash_if_blank
|
7
9
|
@classes = args[:class].present? ? args[:class] : ""
|
@@ -12,9 +14,33 @@ class Avo::CommonFieldWrapperComponent < ViewComponent::Base
|
|
12
14
|
@model = resource.present? ? resource.model : nil
|
13
15
|
@full_width = full_width
|
14
16
|
@label = label
|
17
|
+
@view = view
|
18
|
+
end
|
19
|
+
|
20
|
+
def classes(extra_classes = "")
|
21
|
+
"#{@classes || ""} #{extra_classes || ""} #{@field.get_html(:classes, view: view, element: :wrapper)}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def style
|
25
|
+
@field.get_html(:style, view: view, element: :wrapper)
|
15
26
|
end
|
16
27
|
|
17
28
|
def label
|
18
29
|
@label || @field.name
|
19
30
|
end
|
31
|
+
|
32
|
+
def stimulus_attributes
|
33
|
+
attributes = {}
|
34
|
+
|
35
|
+
@resource.get_stimulus_controllers.split(" ").each do |controller|
|
36
|
+
attributes["#{controller}-target"] = "#{@field.id.to_s.underscore}_#{@field.type.to_s.underscore}_wrapper".camelize(:lower)
|
37
|
+
end
|
38
|
+
|
39
|
+
wrapper_data_attributes = @field.get_html :data, view: view, element: :wrapper
|
40
|
+
if wrapper_data_attributes.present?
|
41
|
+
attributes.merge! wrapper_data_attributes
|
42
|
+
end
|
43
|
+
|
44
|
+
attributes
|
45
|
+
end
|
20
46
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= render Avo::CommonFieldWrapperComponent.new(field: @field, resource: @resource, index: @index, form: @form, displayed_in_modal: @displayed_in_modal, label: @label) do %>
|
1
|
+
<%= render Avo::CommonFieldWrapperComponent.new(field: @field, resource: @resource, index: @index, form: @form, displayed_in_modal: @displayed_in_modal, label: @label, view: @resource.view, class: @classes) do %>
|
2
2
|
<div class="self-center <% if @displayed_in_modal or @full_width %> w-full <% else %> w-full md:w-8/12 <% end %>" data-slot="value">
|
3
3
|
<%= content %>
|
4
4
|
<% if @model.present? and @model.errors.include? @field.id %>
|
@@ -13,24 +13,35 @@
|
|
13
13
|
></div>
|
14
14
|
<div class="relative w-full" autocomplete="off">
|
15
15
|
<%= @form.text_field @foreign_key,
|
16
|
-
|
17
|
-
value: field_label,
|
18
|
-
class: helpers.input_classes('w-full', has_error: @field.model_errors.include?(@field.id)),
|
19
|
-
placeholder: @field.placeholder,
|
20
|
-
'data-search-target': 'button clearValue',
|
16
|
+
class: classes,
|
21
17
|
# This instructs the search_controller if it should enable/disabled this field when the user switches polymorphic associations
|
22
18
|
# It should not enable the field if the record is being created through an association
|
23
|
-
|
24
|
-
|
19
|
+
data: {
|
20
|
+
'search-target': 'button clearValue',
|
21
|
+
'should-be-disabled': @disabled,
|
22
|
+
**@field.get_html(:data, view: view, element: :input)
|
23
|
+
},
|
24
|
+
disabled: true,
|
25
|
+
placeholder: @field.placeholder,
|
26
|
+
style: @field.get_html(:style, view: view, element: :input),
|
27
|
+
type: :text,
|
28
|
+
value: field_label %>
|
25
29
|
<% unless @disabled %>
|
26
|
-
<
|
30
|
+
<button class="absolute top-1/2 left-auto right-3 mr-px -mt-2 cursor-pointer hidden text-gray-500"
|
31
|
+
type="button"
|
27
32
|
data-tippy="tooltip"
|
28
33
|
data-search-target="clearButton"
|
29
34
|
title="<%= I18n.translate 'avo.clear_value' %>"
|
30
35
|
data-action="click->search#clearValue"
|
31
36
|
><%= helpers.svg 'x', class: 'h-4' %>
|
32
|
-
</
|
37
|
+
</button>
|
33
38
|
<% end %>
|
34
39
|
</div>
|
35
|
-
<%= @form.hidden_field @foreign_key,
|
40
|
+
<%= @form.hidden_field @foreign_key,
|
41
|
+
value: field_value,
|
42
|
+
data: {
|
43
|
+
'search-target': 'hiddenId clearValue',
|
44
|
+
**@field.get_html(:data, view: view, element: :input)
|
45
|
+
}
|
46
|
+
%>
|
36
47
|
</div>
|
@@ -1,14 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Avo::Fields::BelongsToField::AutocompleteComponent < ViewComponent::Base
|
4
|
-
|
4
|
+
attr_reader :classes
|
5
|
+
attr_reader :view
|
6
|
+
|
7
|
+
def initialize(form:, field:, model_key:, foreign_key:, disabled: false, type: nil, resource: nil, polymorphic_record: nil, view: nil, style: nil, classes: nil)
|
5
8
|
@form = form
|
6
9
|
@field = field
|
7
10
|
@type = type
|
11
|
+
@view = view
|
8
12
|
@model_key = model_key
|
9
13
|
@foreign_key = foreign_key
|
10
14
|
@resource = resource
|
11
15
|
@disabled = disabled
|
16
|
+
@style = style
|
17
|
+
@classes = classes
|
12
18
|
@polymorphic_record = polymorphic_record
|
13
19
|
end
|
14
20
|
|
@@ -19,10 +19,13 @@
|
|
19
19
|
include_blank: @field.placeholder,
|
20
20
|
},
|
21
21
|
{
|
22
|
-
class:
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
class: classes("w-full"),
|
23
|
+
data: {
|
24
|
+
**@field.get_html(:data, view: view, element: :input),
|
25
|
+
action: "change->belongs-to-field#changeType #{field_html_action}",
|
26
|
+
'belongs-to-field-target': "select",
|
27
|
+
},
|
28
|
+
disabled: disabled
|
26
29
|
}
|
27
30
|
%>
|
28
31
|
<%
|
@@ -40,13 +43,16 @@
|
|
40
43
|
<%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, displayed_in_modal: @displayed_in_modal, label: type.to_s.underscore.humanize do %>
|
41
44
|
<% if @field.searchable %>
|
42
45
|
<%= render Avo::Fields::BelongsToField::AutocompleteComponent.new form: @form,
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
disabled: disabled,
|
47
|
+
field: @field,
|
48
|
+
foreign_key: @field.id_input_foreign_key,
|
49
|
+
model_key: model_keys[type.to_s],
|
50
|
+
polymorphic_record: polymorphic_record,
|
51
|
+
resource: @resource,
|
52
|
+
style: @field.get_html(:style, view: view, element: :input),
|
53
|
+
type: type,
|
54
|
+
classes: classes("w-full"),
|
55
|
+
view: @resource.view
|
50
56
|
%>
|
51
57
|
<% else %>
|
52
58
|
<%= @form.select @field.id_input_foreign_key,
|
@@ -56,7 +62,8 @@
|
|
56
62
|
include_blank: @field.placeholder,
|
57
63
|
},
|
58
64
|
{
|
59
|
-
class:
|
65
|
+
class: classes("w-full"),
|
66
|
+
data: @field.get_html(:data, view: view, element: :input),
|
60
67
|
disabled: disabled
|
61
68
|
}
|
62
69
|
%>
|
@@ -79,7 +86,10 @@
|
|
79
86
|
model_key: @field.target_resource&.model_key,
|
80
87
|
foreign_key: @field.id_input_foreign_key,
|
81
88
|
resource: @resource,
|
82
|
-
disabled: disabled
|
89
|
+
disabled: disabled,
|
90
|
+
classes: classes("w-full"),
|
91
|
+
view: @resource.view,
|
92
|
+
style: @field.get_html(:style, view: view, element: :input)
|
83
93
|
%>
|
84
94
|
<% else %>
|
85
95
|
<%= @form.select @field.id_input_foreign_key, @field.options,
|
@@ -88,8 +98,10 @@
|
|
88
98
|
value: @field.value
|
89
99
|
},
|
90
100
|
{
|
91
|
-
class:
|
92
|
-
|
101
|
+
class: classes("w-full"),
|
102
|
+
data: @field.get_html(:data, view: view, element: :input),
|
103
|
+
disabled: disabled,
|
104
|
+
style: @field.get_html(:style, view: view, element: :input)
|
93
105
|
}
|
94
106
|
%>
|
95
107
|
<%
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<%= show_field_wrapper field: @field, index: @index do %>
|
1
|
+
<%= show_field_wrapper field: @field, resource: @resource, index: @index do %>
|
2
2
|
<%= link_to @field.label, helpers.resource_path(model: @field.value, resource: @field.target_resource, via_resource_class: @resource.model_class, via_resource_id: @resource.model.id) %>
|
3
3
|
<% end %>
|
@@ -1,9 +1,11 @@
|
|
1
1
|
<%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, dash_if_blank: false, displayed_in_modal: @displayed_in_modal do %>
|
2
2
|
<div class="h-8 flex items-center">
|
3
3
|
<%= @form.check_box @field.id,
|
4
|
-
|
4
|
+
checked: @field.value,
|
5
|
+
class: "text-lg h-4 w-4 #{@field.get_html(:classes, view: view, element: :input)}",
|
6
|
+
data: @field.get_html(:data, view: view, element: :input),
|
5
7
|
disabled: @field.readonly,
|
6
|
-
|
8
|
+
style: @field.get_html(:style, view: view, element: :input)
|
7
9
|
%>
|
8
10
|
</div>
|
9
11
|
<% end %>
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<%= index_field_wrapper field: @field, dash_if_blank: false, center_content: true, flush: true do %>
|
1
|
+
<%= index_field_wrapper field: @field, resource: @resource, dash_if_blank: false, center_content: true, flush: true do %>
|
2
2
|
<%= render Avo::Fields::Common::BooleanCheckComponent.new checked: @field.value %>
|
3
3
|
<% end %>
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<%= show_field_wrapper field: @field, index: @index, dash_if_blank: false do %>
|
1
|
+
<%= show_field_wrapper field: @field, resource: @resource, index: @index, dash_if_blank: false do %>
|
2
2
|
<%= render Avo::Fields::Common::BooleanCheckComponent.new checked: @field.value %>
|
3
3
|
<% end %>
|
@@ -17,7 +17,13 @@
|
|
17
17
|
end
|
18
18
|
%>
|
19
19
|
<label class="block">
|
20
|
-
<%= check_box_tag "#{model_param_key}[#{@field.id}][]", id, checked, {
|
20
|
+
<%= check_box_tag "#{model_param_key}[#{@field.id}][]", id, checked, {
|
21
|
+
class: "w-4 h-4 #{@field.get_html(:classes, view: view, element: :input)}",
|
22
|
+
data: @field.get_html(:data, view: view, element: :input),
|
23
|
+
disabled: @field.readonly,
|
24
|
+
id: "#{model_param_key}_#{@field.id}_#{id}",
|
25
|
+
style: @field.get_html(:style, view: view, element: :input)
|
26
|
+
} %> <%= label %>
|
21
27
|
</label>
|
22
28
|
<% end %>
|
23
29
|
</div>
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<%= index_field_wrapper field: @field, dash_if_blank: false do %>
|
1
|
+
<%= index_field_wrapper field: @field, resource: @resource, dash_if_blank: false do %>
|
2
2
|
<%= render Avo::Fields::Common::BooleanGroupComponent.new options: @field.options, value: @field.value %>
|
3
3
|
<% end %>
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<%= show_field_wrapper field: @field, index: @index, dash_if_blank: false do %>
|
1
|
+
<%= show_field_wrapper field: @field, resource: @resource, index: @index, dash_if_blank: false do %>
|
2
2
|
<%= render Avo::Fields::Common::BooleanGroupComponent.new options: @field.options, value: @field.value %>
|
3
3
|
<% end %>
|
@@ -1,19 +1,21 @@
|
|
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="code-field">
|
3
3
|
<%= @form.text_area @field.id,
|
4
|
-
class:
|
5
|
-
placeholder: @field.placeholder,
|
6
|
-
disabled: @field.readonly,
|
4
|
+
class: classes("w-full"),
|
7
5
|
data: {
|
8
6
|
'code-field-target': 'element',
|
9
|
-
view:
|
7
|
+
view: @resource.view,
|
10
8
|
language: @field.language,
|
11
9
|
theme: @field.theme,
|
12
10
|
'tab-size': @field.tab_size,
|
13
11
|
'read-only': @field.readonly,
|
14
12
|
'indent-with-tabs': @field.indent_with_tabs,
|
15
13
|
'line-wrapping': @field.line_wrapping,
|
16
|
-
|
14
|
+
**@field.get_html(:data, view: view, element: :input),
|
15
|
+
},
|
16
|
+
disabled: @field.readonly,
|
17
|
+
placeholder: @field.placeholder,
|
18
|
+
style: @field.get_html(:style, view: view, element: :input)
|
17
19
|
%>
|
18
20
|
</div>
|
19
21
|
<% 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="code-field" style="--height: <%= @field.height %>">
|
3
3
|
<%= text_area_tag @field.id, @field.value,
|
4
4
|
class: helpers.input_classes('w-full'),
|
@@ -6,7 +6,7 @@
|
|
6
6
|
disabled: true,
|
7
7
|
data: {
|
8
8
|
'code-field-target': 'element',
|
9
|
-
view:
|
9
|
+
view: @resource.view,
|
10
10
|
language: @field.language,
|
11
11
|
theme: @field.theme,
|
12
12
|
'tab-size': @field.tab_size,
|
@@ -38,16 +38,22 @@
|
|
38
38
|
value: @field.parsed_value,
|
39
39
|
class: 'hidden',
|
40
40
|
placeholder: @field.placeholder,
|
41
|
-
|
42
|
-
|
41
|
+
data: {
|
42
|
+
"key-value-target": 'input',
|
43
|
+
view: @view,
|
44
|
+
**@field.get_html(:data, view: view, element: :input)
|
45
|
+
}
|
43
46
|
%>
|
44
47
|
<% else %>
|
45
48
|
<%= text_area_tag @field.id,
|
46
49
|
@field.parsed_value,
|
47
50
|
class: 'hidden',
|
48
51
|
placeholder: @field.placeholder,
|
49
|
-
|
50
|
-
|
52
|
+
data: {
|
53
|
+
"key-value-target": 'input',
|
54
|
+
view: @view,
|
55
|
+
**@field.get_html(:data, view: view, element: :input)
|
56
|
+
}
|
51
57
|
%>
|
52
58
|
<% end %>
|
53
59
|
</div>
|
@@ -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.select @field.id, @field.select_options, { selected: @field.value, prompt: @field.placeholder },
|
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 %>
|
@@ -1,9 +1,7 @@
|
|
1
1
|
<%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, displayed_in_modal: @displayed_in_modal do %>
|
2
2
|
<div data-controller="date-field">
|
3
3
|
<%= @form.date_field @field.id,
|
4
|
-
class:
|
5
|
-
placeholder: @field.placeholder,
|
6
|
-
disabled: @field.readonly,
|
4
|
+
class: classes("w-full"),
|
7
5
|
data: {
|
8
6
|
'date-field-target': 'input',
|
9
7
|
'first-day-of-week': @field.first_day_of_week,
|
@@ -12,7 +10,11 @@
|
|
12
10
|
format: @field.format,
|
13
11
|
placeholder: @field.placeholder,
|
14
12
|
relative: @field.relative,
|
15
|
-
|
13
|
+
**@field.get_html(:data, view: view, element: :input)
|
14
|
+
},
|
15
|
+
disabled: @field.readonly,
|
16
|
+
placeholder: @field.placeholder,
|
17
|
+
style: @field.get_html(:style, view: view, element: :input)
|
16
18
|
%>
|
17
19
|
</div>
|
18
20
|
<% end %>
|
@@ -1,9 +1,7 @@
|
|
1
1
|
<%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, displayed_in_modal: @displayed_in_modal do %>
|
2
2
|
<div data-controller="date-field">
|
3
3
|
<%= @form.datetime_field @field.id,
|
4
|
-
class:
|
5
|
-
placeholder: @field.placeholder,
|
6
|
-
disabled: @field.readonly,
|
4
|
+
class: classes("w-full"),
|
7
5
|
data: {
|
8
6
|
'date-field-target': 'input',
|
9
7
|
'first-day-of-week': @field.first_day_of_week,
|
@@ -14,7 +12,11 @@
|
|
14
12
|
format: @field.format,
|
15
13
|
placeholder: @field.placeholder,
|
16
14
|
relative: @field.relative,
|
17
|
-
|
15
|
+
**@field.get_html(:data, view: view, element: :input)
|
16
|
+
},
|
17
|
+
disabled: @field.readonly,
|
18
|
+
placeholder: @field.placeholder,
|
19
|
+
style: @field.get_html(:style, view: view, element: :input)
|
18
20
|
%>
|
19
21
|
</div>
|
20
22
|
<% end %>
|
@@ -3,11 +3,18 @@
|
|
3
3
|
class Avo::Fields::EditComponent < ViewComponent::Base
|
4
4
|
include Avo::ResourcesHelper
|
5
5
|
|
6
|
+
attr_reader :view
|
7
|
+
|
6
8
|
def initialize(field: nil, resource: nil, index: 0, form: nil, displayed_in_modal: false)
|
7
9
|
@field = field
|
8
10
|
@resource = resource
|
9
11
|
@index = index
|
10
12
|
@form = form
|
11
13
|
@displayed_in_modal = displayed_in_modal
|
14
|
+
@view = :edit
|
15
|
+
end
|
16
|
+
|
17
|
+
def classes(extra_classes = "")
|
18
|
+
helpers.input_classes("#{@field.get_html(:classes, view: view, element: :input)} #{extra_classes}", has_error: @field.model_errors.include?(@field.id))
|
12
19
|
end
|
13
20
|
end
|
@@ -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 %>
|