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 +4 -4
- data/Gemfile.lock +1 -1
- data/app/assets/javascripts/cm_admin/application.js +1 -0
- data/app/assets/javascripts/cm_admin/cocoon.js +1 -0
- data/app/assets/javascripts/cm_admin/scaffolds.js +9 -13
- data/app/controllers/cm_admin/resource_controller.rb +1 -1
- data/app/views/cm_admin/main/import_form.html.slim +2 -2
- data/lib/cm_admin/model.rb +2 -2
- data/lib/cm_admin/models/importer.rb +3 -2
- data/lib/cm_admin/version.rb +1 -1
- data/lib/cm_admin/view_helpers/field_display_helper.rb +2 -0
- data/lib/cm_admin/view_helpers/form_field_helper.rb +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85496e0fb2a6c7fdafd600df87f9696a93602e4373a7ab58134e74de2b8ac0fd
|
4
|
+
data.tar.gz: 76a47ad8ff3e0f84850377bb7ed4edac39641bfc1989f603fffa554905e21721
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38a6525246bcfe77af5e15e7a54bc855fde8429547019a4171ae45a67a5fec87b17d4a8cdda7131d7d7be3643cb47ca9fb0e2822fe23bf4a61ec8f47538f8c42
|
7
|
+
data.tar.gz: 1c7801e19d0eb171e0e0cda085b3bc129c0e27d700e85438e1a2d5e06a83f1e7f2a67a00e69b849a518e40e5a76e307a535cb1e22370e7a3c01f51b5c09ffa48
|
data/Gemfile.lock
CHANGED
@@ -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
|
-
|
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('
|
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
|
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'
|
data/lib/cm_admin/model.rb
CHANGED
@@ -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
|
data/lib/cm_admin/version.rb
CHANGED
@@ -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,
|
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
|
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.
|
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-
|
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
|