cm-admin 1.5.27 → 1.5.28

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: 80372ae18ae55b314e3140013b256d5b482105f017bd8174dfb5a0eb7157e105
4
- data.tar.gz: 6543238e8a2610fd96742ec9e062d3f2b1e0a5a7bcf12c925734fa8c072a3b15
3
+ metadata.gz: 7935960984bf5a170dbb16e272ce951ab886ae16fcbb131d25fcbaafc31a8e82
4
+ data.tar.gz: de1756f433cdb23fccf3daaee59e46b8436ca37cee29b5c34808a19d28211989
5
5
  SHA512:
6
- metadata.gz: 1d18282dfa81d47fd073355c9e473255d3e1abfae81366b09683ba37e3c47a92fc927e47258523acf48c10d3faf9587c39bbab31983e3ce5e1192d5757a4fe30
7
- data.tar.gz: 40a791b08a8795345394960c8e00d7a50706988e97f7110240997cdac8239c2545dd2fb494ce52a83fd7ec513cacbaa51f685f5c4db1756a181e0679a8e6ef89
6
+ metadata.gz: 315d9e2c449721ac68ae48fe238ad80035208b774c84e31c71f70bf9c4fb3f481ae0ff37d1e9fa76aaa9040106d59a202e7baea257cc2b603ecb7bd4cdc08efc
7
+ data.tar.gz: 00577270ba1efaee074b670e339e80ee80692414b3ea7ecc2388951443d881bbbc3f5f56866baa4f0b7c907d8a1188f10dd6081fbafce27d268f37bbbb67c276
@@ -19,10 +19,6 @@ jobs:
19
19
  rubocop_extensions: rubocop-rails:2.14.2
20
20
  github_token: ${{ secrets.GITHUB_TOKEN }}
21
21
  reporter: github-pr-check # Possible values are github-pr-check, github-pr-review
22
- - name: reek
23
- uses: reviewdog/action-reek@v1
24
- with:
25
- reek_version: 6.1.1
26
22
  - uses: actions/checkout@v3
27
23
  - name: stylelint
28
24
  uses: reviewdog/action-stylelint@v1
data/Gemfile CHANGED
@@ -8,9 +8,9 @@ gem 'rspec', '~> 3.0'
8
8
  gem 'slim'
9
9
 
10
10
  group :development do
11
- gem 'rubocop', '~> 1.35.1', require: false
12
- gem 'rubocop-rails', '~> 2.15.2', require: false
13
- gem 'rubocop-performance', '~> 1.14.3', require: false
11
+ gem 'rubocop', require: false
12
+ gem 'rubocop-performance', require: false
13
+ gem 'rubocop-rails', require: false
14
14
  end
15
15
  # Specify your gem's dependencies in cm_admin.gemspec
16
16
  gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cm-admin (1.5.27)
4
+ cm-admin (1.5.28)
5
5
  caxlsx_rails
6
6
  cocoon (~> 1.2.15)
7
7
  csv-importer (~> 0.8.2)
@@ -98,7 +98,7 @@ GEM
98
98
  cocoon (1.2.15)
99
99
  coercible (1.0.0)
100
100
  descendants_tracker (~> 0.0.1)
101
- concurrent-ruby (1.2.2)
101
+ concurrent-ruby (1.3.3)
102
102
  crass (1.0.6)
103
103
  csv-importer (0.8.2)
104
104
  virtus
@@ -110,14 +110,15 @@ GEM
110
110
  globalid (1.2.1)
111
111
  activesupport (>= 6.1)
112
112
  htmlentities (4.3.4)
113
- i18n (1.14.1)
113
+ i18n (1.14.5)
114
114
  concurrent-ruby (~> 1.0)
115
115
  ice_nine (0.11.2)
116
116
  importmap-rails (2.0.1)
117
117
  actionpack (>= 6.0.0)
118
118
  activesupport (>= 6.0.0)
119
119
  railties (>= 6.0.0)
120
- json (2.6.2)
120
+ json (2.7.2)
121
+ language_server-protocol (3.17.0.3)
121
122
  local_time (2.1.0)
