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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 57f4f569dd190c4beda6a88e60269f61170e1f4e57b84a4b8628bc5ffcee5590
4
- data.tar.gz: 114732f4357071651829db26e0f6a9fed0fbc9bfc70f7ef269c01b17f344dd2b
3
+ metadata.gz: 15551855652f4c5ac77f380e97f4ffee2641505f1daf273d47eae69c571322d1
4
+ data.tar.gz: bc0face163e5ace8d25df0c19c093673d7bf28d1f36b8bd607d717e7143634b5
5
5
  SHA512:
6
- metadata.gz: 486c5bd7d7f3602d25df34ac7e62c0bd5a562ae34d4737f0f7787a3b64ec3f561fe60d550980c8e50962d176ff9bc4c8cfe69b2400ced3a8718f049cabe25bea
7
- data.tar.gz: a8db47cc780c85b77ad7afe9f1e6a37da27362d56d134fd6f95d795032c7adbda6e863aa18f8fce711d065ae712f34891097889ccec79ace88c3847a04fb1a84
6
+ metadata.gz: 0ed4fb721ecc53c56b6a808817a9873fe4f4fa11d2b1d24c56f4514775b24ef5fc79cbdf6f0d90f9c0b78e20af154d2712eaf4e5d93c84a7ef0efe2fe292e6ad
7
+ data.tar.gz: 22a7d944b8fb5a351a519a0df3bbfb1d48b7d220df715cd017345acee909c638020bee23b28fe044528492431b4c81673b1617332498de262335dcadab833a9a
@@ -0,0 +1 @@
1
+ * @Mahaveer1141 @anbublacky @mikevic
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cm-admin (1.5.47)
4
+ cm-admin (1.5.48)
5
5
  caxlsx_rails
6
6
  cocoon (~> 1.2.15)
7
7
  csv-importer (~> 0.8.2)
@@ -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
- if ($(this).val().trim().length === 0) {
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
- | Admin
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
@@ -6,7 +6,7 @@ module CmAdmin
6
6
 
7
7
  # Returns the humanized value of the field.
8
8
  def humanized_field_value(name, capitalize: false)
9
- name.to_s.humanize(capitalize: capitalize)
9
+ name.to_s.humanize(capitalize:)
10
10
  end
11
11
  end
12
12
  end
@@ -1,3 +1,3 @@
1
1
  module CmAdmin
2
- VERSION = '1.5.47'
2
+ VERSION = '1.5.48'
3
3
  end
@@ -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
- return "#{count} #{table_name.humanize.downcase} found"
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(&block)
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
- if entity.is_a?(Class)
42
- return if CmAdmin::Model.find_by({name: entity.name})
43
- config.cm_admin_models << CmAdmin::Model.new(entity, &block)
44
- end
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.47
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-02 00:00:00.000000000 Z
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.11
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