cm-admin 1.5.29 → 1.5.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/controllers/cm_admin/resource_controller.rb +1 -1
- data/app/views/cm_admin/main/_nested_table_form.html.slim +1 -1
- data/lib/cm_admin/version.rb +1 -1
- data/lib/cm_admin/view_helpers/field_display_helper.rb +17 -10
- data/lib/cm_admin/view_helpers/form_field_helper.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7b3d959b5e4c28d831b165dc391c42953beb42f87a9c078c97bb42f3dec2a64
|
4
|
+
data.tar.gz: a08df5bdd7d91feee259f8f18e1a198fdb3022192c4684e121cfccd2f36b1a6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98265ae7f832c8d132853a45f0c7263398530a43b485151695d6a7b8350da8221f0e584938dfd154367f815dad55071b922cdb826649be140f79aa14169765e8
|
7
|
+
data.tar.gz: e9ef61ff233874c87a88a2d3a8ea677d9c7ace389e9375dc2beb688cdc95db3ba9acfce27c24350bcabd8aa5f10474e8fb62c68c51d125ba914919baa683874b
|
data/Gemfile.lock
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
|
|
13
13
|
- nested_table_field.fields.each do |field|
|
14
14
|
th data-field-type="#{field.input_type}"
|
15
|
-
= field.field_name.to_s.titleize
|
15
|
+
= field.label.to_s.titleize || field.field_name.to_s.titleize
|
16
16
|
tbody class="insert-cocoon-position-#{uniq_no}"
|
17
17
|
= f.fields_for table_name do |record|
|
18
18
|
- if record.object.persisted? || @ar_object.errors.present?
|
data/lib/cm_admin/version.rb
CHANGED
@@ -98,17 +98,14 @@ module CmAdmin
|
|
98
98
|
concat content_tag(:div, 'View', class: 'drawer-btn')
|
99
99
|
end
|
100
100
|
when :image
|
101
|
+
attachment = ar_object.send(field.field_name)
|
101
102
|
content_tag(:div, class: 'd-flex') do
|
102
|
-
if
|
103
|
+
if attachment.attached?
|
103
104
|
if has_one_image_attached?(ar_object, field)
|
104
|
-
|
105
|
-
image_tag(ar_object.send(field.field_name).url, height: field.height, width: field.width, class: 'rounded')
|
106
|
-
end
|
105
|
+
attachment_with_preview(attachment, field)
|
107
106
|
elsif has_many_image_attached?(ar_object, field)
|
108
|
-
|
109
|
-
|
110
|
-
image_tag(asset.url, height: field.height, width: field.width, class: 'rounded mr-1')
|
111
|
-
end
|
107
|
+
attachment.map do |asset|
|
108
|
+
attachment_with_preview(asset, field, 'mr-1')
|
112
109
|
end.join("\n").html_safe
|
113
110
|
end
|
114
111
|
else
|
@@ -126,16 +123,26 @@ module CmAdmin
|
|
126
123
|
end
|
127
124
|
end
|
128
125
|
|
126
|
+
def attachment_with_preview(attachment, field, custom_class = nil)
|
127
|
+
content_tag :a, href: attachment.url, target: '_blank' do
|
128
|
+
if attachment.content_type.include?('image')
|
129
|
+
image_tag(attachment.url, height: field.height, width: field.width, class: "rounded #{custom_class}")
|
130
|
+
else
|
131
|
+
image_tag('https://cm-admin.s3.ap-south-1.amazonaws.com/gem_static_assets/image_not_available.png', height: 50, width: 50, class: "rounded #{custom_class}")
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
129
136
|
def show_attachment_value(ar_object, field)
|
130
137
|
if ar_object.send(field.field_name).attached?
|
131
138
|
if has_one_image_attached?(ar_object, field)
|
132
|
-
content_tag :a, href:
|
139
|
+
content_tag :a, href: ar_object.send(field.field_name).url do
|
133
140
|
ar_object.send(field.field_name).filename.to_s
|
134
141
|
end
|
135
142
|
elsif has_many_image_attached?(ar_object, field)
|
136
143
|
ar_object.send(field.field_name).map do |asset|
|
137
144
|
content_tag(:div) do
|
138
|
-
content_tag :a, href:
|
145
|
+
content_tag :a, href: asset.url do
|
139
146
|
asset.filename.to_s
|
140
147
|
end
|
141
148
|
end
|
@@ -51,7 +51,7 @@ module CmAdmin
|
|
51
51
|
}, cm_field.html_attrs )
|
52
52
|
end
|
53
53
|
|
54
|
-
def cm_custom_string_field(form_obj, cm_field, value, required_class,
|
54
|
+
def cm_custom_string_field(form_obj, cm_field, value, required_class, _target_action_ajax_url)
|
55
55
|
text_field_tag cm_field.html_attrs[:name] || cm_field.field_name,
|
56
56
|
merge_wrapper_options(
|
57
57
|
{
|