122
123
  loofah (2.22.0)
123
124
  crass (~> 1.0.2)
@@ -131,7 +132,7 @@ GEM
131
132
  method_source (1.1.0)
132
133
  mini_mime (1.1.5)
133
134
  mini_portile2 (2.8.7)
134
- minitest (5.18.1)
135
+ minitest (5.24.0)
135
136
  net-imap (0.4.11)
136
137
  date
137
138
  net-protocol
@@ -150,13 +151,14 @@ GEM
150
151
  nokogiri (1.16.5-x86_64-linux)
151
152
  racc (~> 1.4)
152
153
  pagy (4.11.0)
153
- parallel (1.22.1)
154
- parser (3.1.2.1)
154
+ parallel (1.25.1)
155
+ parser (3.3.3.0)
155
156
  ast (~> 2.4.1)
157
+ racc
156
158
  pundit (2.2.0)
157
159
  activesupport (>= 3.0.0)
158
160
  racc (1.8.0)
159
- rack (2.2.7)
161
+ rack (2.2.9)
160
162
  rack-proxy (0.7.7)
161
163
  rack
162
164
  rack-test (2.1.0)
@@ -191,8 +193,9 @@ GEM
191
193
  zeitwerk (~> 2.5)
192
194
  rainbow (3.1.1)
193
195
  rake (12.3.3)
194
- regexp_parser (2.6.1)
195
- rexml (3.2.5)
196
+ regexp_parser (2.9.2)
197
+ rexml (3.3.0)
198
+ strscan
196
199
  rspec (3.10.0)
197
200
  rspec-core (~> 3.10.0)
198
201
  rspec-expectations (~> 3.10.0)
@@ -206,31 +209,34 @@ GEM
206
209
  diff-lcs (>= 1.2.0, < 2.0)
207
210
  rspec-support (~> 3.10.0)
208
211
  rspec-support (3.10.2)
209
- rubocop (1.35.1)
212
+ rubocop (1.64.1)
210
213
  json (~> 2.3)
214
+ language_server-protocol (>= 3.17.0)
211
215
  parallel (~> 1.10)
212
- parser (>= 3.1.2.1)
216
+ parser (>= 3.3.0.2)
213
217
  rainbow (>= 2.2.2, < 4.0)
214
218
  regexp_parser (>= 1.8, < 3.0)
215
219
  rexml (>= 3.2.5, < 4.0)
216
- rubocop-ast (>= 1.20.1, < 2.0)
220
+ rubocop-ast (>= 1.31.1, < 2.0)
217
221
  ruby-progressbar (~> 1.7)
218
- unicode-display_width (>= 1.4.0, < 3.0)
219
- rubocop-ast (1.23.0)
220
- parser (>= 3.1.1.0)
221
- rubocop-performance (1.14.3)
222
- rubocop (>= 1.7.0, < 2.0)
223
- rubocop-ast (>= 0.4.0)
224
- rubocop-rails (2.15.2)
222
+ unicode-display_width (>= 2.4.0, < 3.0)
223
+ rubocop-ast (1.31.3)
224
+ parser (>= 3.3.1.0)
225
+ rubocop-performance (1.21.1)
226
+ rubocop (>= 1.48.1, < 2.0)
227
+ rubocop-ast (>= 1.31.1, < 2.0)
228
+ rubocop-rails (2.25.0)
225
229
  activesupport (>= 4.2.0)
226
230
  rack (>= 1.1)
227
- rubocop (>= 1.7.0, < 2.0)
228
- ruby-progressbar (1.11.0)
231
+ rubocop (>= 1.33.0, < 2.0)
232
+ rubocop-ast (>= 1.31.1, < 2.0)
233
+ ruby-progressbar (1.13.0)
229
234
  rubyzip (2.3.2)
230
235
  semantic_range (3.0.0)
231
236
  slim (4.1.0)
232
237
  temple (>= 0.7.6, < 0.9)
233
238
  tilt (>= 2.0.6, < 2.1)
239
+ strscan (3.1.0)
234
240
  temple (0.8.2)
235
241
  thor (1.3.1)
