avo 2.16.1.pre.1.nativefields → 2.17.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 +4 -2
- data/Gemfile.lock +3 -1
- data/README.md +1 -1
- data/app/assets/config/avo_manifest.js +1 -0
- data/app/assets/svgs/placeholder.svg +1 -0
- data/app/components/avo/actions_component.html.erb +3 -3
- data/app/components/avo/base_component.rb +7 -4
- data/app/components/avo/field_wrapper_component.html.erb +8 -10
- data/app/components/avo/field_wrapper_component.rb +14 -12
- data/app/components/avo/fields/badge_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/belongs_to_field/edit_component.rb +9 -3
- 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/belongs_to_field/show_component.rb +1 -1
- 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/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/show_component.html.erb +1 -1
- data/app/components/avo/fields/common/heading_component.html.erb +5 -4
- data/app/components/avo/fields/common/heading_component.rb +6 -1
- data/app/components/avo/fields/country_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/date_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/date_time_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/edit_component.rb +6 -4
- data/app/components/avo/fields/external_image_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/file_field/edit_component.html.erb +2 -1
- data/app/components/avo/fields/file_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/files_field/edit_component.html.erb +2 -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/has_one_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/heading_field/edit_component.html.erb +1 -1
- data/app/components/avo/fields/heading_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/id_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/index_component.rb +11 -2
- data/app/components/avo/fields/number_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/progress_bar_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/select_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/show_component.rb +7 -1
- data/app/components/avo/fields/status_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/tags_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/text_field/edit_component.html.erb +3 -1
- data/app/components/avo/fields/text_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/trix_field/edit_component.html.erb +1 -1
- data/app/components/avo/filters_component.html.erb +2 -2
- data/app/components/avo/index/grid_cover_empty_state_component.html.erb +1 -1
- data/app/components/avo/index/grid_item_component.html.erb +15 -13
- data/app/components/avo/index/grid_item_component.rb +1 -1
- data/app/components/avo/index/ordering/buttons_component.html.erb +1 -1
- data/app/components/avo/index/resource_controls_component.rb +2 -2
- data/app/components/avo/index/table_row_component.html.erb +1 -1
- data/app/components/avo/panel_component.html.erb +11 -2
- data/app/components/avo/panel_component.rb +1 -0
- data/app/components/avo/resource_component.rb +18 -0
- data/app/components/avo/resource_sidebar_component.html.erb +19 -0
- data/app/components/avo/resource_sidebar_component.rb +26 -0
- data/app/components/avo/sidebar_profile_component.html.erb +1 -1
- data/app/components/avo/tab_switcher_component.html.erb +2 -2
- data/app/components/avo/views/resource_edit_component.html.erb +31 -25
- data/app/components/avo/views/resource_edit_component.rb +1 -1
- data/app/components/avo/views/resource_show_component.html.erb +8 -2
- data/app/components/avo/views/resource_show_component.rb +1 -1
- data/app/controllers/avo/actions_controller.rb +10 -2
- data/app/controllers/avo/application_controller.rb +4 -2
- data/app/controllers/avo/associations_controller.rb +10 -5
- data/app/controllers/avo/attachments_controller.rb +2 -1
- data/app/controllers/avo/base_controller.rb +6 -4
- data/app/controllers/avo/search_controller.rb +13 -4
- data/app/helpers/avo/application_helper.rb +3 -3
- data/app/helpers/avo/resources_helper.rb +2 -2
- data/app/javascript/avo.base.js +3 -1
- data/app/javascript/js/controllers/action_controller.js +1 -4
- data/app/javascript/js/controllers/actions_picker_controller.js +8 -9
- data/app/javascript/js/controllers/tabs_controller.js +14 -27
- data/app/views/avo/actions/show.html.erb +2 -2
- data/app/views/avo/home/failed_to_load.html.erb +3 -2
- data/config/brakeman.ignore +40 -0
- data/db/factories.rb +20 -0
- data/lib/avo/base_resource.rb +26 -0
- data/lib/avo/concerns/fetches_things.rb +1 -1
- data/lib/avo/concerns/has_fields.rb +22 -0
- data/lib/avo/concerns/is_resource_item.rb +4 -0
- data/lib/avo/configuration/branding.rb +9 -1
- data/lib/avo/fields/belongs_to_field.rb +3 -0
- data/lib/avo/fields/heading_field.rb +15 -0
- data/lib/avo/items_holder.rb +4 -0
- data/lib/avo/licensing/pro_license.rb +1 -0
- data/lib/avo/menu/builder.rb +1 -1
- data/lib/avo/menu/menu.rb +0 -2
- data/lib/avo/reloader.rb +27 -26
- data/lib/avo/services/encryption_service.rb +1 -1
- data/lib/avo/sidebar.rb +60 -0
- data/lib/avo/sidebar_builder.rb +24 -0
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/templates/field/components/index_component.html.erb.tt +1 -1
- data/lib/generators/avo/templates/initializer/avo.tt +2 -1
- data/lib/generators/avo/templates/locales/avo.en.yml +0 -1
- data/lib/generators/avo/templates/locales/{avo.nb-NO.yml → avo.nb.yml} +35 -10
- data/lib/generators/avo/templates/locales/avo.nn.yml +118 -0
- data/lib/generators/avo/templates/locales/avo.tr.yml +119 -0
- data/public/avo-assets/avo.base.css +57 -75
- data/public/avo-assets/avo.base.js +63 -63
- data/public/avo-assets/avo.base.js.map +3 -3
- metadata +13 -7
- data/app/views/avo/home/failed_to_load.html copy.erb +0 -23
- data/config/master.key +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce1ecba413a03866498a9f2992647e7f1ab99a55b854a67ba86154fde854f7d1
|
4
|
+
data.tar.gz: a060cca4fd407dd9d479fa5aa5bd1c6688d6c3eaab3ca23bdfc7b338341452f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 703bc0074a7db187b5d5d75e4cb9a1db908b7eb5c2381c97f668993320b499d8a4b5fee55799576f087ecd712ccfca8896a59334a5d526167a8ba74771b5fb00
|
7
|
+
data.tar.gz: d90939f46f227a5a3e14d7bf5ee77b621f4311121ea6fbad75f8db2fb6905b6254d6a3efe553083bd9d552e441bae43d1615f652532344e2fdb414d7fb776dbd
|
data/Gemfile
CHANGED
@@ -71,7 +71,7 @@ group :development do
|
|
71
71
|
gem "bump", require: false
|
72
72
|
gem "gem-release", require: false
|
73
73
|
|
74
|
-
gem
|
74
|
+
gem "annotate"
|
75
75
|
|
76
76
|
# gem 'rack-mini-profiler'
|
77
77
|
# gem 'memory_profiler'
|
@@ -80,9 +80,11 @@ group :development do
|
|
80
80
|
|
81
81
|
# gem 'pry-rails'
|
82
82
|
|
83
|
-
gem
|
83
|
+
gem "htmlbeautifier"
|
84
84
|
|
85
85
|
gem "hotwire-livereload", "~> 1.1"
|
86
|
+
|
87
|
+
gem "brakeman"
|
86
88
|
end
|
87
89
|
|
88
90
|
group :development, :test do
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
avo (2.
|
4
|
+
avo (2.17.0)
|
5
5
|
active_link_to
|
6
6
|
addressable
|
7
7
|
breadcrumbs_on_rails
|
@@ -122,6 +122,7 @@ GEM
|
|
122
122
|
bindex (0.8.1)
|
123
123
|
bootsnap (1.13.0)
|
124
124
|
msgpack (~> 1.2)
|
125
|
+
brakeman (5.3.1)
|
125
126
|
breadcrumbs_on_rails (4.1.0)
|
126
127
|
railties (>= 5.0)
|
127
128
|
builder (3.2.4)
|
@@ -429,6 +430,7 @@ DEPENDENCIES
|
|
429
430
|
awesome_print
|
430
431
|
aws-sdk-s3
|
431
432
|
bootsnap (>= 1.4.2)
|
433
|
+
brakeman
|
432
434
|
breadcrumbs_on_rails
|
433
435
|
bump
|
434
436
|
bundler-integrity (~> 1.0)
|
data/README.md
CHANGED
@@ -48,7 +48,7 @@ Avo is a beautiful next-generation framework that empowers you, the developer, t
|
|
48
48
|
- **Menu builder** - Group and surface information as you need to
|
49
49
|
- **Branding** - Make it look
|
50
50
|
|
51
|
-
## Some of the things we're going
|
51
|
+
## Some of the things we're going to focus on next
|
52
52
|
|
53
53
|
Theming ⭐️ notifications ⭐️ Resource segmentation ⭐️ filterable fields ⭐️ inline editing ⭐️ multilingual records ⭐️ keyboard shortcuts ⭐️ track resource changes ⭐️ smart resource generation ⭐️ live resources ⭐️ columns view ⭐️ list view ⭐️ custom action items ⭐️ command bar ⭐️ use fields DSL in your custom views
|
54
54
|
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg fill="#9197A1" xmlns:x="http://ns.adobe.com/Extensibility/1.0/" xmlns:i="http://ns.adobe.com/AdobeIllustrator/10.0/" xmlns:graph="http://ns.adobe.com/Graphs/1.0/" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 100 125" style="enable-background:new 0 0 100 100;" xml:space="preserve"><switch><foreignObject requiredExtensions="http://ns.adobe.com/AdobeIllustrator/10.0/" x="0" y="0" width="1" height="1"/><g i:extraneous="self"><g><path d="M61.5,61.1c0-11.8-8.7-21.5-19.5-21.5c-10.7,0-19.5,9.6-19.5,21.5s8.7,21.5,19.5,21.5C52.8,82.6,61.5,73,61.5,61.1z M27.7,61.1c0-9,6.4-16.4,14.4-16.4s14.4,7.3,14.4,16.4S50,77.5,42.1,77.5S27.7,70.2,27.7,61.1z"/><path d="M44.6,54.3c0-1.4-1.1-2.5-2.5-2.5c-4.8,0-8.7,4.2-8.7,9.4c0,1.4,1.1,2.5,2.5,2.5s2.5-1.1,2.5-2.5c0-2.4,1.6-4.3,3.6-4.3 C43.5,56.8,44.6,55.7,44.6,54.3z"/><path d="M90.3,52.6c-1.1-9.3-5.8-21.5-12-31C72.7,12.9,63.3,2.5,50.7,2.5h-8.7c-11.6,0-21.5,11-24.6,27.4 c-1.1,5.7-3.2,11.2-5.2,16.3c-1.9,4.7-2.9,9.8-2.9,15c0,20,14.7,36.4,32.8,36.4h20.3c6,0,12.5-3.4,17.8-9.4 C88.3,79,92,66.1,90.3,52.6z M14.4,61.1c0-4.6,0.9-9,2.5-13.1c2.2-5.3,4.3-11.1,5.5-17.2C25,17.2,33.1,7.6,42.1,7.6 s17,9.6,19.6,23.2c1.2,6.2,3.3,11.9,5.5,17.2h0c1.7,4.1,2.5,8.5,2.5,13.1c0,17.2-12.4,31.3-27.7,31.3S14.4,78.4,14.4,61.1z M76.3,84.8c-4.2,4.8-9.5,7.6-14,7.6h-3.7c9.6-6.3,16.1-18,16.1-31.3c0-5.2-1-10.3-2.9-15c0,0,0,0,0,0 c-2.1-5.1-4.1-10.5-5.2-16.3C64.9,20.7,61.1,13.2,56,8.4c15.5,4.9,27.6,30.3,29.3,44.8C86.7,65.2,83.5,76.7,76.3,84.8z"/></g></g></switch></svg>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<div class="relative flex flex-col w-full sm:w-auto
|
1
|
+
<div class="relative flex flex-col w-full sm:w-auto js-actions-dropdown"
|
2
2
|
data-controller="toggle-panel actions-picker"
|
3
3
|
data-actions-picker-enabled-class="text-black hover:bg-primary-500 hover:text-white"
|
4
4
|
data-actions-picker-disabled-class="cursor-wait text-gray-500"
|
@@ -14,7 +14,7 @@
|
|
14
14
|
<%= t 'avo.actions' %>
|
15
15
|
<% end %>
|
16
16
|
<div
|
17
|
-
class="absolute flex inset-auto xl:right-0 top-full bg-white w-full sm:w-auto sm:min-w-[300px] mt-2 z-
|
17
|
+
class="absolute flex inset-auto xl:right-0 top-full bg-white w-full sm:w-auto sm:min-w-[300px] mt-2 z-40 shadow-modal rounded overflow-hidden hidden"
|
18
18
|
data-toggle-panel-target="panel"
|
19
19
|
>
|
20
20
|
<div class="w-full space divide-y">
|
@@ -28,7 +28,7 @@
|
|
28
28
|
},
|
29
29
|
title: action.action_name,
|
30
30
|
class: "flex items-center px-4 py-3 w-full font-semibold text-sm hover:bg-primary-100 #{is_disabled?(action) ? 'text-gray-500' : 'text-black'}" do %>
|
31
|
-
<%= svg 'play', class: 'h-5 mr-1 inline' %> <%= action.action_name %>
|
31
|
+
<%= svg 'play', class: 'h-5 mr-1 inline pointer-events-none' %> <%= action.action_name %>
|
32
32
|
<% end %>
|
33
33
|
<% end %>
|
34
34
|
</div>
|
@@ -17,13 +17,16 @@ class Avo::BaseComponent < ViewComponent::Base
|
|
17
17
|
end
|
18
18
|
|
19
19
|
# Fetch the resource and hydrate it with the model
|
20
|
-
def
|
21
|
-
|
22
|
-
|
20
|
+
def association_resource
|
21
|
+
resource = ::Avo::App.get_resource(params[:via_resource_class])
|
22
|
+
model_class_name = params[:via_relation_class] || resource.model_class
|
23
|
+
|
24
|
+
model_klass = ::Avo::BaseResource.valid_model_class model_class_name
|
23
25
|
|
24
|
-
resource = ::Avo::App.get_resource_by_model_name model_klass
|
25
26
|
model = model_klass.find params[:via_resource_id]
|
26
27
|
|
28
|
+
resource = ::Avo::App.get_resource_by_model_name model_klass if resource.blank?
|
29
|
+
|
27
30
|
resource.dup.hydrate model: model
|
28
31
|
end
|
29
32
|
|
@@ -2,8 +2,8 @@
|
|
2
2
|
class: classes,
|
3
3
|
style: style,
|
4
4
|
data: data do %>
|
5
|
-
<div class="h-full pt-4 md:pt-0 md:h-14 flex self-start items-center text-slate-800">
|
6
|
-
<div class="<% if
|
5
|
+
<div class="h-full <% if stacked? %> md:pt-4 <% else %> md:pt-0 md:h-14 <% end %> pt-4 flex self-start items-center text-slate-800">
|
6
|
+
<div class="w-48 <% if compact? %> md:w-48 xl:w-64 <% else %> md:w-64 <% end %> px-6 flex uppercase font-semibold text-gray-500 text-sm" data-slot="label">
|
7
7
|
<% if form.present? %>
|
8
8
|
<%= form.label field.id, label %>
|
9
9
|
<% else %>
|
@@ -12,17 +12,15 @@
|
|
12
12
|
<% if on_edit? && field.is_required? %> <span class="text-red-600 ml-1">*</span> <% end %>
|
13
13
|
</div>
|
14
14
|
</div>
|
15
|
-
<div class="flex-1 flex flex-row md:min-h-inherit py-2 <%
|
16
|
-
<% if
|
17
|
-
|
15
|
+
<div class="flex-1 flex flex-row md:min-h-inherit py-2 <% if stacked? %> pb-4 <% else %><% end %> px-6">
|
16
|
+
<div class="self-center <% if full_width? || compact? || stacked? %> w-full <% else %> md:w-8/12 <% end %>" data-slot="value">
|
17
|
+
<% if on_show? %>
|
18
18
|
<% if field.value.blank? and dash_if_blank %>
|
19
19
|
—
|
20
20
|
<% else %>
|
21
21
|
<%= content %>
|
22
22
|
<% end %>
|
23
|
-
|
24
|
-
<% elsif on_edit? %>
|
25
|
-
<div class="self-center <% if displayed_in_modal or full_width or compact? %> w-full <% else %> w-full md:w-8/12 <% end %>" data-slot="value">
|
23
|
+
<% elsif on_edit? %>
|
26
24
|
<%= content %>
|
27
25
|
<% if record.present? and record.errors.include? field.id %>
|
28
26
|
<div class="text-red-600 mt-2 text-sm"><%= record.errors.full_messages_for(field.id).to_sentence %></div>
|
@@ -30,8 +28,8 @@
|
|
30
28
|
<% if help.present? %>
|
31
29
|
<div class="text-gray-600 mt-2 text-sm"><%== help %></div>
|
32
30
|
<% end %>
|
33
|
-
|
34
|
-
|
31
|
+
<% end %>
|
32
|
+
</div>
|
35
33
|
</div>
|
36
34
|
<% if params[:avo_debug].present? %>
|
37
35
|
<!-- Raw value: -->
|
@@ -1,53 +1,47 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Avo::FieldWrapperComponent < ViewComponent::Base
|
4
|
-
# attr_reader :classes
|
5
4
|
attr_reader :dash_if_blank
|
6
|
-
|
7
|
-
attr_reader :displayed_in_modal
|
8
|
-
# attr_reader :help
|
5
|
+
attr_reader :compact
|
9
6
|
attr_reader :field
|
10
7
|
attr_reader :form
|
11
8
|
attr_reader :full_width
|
12
|
-
# attr_reader :label
|
13
9
|
attr_reader :resource
|
14
|
-
# attr_reader :record
|
15
|
-
# attr_reader :style
|
16
10
|
attr_reader :view
|
17
11
|
|
18
12
|
def initialize(
|
19
|
-
compact: false,
|
20
13
|
dash_if_blank: true,
|
21
14
|
data: {},
|
22
|
-
|
15
|
+
compact: false,
|
23
16
|
help: nil, # do we really need it?
|
24
17
|
field: nil,
|
25
18
|
form: nil,
|
26
19
|
full_width: false,
|
27
20
|
label: nil, # do we really need it?
|
28
21
|
resource: nil,
|
22
|
+
stacked: false,
|
29
23
|
style: "",
|
30
24
|
view: :show,
|
31
25
|
**args
|
32
26
|
)
|
33
27
|
@args = args
|
34
28
|
@classes = args[:class].present? ? args[:class] : ""
|
35
|
-
@compact = compact
|
36
29
|
@dash_if_blank = dash_if_blank
|
37
30
|
@data = data
|
38
|
-
@
|
31
|
+
@compact = compact
|
39
32
|
@help = help
|
40
33
|
@field = field
|
41
34
|
@form = form
|
42
35
|
@full_width = full_width
|
43
36
|
@label = label
|
44
37
|
@resource = resource
|
38
|
+
@stacked = stacked
|
45
39
|
@style = style
|
46
40
|
@view = view
|
47
41
|
end
|
48
42
|
|
49
43
|
def classes(extra_classes = "")
|
50
|
-
"relative flex flex-col flex-grow pb-2 md:pb-0 leading-tight min-h-14 #{
|
44
|
+
"relative flex flex-col flex-grow pb-2 md:pb-0 leading-tight min-h-14 #{stacked? ? "" : "md:flex-row md:items-center"} #{@classes || ""} #{extra_classes || ""} #{@field.get_html(:classes, view: view, element: :wrapper)}"
|
51
45
|
end
|
52
46
|
|
53
47
|
def style
|
@@ -96,7 +90,15 @@ class Avo::FieldWrapperComponent < ViewComponent::Base
|
|
96
90
|
attributes
|
97
91
|
end
|
98
92
|
|
93
|
+
def stacked?
|
94
|
+
@stacked
|
95
|
+
end
|
96
|
+
|
99
97
|
def compact?
|
100
98
|
@compact
|
101
99
|
end
|
100
|
+
|
101
|
+
def full_width?
|
102
|
+
@full_width
|
103
|
+
end
|
102
104
|
end
|
@@ -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(field: nil, resource: nil, index: 0, form: nil,
|
5
|
-
super field: field, resource: resource, index: index, form: form,
|
4
|
+
def initialize(field: nil, resource: nil, index: 0, form: nil, compact: false)
|
5
|
+
super field: field, resource: resource, index: index, form: form, compact: compact
|
6
6
|
|
7
7
|
@polymorphic_record = nil
|
8
8
|
end
|
@@ -12,7 +12,7 @@ class Avo::Fields::BelongsToField::EditComponent < Avo::Fields::EditComponent
|
|
12
12
|
|
13
13
|
# When visiting the record through it's association we keep the field disabled by default
|
14
14
|
# We make an exception when the user deliberately instructs Avo to allow detaching in this scenario
|
15
|
-
return !@field.allow_via_detaching if @field.target_resource.present? &&
|
15
|
+
return !@field.allow_via_detaching if @field.target_resource.present? && visit_through_association?
|
16
16
|
return !@field.allow_via_detaching if @field.id.to_s == params[:via_relation].to_s
|
17
17
|
|
18
18
|
false
|
@@ -52,4 +52,10 @@ class Avo::Fields::BelongsToField::EditComponent < Avo::Fields::EditComponent
|
|
52
52
|
def field_html_action
|
53
53
|
@field.get_html(:data, view: @resource.view, element: :input).fetch(:action, nil)
|
54
54
|
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def visit_through_association?
|
59
|
+
@field.target_resource.class.to_s == params[:via_resource_class].to_s
|
60
|
+
end
|
55
61
|
end
|
@@ -5,7 +5,7 @@ class Avo::Fields::BelongsToField::ShowComponent < Avo::Fields::ShowComponent
|
|
5
5
|
helpers.resource_view_path(
|
6
6
|
model: @field.value,
|
7
7
|
resource: @field.target_resource,
|
8
|
-
via_resource_class: @resource.
|
8
|
+
via_resource_class: @resource.class.to_s,
|
9
9
|
via_resource_id: @resource.model.id
|
10
10
|
)
|
11
11
|
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<%= index_field_wrapper
|
1
|
+
<%= index_field_wrapper **field_wrapper_args, 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
|
-
<%= index_field_wrapper
|
1
|
+
<%= index_field_wrapper **field_wrapper_args, dash_if_blank: false do %>
|
2
2
|
<%= render Avo::Fields::Common::BooleanGroupComponent.new options: @field.options, value: @field.value %>
|
3
3
|
<% end %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= field_wrapper
|
1
|
+
<%= field_wrapper **field_wrapper_args, 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'),
|
@@ -1,10 +1,11 @@
|
|
1
1
|
<div class="flex items-start py-1 leading-tight bg-gray-100 text-gray-500 text-xs">
|
2
2
|
<div class="py-2 px-6 h-full w-full">
|
3
|
-
<% if
|
4
|
-
|
5
|
-
|
3
|
+
<% if empty %>
|
4
|
+
<% elsif value.present? %>
|
5
|
+
<% if as_html %>
|
6
|
+
<%== value %>
|
6
7
|
<% else %>
|
7
|
-
<div class="font-semibold uppercase"><%=
|
8
|
+
<div class="font-semibold uppercase"><%= value %></div>
|
8
9
|
<% end %>
|
9
10
|
<% else %>
|
10
11
|
—
|
@@ -1,8 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Avo::Fields::Common::HeadingComponent < ViewComponent::Base
|
4
|
-
|
4
|
+
attr_reader :value
|
5
|
+
attr_reader :as_html
|
6
|
+
attr_reader :empty
|
7
|
+
|
8
|
+
def initialize(value:, as_html:, empty:)
|
5
9
|
@value = value
|
6
10
|
@as_html = as_html
|
11
|
+
@empty = empty
|
7
12
|
end
|
8
13
|
end
|
@@ -4,20 +4,22 @@ class Avo::Fields::EditComponent < ViewComponent::Base
|
|
4
4
|
include Avo::ResourcesHelper
|
5
5
|
|
6
6
|
attr_reader :compact
|
7
|
-
attr_reader :displayed_in_modal
|
8
7
|
attr_reader :field
|
9
8
|
attr_reader :form
|
10
9
|
attr_reader :index
|
10
|
+
attr_reader :multiple
|
11
11
|
attr_reader :resource
|
12
|
+
attr_reader :stacked
|
12
13
|
attr_reader :view
|
13
14
|
|
14
|
-
def initialize(field: nil, resource: nil, index: 0, form: nil,
|
15
|
+
def initialize(field: nil, resource: nil, index: 0, form: nil, compact: false, stacked: false, multiple: false, **kwargs)
|
15
16
|
@compact = compact
|
16
|
-
@displayed_in_modal = displayed_in_modal
|
17
17
|
@field = field
|
18
18
|
@form = form
|
19
19
|
@index = index
|
20
|
+
@multiple = multiple
|
20
21
|
@resource = resource
|
22
|
+
@stacked = stacked
|
21
23
|
@view = :edit
|
22
24
|
end
|
23
25
|
|
@@ -32,11 +34,11 @@ class Avo::Fields::EditComponent < ViewComponent::Base
|
|
32
34
|
def field_wrapper_args
|
33
35
|
{
|
34
36
|
compact: compact,
|
35
|
-
displayed_in_modal: displayed_in_modal,
|
36
37
|
field: field,
|
37
38
|
form: form,
|
38
39
|
index: index,
|
39
40
|
resource: resource,
|
41
|
+
stacked: stacked,
|
40
42
|
view: view
|
41
43
|
}
|
42
44
|
end
|
@@ -11,7 +11,8 @@
|
|
11
11
|
data: @field.get_html(:data, view: view, element: :input),
|
12
12
|
direct_upload: @field.direct_upload,
|
13
13
|
disabled: @field.is_readonly?,
|
14
|
-
style: @field.get_html(:style, view: view, element: :input)
|
14
|
+
style: @field.get_html(:style, view: view, element: :input),
|
15
|
+
class: "w-full"
|
15
16
|
%>
|
16
17
|
<% end %>
|
17
18
|
<% end %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= index_field_wrapper
|
1
|
+
<%= index_field_wrapper **field_wrapper_args, 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_view_path, class: 'block' %>
|
@@ -9,7 +9,8 @@
|
|
9
9
|
direct_upload: @field.direct_upload,
|
10
10
|
disabled: @field.is_readonly?,
|
11
11
|
multiple: true,
|
12
|
-
style: @field.get_html(:style, view: view, element: :input)
|
12
|
+
style: @field.get_html(:style, view: view, element: :input),
|
13
|
+
class: "w-full"
|
13
14
|
%>
|
14
15
|
</div>
|
15
16
|
<% end %>
|
@@ -1,3 +1,3 @@
|
|
1
1
|
<div <% if @index == 0 %> class="overflow-hidden rounded-t" <% end %> data-field-id="<%= @field.id %>">
|
2
|
-
<%= render Avo::Fields::Common::HeadingComponent.new value: @field.name, as_html: @field.as_html %>
|
2
|
+
<%= render Avo::Fields::Common::HeadingComponent.new value: @field.name, as_html: @field.as_html, empty: @field.empty %>
|
3
3
|
</div>
|
@@ -1,3 +1,3 @@
|
|
1
1
|
<div <% if @index == 0 %> class="overflow-hidden rounded-t" <% end %> data-field-id="<%= @field.id %>">
|
2
|
-
<%= render Avo::Fields::Common::HeadingComponent.new value: @field.name, as_html: @field.as_html %>
|
2
|
+
<%= render Avo::Fields::Common::HeadingComponent.new value: @field.name, as_html: @field.as_html, empty: @field.empty %>
|
3
3
|
</div>
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<%= index_field_wrapper
|
1
|
+
<%= index_field_wrapper **field_wrapper_args, 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_view_path, title: t('avo.view_item', item: @resource.name).humanize %>
|
3
3
|
<% end %>
|
@@ -3,13 +3,15 @@
|
|
3
3
|
class Avo::Fields::IndexComponent < ViewComponent::Base
|
4
4
|
include Avo::ResourcesHelper
|
5
5
|
|
6
|
+
attr_reader :parent_resource
|
6
7
|
attr_reader :view
|
7
8
|
|
8
|
-
def initialize(field: nil, resource: nil, index: 0, parent_model: nil)
|
9
|
+
def initialize(field: nil, resource: nil, index: 0, parent_model: nil, parent_resource: nil)
|
9
10
|
@field = field
|
10
11
|
@resource = resource
|
11
12
|
@index = index
|
12
13
|
@parent_model = parent_model
|
14
|
+
@parent_resource = parent_resource
|
13
15
|
@view = :index
|
14
16
|
end
|
15
17
|
|
@@ -18,11 +20,18 @@ class Avo::Fields::IndexComponent < ViewComponent::Base
|
|
18
20
|
|
19
21
|
if @parent_model.present?
|
20
22
|
args = {
|
21
|
-
via_resource_class: @
|
23
|
+
via_resource_class: @parent_resource.class,
|
22
24
|
via_resource_id: @parent_model.id
|
23
25
|
}
|
24
26
|
end
|
25
27
|
|
26
28
|
helpers.resource_view_path(model: @resource.model, resource: @resource, **args)
|
27
29
|
end
|
30
|
+
|
31
|
+
def field_wrapper_args
|
32
|
+
{
|
33
|
+
field: @field,
|
34
|
+
resource: @resource
|
35
|
+
}
|
36
|
+
end
|
28
37
|
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<%= index_field_wrapper
|
1
|
+
<%= index_field_wrapper **field_wrapper_args, flush: true do %>
|
2
2
|
<%= render Avo::Fields::Common::ProgressBarComponent.new value: @field.value, display_value: @field.display_value, value_suffix: @field.value_suffix, max: @field.max, view: view %>
|
3
3
|
<% end %>
|
@@ -3,15 +3,19 @@
|
|
3
3
|
class Avo::Fields::ShowComponent < ViewComponent::Base
|
4
4
|
include Avo::ResourcesHelper
|
5
5
|
|
6
|
+
attr_reader :compact
|
6
7
|
attr_reader :field
|
7
8
|
attr_reader :index
|
8
9
|
attr_reader :resource
|
10
|
+
attr_reader :stacked
|
9
11
|
attr_reader :view
|
10
12
|
|
11
|
-
def initialize(field: nil, resource: nil, index: 0, form: nil)
|
13
|
+
def initialize(field: nil, resource: nil, index: 0, form: nil, compact: false, stacked: false)
|
14
|
+
@compact = compact
|
12
15
|
@field = field
|
13
16
|
@index = index
|
14
17
|
@resource = resource
|
18
|
+
@stacked = stacked
|
15
19
|
@view = :show
|
16
20
|
end
|
17
21
|
|
@@ -40,9 +44,11 @@ class Avo::Fields::ShowComponent < ViewComponent::Base
|
|
40
44
|
|
41
45
|
def field_wrapper_args
|
42
46
|
{
|
47
|
+
compact: compact,
|
43
48
|
field: field,
|
44
49
|
index: index,
|
45
50
|
resource: resource,
|
51
|
+
stacked: stacked,
|
46
52
|
view: view
|
47
53
|
}
|
48
54
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= index_field_wrapper
|
1
|
+
<%= index_field_wrapper **field_wrapper_args, 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)) %>
|
@@ -4,6 +4,8 @@
|
|
4
4
|
data: @field.get_html(:data, view: view, element: :input),
|
5
5
|
disabled: @field.is_readonly?,
|
6
6
|
placeholder: @field.placeholder,
|
7
|
-
style: @field.get_html(:style, view: view, element: :input)
|
7
|
+
style: @field.get_html(:style, view: view, element: :input),
|
8
|
+
# value: @field.value,
|
9
|
+
multiple: multiple
|
8
10
|
%>
|
9
11
|
<% end %>
|