cm-admin 1.0.6 → 1.0.8

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: 86d033fefa5d556af30d7127b65993513423c82a5358774eba875ab17d8946a1
4
- data.tar.gz: 466f4769e70f2d6133873d5931cb4d6fbf826629b8ad3b837ff06b5fe36c49ca
3
+ metadata.gz: 2fa1190d6f07315dbcefb3d73dec3c4bf707ebe525f9f7e5e0286e741c4d27c7
4
+ data.tar.gz: c0f55a1fec64fc363ee790b88ece877aed4145d1711dacf7032ac6155e71aba5
5
5
  SHA512:
6
- metadata.gz: 5d5f05bc6a9a5e02226c95e8a487210b391272e4d8bf871327fbc013359f9f4e25e50d0bb68b57c08607573e57fb92e142282f0176bb3e7ad5473047904f97c7
7
- data.tar.gz: 0b6f062d86781a11903361f97bd2d3de607d500ff675b0ce1acebfbdb0548cd4842033d54066ba058aacd7f57ec6570383570ae5f6a7d1eb8e263884f0e6d535
6
+ metadata.gz: 67c6cd0cbb94ae18ce9c51f9764bed6100ae69c0d7522524dc8bcbd36987a02463bbd9e9ca9c901371e37e6665235bfb97a5a18789047ca83315e6c5bff9eb83
7
+ data.tar.gz: 68bcd00f9814c034736c518357bfe1abe10f0a1f7f0ce7a5084f69e4608359f26c93b439405d6ed75bee023b69e8ece738a8d23d2177509f474118d33520391e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cm-admin (1.0.6)
4
+ cm-admin (1.0.8)
5
5
  caxlsx_rails
6
6
  cocoon (~> 1.2.15)
7
7
  csv-importer (~> 0.8.2)
@@ -113,14 +113,14 @@ 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.5)
116
+ importmap-rails (1.1.6)
117
117
  actionpack (>= 6.0.0)
118
118
  railties (>= 6.0.0)
119
119
  json (2.6.2)
120
120
  local_time (2.1.0)
121
- loofah (2.20.0)
121
+ loofah (2.21.3)
122
122
  crass (~> 1.0.2)
123
- nokogiri (>= 1.5.9)
123
+ nokogiri (>= 1.12.0)
124
124
  mail (2.8.1)
125
125
  mini_mime (>= 0.1.1)
126
126
  net-imap
@@ -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.14.3-arm64-darwin)
143
+ nokogiri (1.15.0-arm64-darwin)
144
144
  racc (~> 1.4)
145
145
  pagy (4.11.0)
146
146
  parallel (1.22.1)
@@ -223,7 +223,7 @@ GEM
223
223
  temple (>= 0.7.6, < 0.9)
224
224
  tilt (>= 2.0.6, < 2.1)
225
225
  temple (0.8.2)
226
- thor (1.2.1)
226
+ thor (1.2.2)
227
227
  thread_safe (0.3.6)
228
228
  tilt (2.0.10)
229
229
  timeout (0.3.2)
@@ -242,7 +242,7 @@ GEM
242
242
  websocket-driver (0.7.5)
243
243
  websocket-extensions (>= 0.1.0)
244
244
  websocket-extensions (0.1.5)
245
- zeitwerk (2.6.7)
245
+ zeitwerk (2.6.8)
246
246
 
247
247
  PLATFORMS
248
248
  arm64-darwin-20
@@ -1,4 +1,5 @@
1
1
  import './scaffolds.js';
2
+ import './cocoon.js'
2
3
  import './shared_scaffolds.js';
3
4
  import './form_validation.js'
4
5
  import './quick_search.js'
@@ -0,0 +1 @@
1
+ import '@nathanvda/cocoon'
@@ -232,7 +232,7 @@ module CmAdmin
232
232
  if x.class.name.include?('HasOne')
233
233
  x.name.to_s.gsub('_attachment', '').gsub('rich_text_', '').to_sym
234
234
  elsif x.class.name.include?('HasMany')
235
- Hash[x.name.to_s.gsub('_attachment', ''), []]
235
+ Hash[x.name.to_s.gsub('_attachments', ''), []]
236
236
  end
237
237
  }.compact