236
242
  thread_safe (0.3.6)
@@ -238,7 +244,7 @@ GEM
238
244
  timeout (0.4.1)
239
245
  tzinfo (2.0.6)
240
246
  concurrent-ruby (~> 1.0)
241
- unicode-display_width (2.3.0)
247
+ unicode-display_width (2.5.0)
242
248
  virtus (2.0.0)
243
249
  axiom-types (~> 0.1)
244
250
  coercible (~> 1.0)
@@ -267,9 +273,9 @@ DEPENDENCIES
267
273
  pundit
268
274
  rake (~> 12.0)
269
275
  rspec (~> 3.0)
270
- rubocop (~> 1.35.1)
271
- rubocop-performance (~> 1.14.3)
272
- rubocop-rails (~> 2.15.2)
276
+ rubocop
277
+ rubocop-performance
278
+ rubocop-rails
273
279
  slim
274
280
 
275
281
  BUNDLED WITH
@@ -4,7 +4,10 @@
4
4
  p.section-heading = section.section_name
5
5
  .card
6
6
  .card-body
7
- - section.section_fields.each do |field|
8
- = show_field(@ar_object, field)
7
+ - if !section.section_fields.empty?
8
+ - section.section_fields.each do |field|
9
+ = show_field(@ar_object, field)
10
+ - if section.rows.present?
11
+ = show_rows(@ar_object, section.rows)
9
12
  - section.nested_table_fields.each do |nested_field|
10
- = render partial: 'cm_admin/main/nested_table_section', locals: { nested_field: nested_field, ar_object: @ar_object }
13
+ = render partial: 'cm_admin/main/nested_table_section', locals: { nested_field: nested_field, ar_object: @ar_object }
data/cm_admin.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.description = 'CmAdmin providing a streamlined and efficient solution for building customized admin panels within the context of Rails applications. Its robust features empower developers to effortlessly generate and manage administrative interfaces with precision and ease.'
11
11
  spec.homepage = 'https://github.com/commutatus/cm-admin'
12
12
  spec.license = 'MIT'
13
- spec.required_ruby_version = '>= 3.0.0'
13
+ spec.required_ruby_version = '>= 2.7.0'
14
14
 
15
15
  # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
16
16
 
@@ -6,7 +6,7 @@ module CmAdmin
6
6
  include Utils::Helpers
7
7
 
8
8
  attr_accessor :field_name, :label, :header, :input_type, :collection, :disabled, :helper_method,
9
- :placeholder, :display_if, :html_attr, :target, :col_size, :ajax_url
9
+ :placeholder, :display_if, :html_attrs, :target, :col_size, :ajax_url
10
10
 
