cm-admin 1.1.0 → 1.1.2

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: a9d5d1694d9470dd58f68fc032596d9c30205c0d5afec2776f8c5c4ea6d10ba7
4
- data.tar.gz: 91de086adf1f05d4dcc10d257ee26f00913e487b887ab7321d1af00db700d6e9
3
+ metadata.gz: 6ca2b1b912d7ae2bc0925180a861cba806874e54baa273c2176af245e68940c0
4
+ data.tar.gz: d56e8c3155712a502cab04a22aa209877988cc85593d56008155e0daf7d4778b
5
5
  SHA512:
6
- metadata.gz: 3df8b75e1d1afdcabe543e27cfaac0fd6bef428b9443a4154fdfb6653b5ac44acc491c3003d78d7ddcc0e2dd30616e97f532774c84d96cc6b94780ef5613322b
7
- data.tar.gz: 5dd8fa05c669399326c6b1d0b3f2650891273f4cd70179ff2bdc69ec1a65483cc3191ac924bf5fe73f7fabce35bfa5cce3e2f05c72b7e441da831405b12705c0
6
+ metadata.gz: d71ce2f05820e692c76d40db3fee7f646066a3bff0c1341b2ef78dae62339f6d750bfacc38d4a8d4676ce73b5bb502469487c93a9a32246281d3bdfa14eb2933
7
+ data.tar.gz: 564ddd3e0842b3ce7505e41f4f34a26a55bb3428aac6e7c9960af3bf34cb2c17877f4c251c0c3f6f54981d19a2f33fc87b2a761d6782f55a4a9d231e9ae044b6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cm-admin (1.1.0)
4
+ cm-admin (1.1.2)
5
5
  caxlsx_rails
6
6
  cocoon (~> 1.2.15)
7
7
  csv-importer (~> 0.8.2)
@@ -87,7 +87,7 @@ GEM
87
87
  ice_nine (~> 0.11.0)
88
88
  thread_safe (~> 0.3, >= 0.3.1)
89
89
  builder (3.2.4)
90
- caxlsx (3.4.0)
90
+ caxlsx (3.4.1)
91
91
  htmlentities (~> 4.3, >= 4.3.4)
92
92
  marcel (~> 1.0)
93
93
  nokogiri (~> 1.10, >= 1.10.4)
@@ -113,7 +113,7 @@ GEM
113
113
  i18n (1.11.0)
114
114
  concurrent-ruby (~> 1.0)
115
115
  ice_nine (0.11.2)
116
- importmap-rails (1.1.6)
116
+ importmap-rails (1.2.1)
117
117
  actionpack (>= 6.0.0)
118
118
  railties (>= 6.0.0)
119
119
  json (2.6.2)
@@ -130,7 +130,7 @@ GEM
130
130
  method_source (1.0.0)
131
131
  mini_mime (1.1.2)
132
132
  minitest (5.16.2)
133
- net-imap (0.3.4)
133
+ net-imap (0.3.6)
134
134
  date
135
135
  net-protocol
136
136
  net-pop (0.1.2)
@@ -140,7 +140,7 @@ GEM
140
140
  net-smtp (0.3.3)
141
141
  net-protocol
142
142
  nio4r (2.5.9)
143
- nokogiri (1.15.0-arm64-darwin)
143
+ nokogiri (1.15.2-arm64-darwin)
144
144
  racc (~> 1.4)
145
145
  pagy (4.11.0)
146
146
  parallel (1.22.1)
@@ -148,7 +148,7 @@ GEM
148
148
  ast (~> 2.4.1)
149
149
  pundit (2.2.0)
150
150
  activesupport (>= 3.0.0)
151
- racc (1.6.2)
151
+ racc (1.7.1)
152
152
  rack (2.2.6.4)
153
153
  rack-proxy (0.7.6)
154
154
  rack
@@ -168,11 +168,13 @@ GEM
168
168
  activesupport (= 7.0.3.1)