238
238
  nested_tables = @model.available_fields[:new].map(&:nested_table_fields).map(&:keys).flatten
@@ -28,8 +28,8 @@
28
28
  ul.steps-list
29
29
  li
30
30
  | Download this
31
- a href="#" template file
31
+ a href="#{@model.importer.sample_file_path}" template file
32
32
  li Add your data on the file without changing the format
33
- li Save the file as a csv, xls or xlsx
33
+ li Save the file as a csv
34
34
  li Upload the file in the field above
35
35
  = f.button :submit, class: "cta-btn import-btn", value: 'Import data'
@@ -83,8 +83,8 @@ module CmAdmin
83
83
  @actions_set = true
84
84
  end
85
85
 
86
- def importable(class_name:, importer_type:)
87
- @importer = CmAdmin::Models::Importer.new(class_name, importer_type)
86
+ def importable(class_name:, importer_type:, sample_file_path: nil)
87
+ @importer = CmAdmin::Models::Importer.new(class_name, importer_type, sample_file_path)
88
88
  end
89
89
 
90
90
  def visible_on_sidebar(visible_option)
@@ -2,14 +2,15 @@ module CmAdmin
2
2
  module Models
3
3
  class Importer
4
4
 
5
- attr_accessor :class_name, :importer_type
5
+ attr_accessor :class_name, :importer_type, :sample_file_path
6
6
 
7
7
  VALID_IMPORTER_TYPES = [:csv_importer, :custom_importer]
8
8
 
9
- def initialize(class_name, importer_type=:csv_importer)
9
+ def initialize(class_name, importer_type=:csv_importer, sample_file_path=nil)
10
10
  raise ArgumentError, "Kindly select a valid importer type like #{VALID_IMPORTER_TYPES.sort.to_sentence(last_word_connector: ', or ')} instead of #{importer_type}" unless VALID_IMPORTER_TYPES.include?(importer_type.to_sym)
11
11
  @class_name = class_name
12
12
  @importer_type = importer_type
13
+ @sample_file_path = sample_file_path
13
14
  end
14
15
 
15
16
  end
@@ -1,3 +1,3 @@
1
1
  module CmAdmin
2
- VERSION = '1.0.6'
2
+ VERSION = '1.0.8'
3
3
  end
@@ -43,6 +43,8 @@ module CmAdmin
43
43
  self.extend LocalTimeHelper
44
44
  local_time(ar_object.send(field.field_name).strftime(field.format || "%d/%m/%Y").to_s) if ar_object.send(field.field_name)
45
45
  when :date
46
+ return unless ar_object.send(field.field_name)
47
+
46
48
  self.extend LocalTimeHelper
47
49
  local_date(ar_object.send(field.field_name), (field.format || '%B %e, %Y'))
48
50
  when :text
@@ -88,11 +88,11 @@ module CmAdmin
88
88
  placeholder: "Enter #{cm_field.field_name.to_s.downcase.gsub('_', ' ')}"
89
89
  end
90
90
 
91
- def cm_single_file_upload_field(form_obj, cm_field, value, required_class, _target_action)
91
+ def cm_single_file_upload_field(form_obj, cm_field, _value, required_class, _target_action)
92
92
  form_obj.file_field cm_field.field_name, class: "normal-input #{required_class}"
93
93
  end
94
94
 
95
- def cm_single_multi_upload_field(form_obj, cm_field, value, required_class, _target_action)
95
+ def cm_multi_file_upload_field(form_obj, cm_field, _value, required_class, _target_action)
96
96
  form_obj.file_field cm_field.field_name, multiple: true, class: "normal-input #{required_class}"
97
97
  end
98
98
 
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.0.6
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - sajinmp
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2023-05-03 00:00:00.000000000 Z
13
+ date: 2023-05-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -179,6 +179,7 @@ files:
179
179
  - app/assets/images/image_not_available.png
180
180
  - app/assets/images/logo.png
181
181
  - app/assets/javascripts/cm_admin/application.js
182
+ - app/assets/javascripts/cm_admin/cocoon.js
182
183
  - app/assets/javascripts/cm_admin/exports.js
183
184
  - app/assets/javascripts/cm_admin/filters.js
184
185
  - app/assets/javascripts/cm_admin/form_validation.js