11
11
  VALID_INPUT_TYPES = %i[
12
12
  integer decimal string single_select multi_select date date_time text
@@ -28,7 +28,7 @@ module CmAdmin
28
28
  self.disabled = lambda { |arg| return false } if display_if.nil?
29
29
  self.label = self.field_name.to_s.titleize
30
30
  self.input_type = :string
31
- self.html_attr = {}
31
+ self.html_attrs = {}
32
32
  self.target = {}
33
33
  self.col_size = nil
34
34
  end
@@ -27,6 +27,14 @@ module CmAdmin
27
27
  end
28
28
  end
29
29
 
30
+ def field(field_name, options={})
31
+ if @current_nested_field
32
+ @current_nested_field.fields << CmAdmin::Models::Field.new(field_name, options)
33
+ else
34
+ @row_fields << CmAdmin::Models::Field.new(field_name, options)
35
+ end
36
+ end
37
+
30
38
  def cm_section(section_name, col_size: nil, display_if: nil, &block)
31
39
  @sections << CmAdmin::Models::Section.new(section_name, @current_action, @model, display_if, col_size, &block)
32
40
  end
@@ -37,4 +45,4 @@ module CmAdmin
37
45
  end
38
46
  end
39
47
  end
40
- end
48
+ end
@@ -1,3 +1,3 @@
1
1
  module CmAdmin
2
- VERSION = '1.5.27'
2
+ VERSION = '1.5.28'
3
3
  end
@@ -9,6 +9,23 @@ module CmAdmin
9
9
  end
10
10
  end
11
11
 
12
+ def show_rows(ar_object, rows, col_size: 3)
13
+ rows.map do |row|
14
+ content_tag(:div, class: 'row') do
15
+ row.row_fields.map do |field|
16
+ next unless field.display_if.call(ar_object)
17
+
18
+ content_tag(:div, class: "col-#{col_size}") do
19
+ content_tag(:div, class: "card-info") do
20
+ concat show_field_label(ar_object, field)
21
+ concat value_with_prefix_and_suffix(ar_object, field)
22
+ end
23
+ end
24
+ end.compact.join.html_safe
25
+ end
26
+ end.join.html_safe
27
+ end
28
+
12
29
  def show_field_label(ar_object, field)
13
30
  content_tag(:div, class: "card-info__label") do
14
31
  field_label = if field.label.present?
@@ -71,7 +88,7 @@ module CmAdmin
71
88
  when :tag
72
89
  tag_class = field.tag_class.dig("#{ar_object.send(field.field_name.to_s)}".to_sym).to_s
73
90
  content_tag :span, class: "status-tag #{tag_class}" do
74
- ar_object.send(field.field_name).to_s.upcase
91
+ ar_object.send(field.field_name).to_s.titleize.upcase
75
92
  end
76
93
  when :attachment
77
94
  show_attachment_value(ar_object, field)
@@ -19,57 +19,73 @@ module CmAdmin
19
19
 
20
20
  def cm_integer_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)
21
21
  form_obj.text_field cm_field.field_name,
22
- class: "field-control #{required_class}",
23
- disabled: cm_field.disabled.call(form_obj.object),
24
- value: value,
25
- placeholder: cm_field.placeholder,
26
- data: { behaviour: 'integer-only' }
22
+ merge_wrapper_options(
23
+ {
24
+ class: "field-control #{required_class}",
25
+ disabled: cm_field.disabled.call(form_obj.object),
26
+ value: value,
27
+ placeholder: cm_field.placeholder,
28
+ data: { behaviour: 'integer-only' }
29
+ }, cm_field.html_attrs )
27
30
  end
28
31
 
29
32
  def cm_decimal_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)
30
33
  form_obj.text_field cm_field.field_name,
34
+ merge_wrapper_options({
31
35
  class: "field-control #{required_class}",
32
36
  disabled: cm_field.disabled.call(form_obj.object),
33
37
  value: value,
34
38
  placeholder: cm_field.placeholder,
35
39
  data: { behaviour: 'decimal-only' }
40
+ }, cm_field.html_attrs )
36
41
  end
37
42
 
38
43
  def cm_string_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)
39
44
  form_obj.text_field cm_field.field_name,
40
- class: "field-control #{required_class}",
41
- disabled: cm_field.disabled.call(form_obj.object),
42
- value: value,
43
- placeholder: cm_field.placeholder
45
+ merge_wrapper_options(
46
+ {
47
+ class: "field-control #{required_class}",
48
+ disabled: cm_field.disabled.call(form_obj.object),
49
+ value: value,
50
+ placeholder: cm_field.placeholder
51
+ }, cm_field.html_attrs )
44
52
  end
45
53
 
46
54
  def cm_custom_string_field(form_obj, cm_field, value, required_class, _target_action)
47
- text_field_tag cm_field.html_attr[:name] || cm_field.field_name,
48
- value, class: "field-control #{required_class}",
49
- disabled: cm_field.disabled.call(form_obj.object),
50
- placeholder: cm_field.placeholder
55
+ text_field_tag cm_field.html_attrs[:name] || cm_field.field_name,
56
+ merge_wrapper_options(
57
+ {
58
+ value: value,
59
+ class: "field-control #{required_class}",
60
+ disabled: cm_field.disabled.call(form_obj.object),
61
+ placeholder: cm_field.placeholder
62
+ }, cm_field.html_attrs )
51
63
  end
52
64
 
53
65
  def cm_single_select_field(form_obj, cm_field, value, required_class, target_action, ajax_url)