169
169
  bundler (>= 1.15.0)
170
170
  railties (= 7.0.3.1)
171
- rails-dom-testing (2.0.3)
172
- activesupport (>= 4.2.0)
171
+ rails-dom-testing (2.1.1)
172
+ activesupport (>= 5.0.0)
173
+ minitest
173
174
  nokogiri (>= 1.6)
174
- rails-html-sanitizer (1.5.0)
175
- loofah (~> 2.19, >= 2.19.1)
175
+ rails-html-sanitizer (1.6.0)
176
+ loofah (~> 2.21)
177
+ nokogiri (~> 1.14)
176
178
  railties (7.0.3.1)
177
179
  actionpack (= 7.0.3.1)
178
180
  activesupport (= 7.0.3.1)
@@ -226,7 +228,7 @@ GEM
226
228
  thor (1.2.2)
227
229
  thread_safe (0.3.6)
228
230
  tilt (2.0.10)
229
- timeout (0.3.2)
231
+ timeout (0.4.0)
230
232
  tzinfo (2.0.4)
231
233
  concurrent-ruby (~> 1.0)
232
234
  unicode-display_width (2.3.0)
@@ -237,10 +237,11 @@ module CmAdmin
237
237
  }.compact
238
238
  nested_tables = @model.available_fields[:new].map(&:nested_table_fields).map(&:keys).flatten
239
239
  nested_tables += @model.available_fields[:edit].map(&:nested_table_fields).map(&:keys).flatten
