cm-admin 1.5.47 → 1.5.48
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/.github/CODEOWNERS +1 -0
- data/Gemfile.lock +1 -1
- data/app/assets/javascripts/cm_admin/form_validation.js +5 -2
- data/app/views/layouts/cm_admin.html.slim +20 -1
- data/lib/cm_admin/configuration.rb +5 -4
- data/lib/cm_admin/models/utils/helpers.rb +1 -1
- data/lib/cm_admin/version.rb +1 -1
- data/lib/cm_admin/view_helpers/form_field_helper.rb +5 -4
- data/lib/cm_admin/view_helpers.rb +16 -3
- data/lib/cm_admin.rb +6 -9
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15551855652f4c5ac77f380e97f4ffee2641505f1daf273d47eae69c571322d1
|
4
|
+
data.tar.gz: bc0face163e5ace8d25df0c19c093673d7bf28d1f36b8bd607d717e7143634b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ed4fb721ecc53c56b6a808817a9873fe4f4fa11d2b1d24c56f4514775b24ef5fc79cbdf6f0d90f9c0b78e20af154d2712eaf4e5d93c84a7ef0efe2fe292e6ad
|
7
|
+
data.tar.gz: 22a7d944b8fb5a351a519a0df3bbfb1d48b7d220df715cd017345acee909c638020bee23b28fe044528492431b4c81673b1617332498de262335dcadab833a9a
|
data/.github/CODEOWNERS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* @Mahaveer1141 @anbublacky @mikevic
|
data/Gemfile.lock
CHANGED
@@ -5,9 +5,12 @@ $(document).on("click", '[data-behaviour="form_submit"]', function (e) {
|
|
5
5
|
$(
|
6
6
|
"." + form_class + " input.required, ." + form_class + " textarea.required",
|
7
7
|
).each(function () {
|
8
|
-
if($(this).attr('type') === 'file') return;
|
9
8
|
$(this).removeClass("is-invalid");
|
10
|
-
|
9
|
+
let isValueNull = $(this).val().trim().length === 0
|
10
|
+
if(isValueNull && $(this).attr('type') === 'file') {
|
11
|
+
isValueNull = $(`[data-attachment-name="${$(this).attr('id')}_attachments"]`).not('.hidden').length === 0
|
12
|
+
}
|
13
|
+
if (isValueNull) {
|
11
14
|
$(this).addClass("is-invalid");
|
12
15
|
$(this)[0].scrollIntoView(true);
|
13
16
|
submit.push(true);
|
@@ -1,8 +1,22 @@
|
|
1
1
|
doctype html
|
2
2
|
html
|
3
3
|
head
|
4
|
+
- if CmAdmin.config.enable_tracking
|
5
|
+
/ Google Tag Manager
|
6
|
+
script
|
7
|
+
| (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
|
8
|
+
| new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
|
9
|
+
| j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
10
|
+
| 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
11
|
+
| })(window,document,'script','dataLayer','GTM-N6898ZX9');
|
12
|
+
/ End Google Tag Manager
|
13
|
+
script
|
14
|
+
| window.dataLayer = window.dataLayer || [];
|
15
|
+
| dataLayer.push({
|
16
|
+
| 'projectName': "#{project_name_with_env}"
|
17
|
+
| });
|
4
18
|
title
|
5
|
-
|
19
|
+
= project_name_with_env
|
6
20
|
meta[name="viewport" content="width=device-width,initial-scale=1"]
|
7
21
|
= csrf_meta_tags
|
8
22
|
= csp_meta_tag
|
@@ -24,6 +38,11 @@ html
|
|
24
38
|
link[rel="stylesheet" href="https://cdn.jsdelivr.net/npm/select2-bootstrap-5-theme@1.3.0/dist/select2-bootstrap-5-theme.rtl.min.css"]
|
25
39
|
|
26
40
|
body
|
41
|
+
- if CmAdmin.config.enable_tracking
|
42
|
+
/ Google Tag Manager (noscript)
|
43
|
+
noscript
|
44
|
+
iframe src="https://www.googletagmanager.com/ns.html?id=GTM-N6898ZX9" height="0" width="0" style="display:none;visibility:hidden"
|
45
|
+
/ End Google Tag Manager (noscript)
|
27
46
|
.cm-admin
|
28
47
|
= render 'layouts/left_sidebar_nav'
|
29
48
|
.panel-area
|
@@ -1,12 +1,13 @@
|
|
1
1
|
module CmAdmin
|
2
2
|
class Configuration
|
3
|
-
attr_accessor :layout, :included_models, :cm_admin_models
|
4
|
-
|
3
|
+
attr_accessor :layout, :included_models, :cm_admin_models, :enable_tracking, :project_name
|
4
|
+
|
5
5
|
def initialize
|
6
6
|
@layout = 'admin'
|
7
7
|
@included_models = []
|
8
8
|
@cm_admin_models = []
|
9
|
+
@enable_tracking = false
|
10
|
+
@project_name = ''
|
9
11
|
end
|
10
|
-
|
11
12
|
end
|
12
|
-
end
|
13
|
+
end
|
data/lib/cm_admin/version.rb
CHANGED
@@ -216,21 +216,22 @@ module CmAdmin
|
|
216
216
|
|
217
217
|
def attachment_list(form_obj, cm_field, _value, _required_class, _target_action)
|
218
218
|
attached = form_obj.object.send(cm_field.field_name)
|
219
|
+
attachment_name = "#{form_obj.object_name}_#{cm_field.field_name}_attachments"
|
219
220
|
return if defined?(::Paperclip) && attached.instance_of?(::Paperclip::Attachment)
|
220
221
|
|
221
222
|
content_tag(:div) do
|
222
223
|
if attached.class == ActiveStorage::Attached::Many
|
223
224
|
attached.each do |attachment|
|
224
|
-
concat attachment_with_icon(attachment)
|
225
|
+
concat attachment_with_icon(attachment, attachment_name:)
|
225
226
|
end
|
226
227
|
elsif attached.attached?
|
227
|
-
concat attachment_with_icon(attached)
|
228
|
+
concat attachment_with_icon(attached, attachment_name:)
|
228
229
|
end
|
229
230
|
end
|
230
231
|
end
|
231
232
|
|
232
|
-
def attachment_with_icon(attachment)
|
233
|
-
content_tag(:div, class: 'destroy-attachment', data: { ar_id: attachment.id }) do
|
233
|
+
def attachment_with_icon(attachment, attachment_name:)
|
234
|
+
content_tag(:div, class: 'destroy-attachment', data: { ar_id: attachment.id, attachment_name: }) do
|
234
235
|
concat(content_tag(:button, '', class: 'btn-ghost') do
|
235
236
|
concat tag.i(class: 'fa-regular fa-trash-can')
|
236
237
|
end)
|
@@ -53,8 +53,8 @@ module CmAdmin
|
|
53
53
|
concat hidden_field_tag 'class_name', klass.name.to_s, id: 'export-to-file-klass'
|
54
54
|
concat checkbox_row(klass)
|
55
55
|
concat tag.hr
|
56
|
-
# TODO: export-to-file-btn class is used for JS functionality, Have to remove
|
57
|
-
concat submit_tag 'Export', class: 'btn-primary export-to-file-btn'
|
56
|
+
# TODO: export-to-file-btn class is used for JS functionality, Have to remove
|
57
|
+
concat submit_tag 'Export', class: 'btn-primary export-to-file-btn'
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
@@ -76,7 +76,20 @@ module CmAdmin
|
|
76
76
|
|
77
77
|
def humanized_ar_collection_count(count, model_name)
|
78
78
|
table_name = count == 1 ? model_name.singularize : model_name.pluralize
|
79
|
-
|
79
|
+
"#{count} #{table_name.humanize.downcase} found"
|
80
|
+
end
|
81
|
+
|
82
|
+
def project_name_with_env
|
83
|
+
return CmAdmin.config.project_name if Rails.env.production?
|
84
|
+
|
85
|
+
env = if Rails.env.development?
|
86
|
+
'DEV'
|
87
|
+
elsif Rails.env.staging?
|
88
|
+
'STG'
|
89
|
+
else
|
90
|
+
Rails.env
|
91
|
+
end
|
92
|
+
"[#{env}] #{CmAdmin.config.project_name}"
|
80
93
|
end
|
81
94
|
end
|
82
95
|
end
|
data/lib/cm_admin.rb
CHANGED
@@ -16,7 +16,6 @@ module CmAdmin
|
|
16
16
|
@@cm_admin_models ||= []
|
17
17
|
|
18
18
|
class << self
|
19
|
-
|
20
19
|
def webpacker
|
21
20
|
@webpacker ||= ::Webpacker::Instance.new(
|
22
21
|
root_path: CmAdmin::Engine.root,
|
@@ -24,25 +23,23 @@ module CmAdmin
|
|
24
23
|
)
|
25
24
|
end
|
26
25
|
|
27
|
-
def configure
|
26
|
+
def configure
|
28
27
|
# instance_eval(&block)
|
29
28
|
@config ||= Configuration.new
|
30
29
|
yield(@config)
|
31
30
|
end
|
32
31
|
|
33
|
-
def layout
|
34
|
-
end
|
32
|
+
def layout; end
|
35
33
|
|
36
34
|
def config
|
37
35
|
@config ||= Configuration.new
|
38
36
|
end
|
39
37
|
|
40
38
|
def initialize_model(entity, &block)
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
39
|
+
return unless entity.is_a?(Class)
|
40
|
+
return if CmAdmin::Model.find_by({ name: entity.name })
|
41
|
+
|
42
|
+
config.cm_admin_models << CmAdmin::Model.new(entity, &block)
|
45
43
|
end
|
46
44
|
end
|
47
|
-
|
48
45
|
end
|
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.5.
|
4
|
+
version: 1.5.48
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: exe
|
16
16
|
cert_chain: []
|
17
|
-
date: 2024-09-
|
17
|
+
date: 2024-09-06 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: caxlsx_rails
|
@@ -172,6 +172,7 @@ executables: []
|
|
172
172
|
extensions: []
|
173
173
|
extra_rdoc_files: []
|
174
174
|
files:
|
175
|
+
- ".github/CODEOWNERS"
|
175
176
|
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
176
177
|
- ".github/ISSUE_TEMPLATE/config.yml"
|
177
178
|
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
@@ -512,7 +513,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
512
513
|
- !ruby/object:Gem::Version
|
513
514
|
version: '0'
|
514
515
|
requirements: []
|
515
|
-
rubygems_version: 3.5.
|
516
|
+
rubygems_version: 3.5.16
|
516
517
|
signing_key:
|
517
518
|
specification_version: 4
|
518
519
|
summary: CmAdmin is a robust gem designed to assist in creating admin panels for Rails
|