54
66
  class_name = ajax_url.present? ? 'select-2-ajax' : 'select-2'
55
67
  form_obj.select cm_field.field_name, options_for_select(select_collection_value(form_obj.object, cm_field), form_obj.object.send(cm_field.field_name)),
56
- { include_blank: cm_field.placeholder },
57
- class: "field-control #{required_class} #{class_name}",
58
- disabled: cm_field.disabled.call(form_obj.object),
59
- data: {
60
- field_name: cm_field.field_name,
61
- field_type: 'linked-field',
62
- target_action: target_action&.name,
63
- target_url: target_action&.name ? cm_admin.send("#{@model.name.underscore}_#{target_action&.name}_path") : '',
64
- ajax_url: ajax_url
65
- }
68
+ {include_blank: cm_field.placeholder},
69
+ merge_wrapper_options(
70
+ {
71
+ class: "field-control #{required_class} #{class_name}",
72
+ disabled: cm_field.disabled.call(form_obj.object),
73
+ data: {
74
+ field_name: cm_field.field_name,
75
+ field_type: 'linked-field',
76
+ target_action: target_action&.name,
77
+ target_url: target_action&.name ? cm_admin.send("#{@model.name.underscore}_#{target_action&.name}_path") : '',
78
+ ajax_url: ajax_url
79
+ }
80
+ }, cm_field.html_attrs )
66
81
  end
67
82
 
68
83
  def cm_custom_single_select_field(form_obj, cm_field, value, required_class, target_action, _ajax_url)
69
- select_tag cm_field.html_attr[:name] || cm_field.field_name,
84
+ select_tag cm_field.html_attrs[:name] || cm_field.field_name,
70
85
  options_for_select(select_collection_value(form_obj.object, cm_field)),
86
+ {include_blank: cm_field.placeholder}
87
+ merge_wrapper_options(
71
88
  {
72
- include_blank: cm_field.placeholder,
73
89
  class: "field-control #{required_class} select-2",
74
90
  disabled: cm_field.disabled.call(form_obj.object),
75
91
  data: {
@@ -78,66 +94,94 @@ module CmAdmin
78
94
  target_action: target_action&.name,
79
95
  target_url: target_action&.name ? cm_admin.send("#{@model.name.underscore}_#{target_action&.name}_path") : ''
80
96
  }
81
- }
97
+ }, cm_field.html_attrs )
82
98
  end
83
99
 
84
100
  def cm_multi_select_field(form_obj, cm_field, value, required_class, target_action, _ajax_url)
85
101
  form_obj.select cm_field.field_name,
86
102
  options_for_select(select_collection_value(form_obj.object, cm_field), form_obj.object.send(cm_field.field_name)),
87
- { include_blank: cm_field.placeholder },
88
- class: "field-control #{required_class} select-2",
89
- disabled: cm_field.disabled.call(form_obj.object), multiple: true
103
+ {include_blank: cm_field.placeholder}
104
+ merge_wrapper_options(
105
+ {
106
+ class: "field-control #{required_class} select-2",
107
+ disabled: cm_field.disabled.call(form_obj.object), multiple: true
108
+ }, cm_field.html_attrs )
90
109
  end
91
110
 
92
111
  def cm_date_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)
93
112
  form_obj.text_field cm_field.field_name,
113
+ merge_wrapper_options(
114
+ {
94
115
  class: "field-control #{required_class}",
95
116
  disabled: cm_field.disabled.call(form_obj.object),
96
117
  value: value&.strftime('%d-%m-%Y'),
97
118
  placeholder: cm_field.placeholder,
98
119
  data: { behaviour: 'date-only' }
120
+ }, cm_field.html_attrs )
99
121
  end
100
122
 
101
123
  def cm_custom_date_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)
102
- text_field_tag cm_field.html_attr[:name] || cm_field.field_name, value&.strftime('%d-%m-%Y'),
124
+ text_field_tag cm_field.html_attrs[:name] || cm_field.field_name, value&.strftime('%d-%m-%Y'),
125
+ merge_wrapper_options(
126
+ {
103
127
  class: "field-control #{required_class}",
104
128
  disabled: cm_field.disabled.call(form_obj.object),
105
129
  value: value&.strftime('%d-%m-%Y'),
106
130
  placeholder: cm_field.placeholder,
107
131
  data: { behaviour: 'date-only' }
132
+ }, cm_field.html_attrs )
108
133
  end
