cm-admin 1.0.7 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cafa2525f536777ecf8b3307495183e0d9fcf943437221d855a9896428b848f9
4
- data.tar.gz: 61ac21f29c6ba46c46306e556418ee1982a72a07ced8870795b4d462fff24e70
3
+ metadata.gz: 2fa1190d6f07315dbcefb3d73dec3c4bf707ebe525f9f7e5e0286e741c4d27c7
4
+ data.tar.gz: c0f55a1fec64fc363ee790b88ece877aed4145d1711dacf7032ac6155e71aba5
5
5
  SHA512:
6
- metadata.gz: f9963bef79936d74e35d893ab29dd472cd5d7eb562855bf766ea77b259e35cd5e2a0800911db1035ea1265c628bc25beaebc8f4f1bb3ebf8c5ba55c5277c8b04
7
- data.tar.gz: 0c40a31d97908fdb9b440d337525fd9e13f594b1a4860eacbb7898d0e3a1ebd752e5559c72d0dc00c961e4f21c54743a8067628719cdc9fd456945ef2954924b
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.7)
4
+ cm-admin (1.0.8)
5
5
  caxlsx_rails
6
6
  cocoon (~> 1.2.15)
7
7
  csv-importer (~> 0.8.2)
@@ -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.7'
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.7
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-23 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