240
- nested_fields = nested_tables.uniq.map {|table|
240
+ nested_fields = nested_tables.uniq.map {|assoc_name|
241
+ table_name = @ar_object._reflections[assoc_name.to_s].klass.table_name
241
242
  Hash[
242
- table.to_s + '_attributes',
243
- table.to_s.classify.constantize.column_names.reject { |i| CmAdmin::REJECTABLE_FIELDS.include?(i) }.map(&:to_sym) + [:id, :_destroy]
243
+ table_name.to_s + '_attributes',
244
+ table_name.to_s.classify.constantize.column_names.reject { |i| CmAdmin::REJECTABLE_FIELDS.include?(i) }.map(&:to_sym) + [:id, :_destroy]
244
245
  ]
245
246
  }
246
247
  permittable_fields += nested_fields
@@ -1,9 +1,10 @@
1
- .nested-field-wrapper data-table-name=table_name data-model-name=table_name.to_s.classify
2
- label.nested-field-label = table_name.to_s.titleize
1
+ - table_name = @ar_object._reflections[assoc_name.to_s].klass.table_name.to_sym
2
+ .nested-field-wrapper data-table-name=assoc_name data-model-name=assoc_name.to_s.classify
3
+ label.nested-field-label = assoc_name.to_s.titleize
3
4
  .accordion.nested-form-accordion
4
5
  = f.fields_for table_name do |record|
5
6
  - if record.object.persisted?
6
- = render partial: '/cm_admin/main/nested_fields', locals: { f: record, assoc_name: table_name, section: section }
7
- - if @reflections.select {|x| x if x.name == table_name}.first.macro == :has_many
7
+ = render partial: '/cm_admin/main/nested_fields', locals: { f: record, assoc_name: assoc_name, section: section }
8
+ - if @reflections.select {|x| x if x.name == assoc_name}.first.macro == :has_many
8
9
  .links
9
- = link_to_add_association "+ Add #{table_name.to_s.titleize}", f, table_name, partial: '/cm_admin/main/nested_fields', render_options: {locals: { assoc_name: table_name, section: section }}, class: 'd-inline-block secondary-btn mt-2'
10
+ = link_to_add_association "+ Add #{assoc_name.to_s.titleize}", f, table_name, partial: '/cm_admin/main/nested_fields', render_options: {locals: { assoc_name: assoc_name, section: section }}, class: 'd-inline-block secondary-btn mt-2'
@@ -16,8 +16,8 @@
16
16
  .sidebar__footer
17
17
  .menu-item
18
18
  .profile-name
19
- span.profile-avatar J
20
- | #{user_full_name}
19
+ span.profile-avatar #{user_full_name.first.titleize}
20
+ | #{user_full_name.titleize}
21
21
  .profile-popup.hidden
22
22
  .profile-info
23
23
  .profile-info__left
@@ -1,3 +1,3 @@
1
1
  module CmAdmin
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.2'
3
3
  end
@@ -77,7 +77,17 @@ module CmAdmin
77
77
  when :image
78
78
  content_tag(:div, class: 'd-flex') do
79
79
  if ar_object.send(field.field_name).attached?
80
- image_tag(ar_object.send(field.field_name).url, height: field.height, width: field.height)
80
+ if has_one_image_attached?(ar_object, field)
81
+ content_tag :a, href: rails_blob_path(ar_object.send(field.field_name)), target: '_blank' do
82
+ image_tag(ar_object.send(field.field_name).url, height: field.height, width: field.width, class: 'rounded')
83
+ end
84
+ elsif has_many_image_attached?(ar_object, field)
85
+ ar_object.send(field.field_name).map do |asset|
86
+ content_tag :a, href: rails_blob_path(asset), target: '_blank' do
87
+ image_tag(asset.url, height: field.height, width: field.width, class: 'rounded mr-1')
88
+ end
89
+ end.join("\n").html_safe
90
+ end
81
91
  else
82
92
  image_tag('https://cm-admin.s3.ap-south-1.amazonaws.com/gem_static_assets/image_not_available.png', height: 50, width: 50)
83
93
  end
@@ -95,11 +105,11 @@ module CmAdmin
95
105
 
96
106
  def show_attachment_value(ar_object, field)
97
107
  if ar_object.send(field.field_name).attached?
98
- if ar_object.send(field.field_name).class.name.include?('One')
108
+ if has_one_image_attached?(ar_object, field)
99
109
  content_tag :a, href: rails_blob_path(ar_object.send(field.field_name), disposition: "attachment") do
100
110
  ar_object.send(field.field_name).filename.to_s
101
111
  end
102
- elsif ar_object.send(field.field_name).class.name.include?('Many')
112
+ elsif has_many_image_attached?(ar_object, field)
103
113
  ar_object.send(field.field_name).map do |asset|
104
114
  content_tag :a, href: rails_blob_path(asset, disposition: "attachment") do
105
115
  asset.filename.to_s
@@ -114,6 +124,15 @@ module CmAdmin
114
124
  return hash[association_name.to_sym] if hash.has_key?(association_name.to_sym)
115
125
  end
116
126
  end
127
+
128
+ def has_one_image_attached?(ar_object, field)
129
+ ar_object.send(field.field_name).class.name.include?('One')
130
+ end
131
+
132
+ def has_many_image_attached?(ar_object, field)
133
+ ar_object.send(field.field_name).class.name.include?('Many')
134
+ end
135
+
117
136
  end
118
137
  end
119
138
  end
@@ -76,7 +76,7 @@ module CmAdmin
76
76
  def set_nested_form_fields(form_obj, section)
77
77
  content_tag(:div) do
78
78
  section.nested_table_fields.keys.each do |key|
79
- concat(render partial: '/cm_admin/main/nested_table_form', locals: {f: form_obj, table_name: key, section: section})
79
+ concat(render partial: '/cm_admin/main/nested_table_form', locals: {f: form_obj, assoc_name: key, section: section})
80
80
  end
81
81
  end
82
82
  end
@@ -14,7 +14,7 @@ module CmAdmin
14
14
  content_tag(:span, class: 'menu-icon') do
15
15
  concat tag.i class: "#{model.icon_name}"
16
16
  end +
17
- model.name.pluralize
17
+ model.name.underscore.titleize.pluralize
18
18
  end
19
19
  end
20
20
  elsif navigation_type == "quick_links"