109
134
 
110
135
  def cm_date_time_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)
111
136
  form_obj.text_field cm_field.field_name,
137
+ merge_wrapper_options(
138
+ {
112
139
  class: "field-control #{required_class}",
113
140
  disabled: cm_field.disabled.call(form_obj.object),
114
141
  value: value,
115
142
  placeholder: cm_field.placeholder,
116
143
  data: { behaviour: 'date-time' }
144
+ }, cm_field.html_attrs )
117
145
  end
118
146
 
119
147
  def cm_text_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)
120
148
  form_obj.text_area cm_field.field_name,
121
- class: "field-control #{required_class}",
122
- placeholder: cm_field.placeholder
149
+ merge_wrapper_options(
150
+ {
151
+ class: "field-control #{required_class}",
152
+ placeholder: cm_field.placeholder
153
+ }, cm_field.html_attrs)
123
154
  end
124
155
 
125
156
  def cm_rich_text_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)
126
157
  form_obj.rich_text_area cm_field.field_name,
127
- class: "field-control #{required_class}",
128
- placeholder: cm_field.placeholder
158
+ merge_wrapper_options(
159
+ {
160
+ class: "field-control #{required_class}",
161
+ placeholder: cm_field.placeholder
162
+ }, cm_field.html_attrs)
129
163
  end
130
164
 
131
165
  def cm_single_file_upload_field(form_obj, cm_field, _value, required_class, _target_action, _ajax_url)
132
166
  content_tag(:div) do
133
- concat form_obj.file_field cm_field.field_name, class: "field-control #{required_class}", disabled: cm_field.disabled.call(form_obj.object)
167
+ concat form_obj.file_field cm_field.field_name,
168
+ merge_wrapper_options(
169
+ {
170
+ class: "field-control #{required_class}",
171
+ disabled: cm_field.disabled.call(form_obj.object)
172
+ }, cm_field.html_attrs )
134
173
  concat attachment_list(form_obj, cm_field, _value, required_class, _target_action)
135
174
  end
136
175
  end
137
176
 
138
177
  def cm_multi_file_upload_field(form_obj, cm_field, _value, required_class, _target_action, _ajax_url)
139
178
  content_tag(:div) do
140
- concat form_obj.file_field cm_field.field_name, multiple: true, class: "field-control #{required_class}", disabled: cm_field.disabled.call(form_obj.object)
179
+ concat form_obj.file_field cm_field.field_name,
180
+ merge_wrapper_options(
181
+ {
182
+ multiple: true, class: "field-control #{required_class}",
183
+ disabled: cm_field.disabled.call(form_obj.object)
184
+ }, cm_field.html_attrs )
141
185
  concat attachment_list(form_obj, cm_field, _value, required_class, _target_action)
142
186
  end
143
187
  end
@@ -145,7 +189,7 @@ module CmAdmin
145
189
  def attachment_list(form_obj, cm_field, _value, required_class, _target_action)
146
190
  attached = form_obj.object.send(cm_field.field_name)
147
191
  return if defined?(::Paperclip) && attached.instance_of?(::Paperclip::Attachment)
148
-
192
+
149
193
  content_tag(:div) do
150
194
  if attached.class == ActiveStorage::Attached::Many
151
195
  attached.each do |attachment|
@@ -176,8 +220,11 @@ module CmAdmin
176
220
 
177
221
  def cm_hidden_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)
178
222
  form_obj.hidden_field cm_field.field_name,
179
- value: value,
180
- name: cm_field.html_attr[:name] || "#{form_obj.object_name}[#{cm_field.field_name}]"
223
+ merge_wrapper_options(
224
+ {
225
+ value: value,
226
+ name: cm_field.html_attrs[:name] || "#{form_obj.object_name}[#{cm_field.field_name}]"
227
+ }, cm_field.html_attrs )
181
228
  end
