cm-admin 1.5.29 → 1.5.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8633d5b2705caba1ed7329b20ac6bfad6e4ef045ded72027768fc615eca2aefe
4
- data.tar.gz: 6c825574261c4552a5c94e9c9a3260267717c6521a974202abc832f1b3c893ef
3
+ metadata.gz: e7b3d959b5e4c28d831b165dc391c42953beb42f87a9c078c97bb42f3dec2a64
4
+ data.tar.gz: a08df5bdd7d91feee259f8f18e1a198fdb3022192c4684e121cfccd2f36b1a6e
5
5
  SHA512:
6
- metadata.gz: db5ace7e6cb92376805d4d51cc6ce3cf15228b3756efaa2983e74be73b4d2a8861c30559adb58be2bc0d95c4208d920e4433386b4d604ec7149335f820bd0abd
7
- data.tar.gz: 8767d826ba1d1d3b5f9950c5dfcbc4582a7a730b234c04c2aef5f956ca52807c0498373d1ffca23e9afc7a7175cae28249e93946cbc98e7c7772c4aa948fc6c8
6
+ metadata.gz: 98265ae7f832c8d132853a45f0c7263398530a43b485151695d6a7b8350da8221f0e584938dfd154367f815dad55071b922cdb826649be140f79aa14169765e8
7
+ data.tar.gz: e9ef61ff233874c87a88a2d3a8ea677d9c7ace389e9375dc2beb688cdc95db3ba9acfce27c24350bcabd8aa5f10474e8fb62c68c51d125ba914919baa683874b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cm-admin (1.5.29)
4
+ cm-admin (1.5.30)
5
5
  caxlsx_rails
6
6
  cocoon (~> 1.2.15)
7
7
  csv-importer (~> 0.8.2)
@@ -39,7 +39,7 @@ module CmAdmin
39
39
  else
40
40
  format.html { render '/cm_admin/main/' + action_name }
41
41
  end
42
- format.json { render json: @ar_object }
42
+ format.json { render json: @ar_object.to_builder.target! }
43
43
  end
44
44
  end
45
45
 
@@ -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?
@@ -1,3 +1,3 @@
1
1
  module CmAdmin
2
- VERSION = '1.5.29'
2
+ VERSION = '1.5.30'
3
3
  end
@@ -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 ar_object.send(field.field_name).attached?
103
+ if attachment.attached?
103
104
  if has_one_image_attached?(ar_object, field)
104
- content_tag :a, href: rails_blob_path(ar_object.send(field.field_name)), target: '_blank' do
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
- ar_object.send(field.field_name).map do |asset|
109
- content_tag :a, href: rails_blob_path(asset), target: '_blank' do
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: rails_blob_path(ar_object.send(field.field_name), disposition: "attachment") do
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: rails_blob_path(asset, disposition: "attachment") do
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, _target_action)
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
  {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cm-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.29
4
+ version: 1.5.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - sajinmp