cm-admin 1.0.7 → 1.0.9

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: cafa2525f536777ecf8b3307495183e0d9fcf943437221d855a9896428b848f9
4
- data.tar.gz: 61ac21f29c6ba46c46306e556418ee1982a72a07ced8870795b4d462fff24e70
3
+ metadata.gz: 85496e0fb2a6c7fdafd600df87f9696a93602e4373a7ab58134e74de2b8ac0fd
4
+ data.tar.gz: 76a47ad8ff3e0f84850377bb7ed4edac39641bfc1989f603fffa554905e21721
5
5
  SHA512:
6
- metadata.gz: f9963bef79936d74e35d893ab29dd472cd5d7eb562855bf766ea77b259e35cd5e2a0800911db1035ea1265c628bc25beaebc8f4f1bb3ebf8c5ba55c5277c8b04
7
- data.tar.gz: 0c40a31d97908fdb9b440d337525fd9e13f594b1a4860eacbb7898d0e3a1ebd752e5559c72d0dc00c961e4f21c54743a8067628719cdc9fd456945ef2954924b
6
+ metadata.gz: 38a6525246bcfe77af5e15e7a54bc855fde8429547019a4171ae45a67a5fec87b17d4a8cdda7131d7d7be3643cb47ca9fb0e2822fe23bf4a61ec8f47538f8c42
7
+ data.tar.gz: 1c7801e19d0eb171e0e0cda085b3bc129c0e27d700e85438e1a2d5e06a83f1e7f2a67a00e69b849a518e40e5a76e307a535cb1e22370e7a3c01f51b5c09ffa48
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.9)
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'
@@ -26,22 +26,18 @@ import '@fortawesome/fontawesome-free'
26
26
  import jqueryJgrowl from 'jgrowl';
27
27
 
28
28
 
29
- flatpickr("[data-behaviour='date-only']", {
30
- dateFormat: "d-m-Y"
31
- })
32
- flatpickr("[data-behaviour='date-time']", {
33
- enableTime: true
34
- })
35
- flatpickr("[data-behaviour='filter'][data-filter-type='date']", {
36
- mode: 'range'
37
- })
38
- $('.select-2').select2();
39
- $(document).on('turbolinks:load', function () {
40
- $('.select-2').select2();
29
+ document.addEventListener("turbo:load", function () {
41
30
  flatpickr("[data-behaviour='date-only']", {
42
31
  dateFormat: "d-m-Y"
43
32
  })
44
- })
33
+ flatpickr("[data-behaviour='date-time']", {
34
+ enableTime: true
35
+ })
36
+ flatpickr("[data-behaviour='filter'][data-filter-type='date']", {
37
+ mode: 'range'
38
+ })
39
+ $('.select-2').select2();
40
+ });
45
41
 
46
42
  $(document).on('click', '.menu-item', function(e) {
47
43
  $('.profile-popup').toggleClass('hidden');
@@ -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.9'
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.9
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-06-06 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