182
229
 
183
230
  # Refactor: Collection argument can be removed.
@@ -197,15 +244,16 @@ module CmAdmin
197
244
  format_check_box_array(value, form_obj, cm_field, required_class, target_action)
198
245
  else
199
246
  form_obj.check_box cm_field.field_name,
200
- {
201
- class: "cm-checkbox #{required_class} #{target_action.present? ? 'linked-field-request' : ''}",
202
- disabled: cm_field.disabled.call(form_obj.object),
203
- data: {
204
- field_name: cm_field.field_name,
205
- target_action: target_action&.name,
206
- target_url: target_action&.name ? cm_admin.send("#{@model.name.underscore}_#{target_action&.name}_path") : ''
207
- }
208
- }
247
+ merge_wrapper_options(
248
+ {
249
+ class: "cm-checkbox #{required_class} #{target_action.present? ? 'linked-field-request' : ''}",
250
+ disabled: cm_field.disabled.call(form_obj.object),
251
+ data: {
252
+ field_name: cm_field.field_name,
253
+ target_action: target_action&.name,
254
+ target_url: target_action&.name ? cm_admin.send("#{@model.name.underscore}_#{target_action&.name}_path") : ''
255
+ }
256
+ }, cm_field.html_attrs )
209
257
  end
210
258
  end
211
259
 
@@ -227,6 +275,7 @@ module CmAdmin
227
275
  def format_check_box_tag(val, form_obj, cm_field, required_class, target_action)
228
276
  content_tag :div, class: 'cm-radio-tag' do
229
277
  concat form_obj.check_box cm_field.field_name,
278
+ merge_wrapper_options(
230
279
  {
231
280
  class: "cm-checkbox #{required_class} #{target_action.present? ? 'linked-field-request' : ''}",
232
281
  disabled: cm_field.disabled.call(form_obj.object),
@@ -235,7 +284,8 @@ module CmAdmin
235
284
  target_action: target_action&.name,
236
285
  target_url: target_action&.name ? cm_admin.send("#{@model.name.underscore}_#{target_action&.name}_path", ':param_1') : ''
237
286
  }
238
- }, val
287
+ }, cm_field.html_attrs ),
288
+ val
239
289
  end
240
290
  end
241
291
 
@@ -259,6 +309,24 @@ module CmAdmin
259
309
  concat form_obj.radio_button :level, val, class: 'field-control cm-radio'
260
310
  end
261
311
  end
312
+
313
+ def merge_wrapper_options(options, html_attrs)
314
+ if html_attrs
315
+ options.merge(html_attrs) do |key, oldval, newval|
316
+ case key.to_s
317
+ when "class"
318
+ oldval + " " + newval
319
+ when "data", "aria"
320
+ oldval.merge(newval)
321
+ else
322
+ newval
323
+ end
324
+ end
325
+ else
326
+ options
327
+ end
328
+ end
329
+
262
330
  end
263
331
  end
264
332
  end
data/package-lock.json CHANGED
@@ -13650,9 +13650,9 @@
13650
13650
  }
13651
13651
  },
13652
13652
  "node_modules/ws": {
13653
- "version": "8.13.0",
13654
- "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz",
13655
- "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==",
13653
+ "version": "8.17.1",
13654
+ "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz",
13655
+ "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==",
13656
13656
  "dev": true,
13657
13657
  "engines": {
13658
13658
  "node": ">=10.0.0"
data/yarn.lock CHANGED
@@ -7717,9 +7717,9 @@ write-file-atomic@^4.0.2:
7717
7717
  signal-exit "^3.0.7"
7718
7718
 
7719
7719
  ws@^8.4.2:
7720
- version "8.8.0"
7721
- resolved "https://registry.npmjs.org/ws/-/ws-8.8.0.tgz"
7722
- integrity sha512-JDAgSYQ1ksuwqfChJusw1LSJ8BizJ2e/vVu5Lxjq3YvNJNlROv1ui4i+c/kUUrPheBvQl4c5UbERhTwKa6QBJQ==
7720
+ version "8.17.1"
7721
+ resolved "https://registry.yarnpkg.com/ws/-/ws-8.17.1.tgz#9293da530bb548febc95371d90f9c878727d919b"
7722
+ integrity sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==
7723
7723
 
7724
7724
  xtend@^4.0.0, xtend@~4.0.1:
7725
7725
  version "4.0.2"
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.27
4
+ version: 1.5.28
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: 2024-06-17 00:00:00.000000000 Z
13
+ date: 2024-06-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: caxlsx_rails
@@ -167,11 +167,9 @@ files:
167
167
  - ".github/ISSUE_TEMPLATE/bug_report.md"
168
168
  - ".github/ISSUE_TEMPLATE/config.yml"
169
169
  - ".github/ISSUE_TEMPLATE/feature_request.md"
170
- - ".github/workflows/bump_gem.yml"
171
170
  - ".github/workflows/linters.yml"
172
- - ".github/workflows/push_gem.yml"
171
+ - ".github/workflows/release-gem.yml"
173
172
  - ".gitignore"
174
- - ".reek.yml"
175
173
  - ".rspec"
176
174
  - ".rubocop-https---raw-githubusercontent-com-commutatus-cm-linters-main-rubocop-yml"
177
175
  - ".rubocop.yml"
@@ -493,7 +491,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
493
491
  requirements:
494
492
  - - ">="
495
493
  - !ruby/object:Gem::Version
496
- version: 3.0.0
494
+ version: 2.7.0
497
495
  required_rubygems_version: !ruby/object:Gem::Requirement
498
496
  requirements:
499
497
  - - ">="
@@ -1,79 +0,0 @@
1
- name: Push & Release Gem Gem
2
-
3
- on:
4
- workflow_dispatch:
5
- inputs:
6
- bump_type:
7
- type: choice
8
- description: "Bump Type ( Choosing None will bump build number and keep the same version )"
9
- default: "patch"
10
- options:
11
- - patch
12
- - minor
13
- - major
14
-
15
-
16
- permissions:
17
- contents: read
18
-
19
- jobs:
20
- build:
21
- name: Build gem
22
- runs-on: ubuntu-latest
23
-
24
- permissions:
25
- id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
26
- contents: write # IMPORTANT: this permission is required for `rake release` to push the release tag
27
-
28
- steps:
29
- # Set up
30
- - uses: actions/checkout@v4
31
-
32
- - name: set git config
33
- env:
34
- GH_TOKEN: ${{ github.token }}
35
- run: |
36
- git config --global user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com"
37
- git config --global user.name "$(gh api /users/${GITHUB_ACTOR} | jq .name -r)"
38
- git config -l
39
- - name: Set up Ruby
40
- uses: ruby/setup-ruby@v1
41
- with:
42
- bundler-cache: true
43
- ruby-version: ruby
44
-
45
- - name: Install the gem-release
46
- run: gem install gem-release
47
-
48
- - name: Bump the gem
49
- run: gem bump ${{ github.events.inputs.bump_type }}
50
-
51
- - name: Push the new version
52
- run: git push
53
-
54
- release:
55
-
56
- name: Release gem
57
- runs-on: ubuntu-latest
58
- needs: build
59
- permissions:
60
- id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
61
- contents: write # IMPORTANT: this permission is required for `rake release` to push the release tag
62
-
63
- steps:
64
- - uses: actions/checkout@v4
65
-
66
- - name: Git Pull
67
- run: git pull
68
-
69
- - name: Set up Ruby
70
- uses: ruby/setup-ruby@v1
71
- with:
72
- ruby-version: ruby
73
-
74
- - name: Remove lock on bundle
75
- run: bundle config set frozen false
76
-
77
- - uses: rubygems/release-gem@v1
78
- with:
79
- await-release: false
data/.reek.yml DELETED
@@ -1,9 +0,0 @@
1
- detectors:
2
- IrresponsibleModule:
3
- enabled: false
4
- UncommunicativeVariableName:
5
- enabled: true
6
- accept:
7
- - e
8
- TooManyStatements:
9
- enabled: false