cm-admin 1.5.41 → 1.5.42

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: c64d865b82c2abfd0975930a349a1ba2f63ee85d5ecbf0a4e627d3cbc1629bb1
4
- data.tar.gz: 5ce41edd98628d3b20315a5ca44c5be95daf578bbdd53c97192f114f58110545
3
+ metadata.gz: 25d1608feb2a0f90e9e8e8202d8898e511a1e1bbb4bc463e0a327190eeedb27a
4
+ data.tar.gz: 7a2ccc290b1545db664634cb915f81a8dca27630c024e38cbbb9fbf1898cee72
5
5
  SHA512:
6
- metadata.gz: 7327d73ee5028535163d62e4f3dbc7197389132178331c9bf76e4e0bb463166a06fb74186c4c32c0a50871c37ead0895e7f4b43157646bb3a5ff59b3e5e7e207
7
- data.tar.gz: fefcc76ae24e4cc066c9dc70831fa5f1974bfe03563c49863e319180adec9577eb0dcb6acae9a4d35d4b587a7a2b602d3a09e0cab4c4b03ae8eac1e12eddd286
6
+ metadata.gz: 15783cf2216b6390a976eeacc314f5a89b0b696ee777648c2e8bcd9e58fff27e625b1b5f29336d0ac31327833e148b5fb8c563b984df79e1e8d5c321ba27b23a
7
+ data.tar.gz: 2d3672c631061c354c3e2b72589ceb8b4e5d42f81b3efd9eed9f8b55a743336d434c4ea826bd3a66c3befb11bc770a8c647ddf879c9b86fa1c10296f4c2d265f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cm-admin (1.5.41)
4
+ cm-admin (1.5.42)
5
5
  caxlsx_rails
6
6
  cocoon (~> 1.2.15)
7
7
  csv-importer (~> 0.8.2)
@@ -42,9 +42,8 @@ var getFilteredData = function(filterType, filterValue, filterColumn=null) {
42
42
  // Generate the queryString by concatenating the filterParams and
43
43
  // searchParams that are already applied, if searchParams are present.
44
44
  var searchParams = window.location.search
45
- var searchParamshash = getParamsAsObject(searchParams)
46
- var tempsearchParamshash = delete searchParamshash['page']
47
- if (tempsearchParamshash.length > 0) {
45
+ var searchParamsHash = getParamsAsObject(searchParams)
46
+ if (Object.keys(searchParamsHash).length > 0) {
48
47
  // Delete the previous applied value for multi_select filter from the
49
48
  // searchParams as altering the array with new and old value will create
50
49
  // more complicated logic. The new value is passed and structured in
@@ -41,13 +41,3 @@ $(document).on("click", '[data-behaviour="form_submit"]', function (e) {
41
41
  return $('[data-behaviour="form_submit"]').button("loading");
42
42
  }
43
43
  });
44
-
45
- $(document).on("change", '[data-behaviour="multiple-checkbox"]', function (e) {
46
- const inputField = e.target.previousElementSibling;
47
-
48
- if (e.target.checked) {
49
- inputField.setAttribute("disabled", "disabled");
50
- } else {
51
- inputField.removeAttribute("disabled");
52
- }
53
- });
@@ -9,7 +9,7 @@ module CmAdmin
9
9
  :placeholder, :display_if, :html_attrs, :target, :col_size, :ajax_url, :helper_text
10
10
 
11
11
  VALID_INPUT_TYPES = %i[
12
- integer decimal string single_select multi_select date date_time text switch custom_single_select
12
+ integer decimal string single_select multi_select date date_time text switch custom_single_select checkbox_group
13
13
  single_file_upload multi_file_upload hidden rich_text check_box radio_button custom_string custom_date
14
14
  ].freeze
15
15
 
@@ -1,3 +1,3 @@
1
1
  module CmAdmin
2
- VERSION = '1.5.41'
2
+ VERSION = '1.5.42'
3
3
  end
@@ -57,15 +57,15 @@ module CmAdmin
57
57
  def cm_switch_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)\
58
58
  content_tag :div, class: 'form-check form-switch' do
59
59
  concat form_obj.check_box cm_field.field_name,
60
- merge_wrapper_options(
61
- {
62
- class: "field-control form-check-input #{required_class}",
63
- disabled: cm_field.disabled.call(form_obj.object),
64
- value:,
65
- role: 'switch'
66
- }, cm_field.html_attrs
67
- )
68
- concat content_tag(:div, cm_field.field_name.to_s.titleize, class: 'cm-switch-label')
60
+ merge_wrapper_options(
61
+ {
62
+ class: "field-control form-check-input #{required_class}",
63
+ disabled: cm_field.disabled.call(form_obj.object),
64
+ value:,
65
+ role: 'switch'
66
+ }, cm_field.html_attrs
67
+ )
68
+ concat content_tag(:div, cm_field.label, class: 'cm-switch-label')
69
69
  end
70
70
  end
71
71
 
@@ -239,12 +239,42 @@ module CmAdmin
239
239
  end
240
240
  end
241
241
 
242
- def cm_check_box_field(form_obj, cm_field, value, required_class, target_action, _ajax_url)
243
- format_check_box_options(value, form_obj, cm_field, required_class, target_action)
242
+ def cm_check_box_field(form_obj, cm_field, _value, required_class, target_action, _ajax_url)
243
+ content_tag :div, class: 'form-check' do
244
+ concat form_obj.check_box cm_field.field_name,
245
+ merge_wrapper_options(
246
+ {
247
+ class: "form-check-input #{required_class} #{target_action.present? ? 'linked-field-request' : ''}",
248
+ disabled: cm_field.disabled.call(form_obj.object),
249
+ data: {
250
+ field_name: cm_field.field_name,
251
+ target_action: target_action&.name,
252
+ target_url: target_action&.name ? cm_admin.send("#{@model.name.underscore}_#{target_action&.name}_path") : ''
253
+ }
254
+ }, cm_field.html_attrs
255
+ )
256
+ concat content_tag(:div, cm_field.label, class: 'cm-checkbox-label')
257
+ end
258
+ end
259
+
260
+ def cm_checkbox_group_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)
261
+ original_value = form_obj.object.send(cm_field.field_name)
262
+ content_tag :div do
263
+ concat form_obj.text_field cm_field.field_name, name: "#{@model.name.underscore}[#{cm_field.field_name}][]",
264
+ value: nil, hidden: true
265
+ value.each do |key, val|
266
+ is_checked = original_value.include?(val)
267
+ concat format_check_box(val || key, key, form_obj, cm_field, required_class, is_checked)
268
+ end
269
+ end
244
270
  end
245
271
 
246
- def cm_radio_button_field(form_obj, _cm_field, value, _required_class, _target_action, _ajax_url)
247
- format_radio_button_options(value, form_obj)
272
+ def cm_radio_button_field(form_obj, cm_field, value, _required_class, _target_action, _ajax_url)
273
+ content_tag :div do
274
+ value.each do |key, val|
275
+ concat format_radio_option(val || key, key, cm_field, form_obj)
276
+ end
277
+ end
248
278
  end
249
279
 
250
280
  def cm_hidden_field(form_obj, cm_field, value, _required_class, _target_action, _ajax_url)
@@ -269,89 +299,23 @@ module CmAdmin
269
299
  end
270
300
  end
271
301
 
272
- def format_check_box_options(value, form_obj, cm_field, required_class, target_action)
273
- if value.instance_of?(Array)
274
- format_check_box_array(value, form_obj, cm_field, required_class, target_action)
275
- else
276
- content_tag :div, class: 'cm-checkbox-section' do
277
- concat single_checkbox_tag(value, form_obj, cm_field, required_class, target_action)
278
- concat content_tag(:div, cm_field.field_name.to_s.titleize, class: 'cm-checkbox-label')
279
- end
280
- end
281
- end
282
-
283
- def format_check_box_array(options, form_obj, cm_field, required_class, target_action)
284
- content_tag :div do
285
- options.each do |key, val|
286
- concat format_check_box(val, key, form_obj, cm_field, required_class, target_action)
287
- end
288
- end
289
- end
290
-
291
- def format_check_box(val, key, form_obj, cm_field, required_class, target_action)
292
- content_tag :div, class: 'cm-checkbox-section' do
293
- concat format_check_box_tag(val, form_obj, cm_field, required_class, target_action)
294
- concat content_tag(:div, key, class: 'cm-checkbox-label')
295
- end
296
- end
297
-
298
- def single_checkbox_tag(value, form_obj, cm_field, required_class, target_action)
299
- content_tag :div, class: 'cm-checkbox-tag' do
300
- concat form_obj.check_box cm_field.field_name,
301
- merge_wrapper_options(
302
- {
303
- class: "cm-checkbox #{required_class} #{target_action.present? ? 'linked-field-request' : ''}",
304
- disabled: cm_field.disabled.call(form_obj.object),
305
- data: {
306
- field_name: cm_field.field_name,
307
- target_action: target_action&.name,
308
- target_url: target_action&.name ? cm_admin.send("#{@model.name.underscore}_#{target_action&.name}_path") : ''
309
- }
310
- }, cm_field.html_attrs
311
- )
312
- end
313
- end
314
-
315
- def format_check_box_tag(val, form_obj, cm_field, required_class, target_action)
316
- content_tag :div, class: 'cm-checkbox-tag' do
317
- if val.present?
318
- concat form_obj.text_field cm_field.field_name, name: "#{@model.name.underscore}[#{cm_field.field_name}][]", value: '0', hidden: true, disabled: 'disabled'
319
- else
320
- concat form_obj.text_field cm_field.field_name, name: "#{@model.name.underscore}[#{cm_field.field_name}][]", value: '0', hidden: true
321
- end
322
- concat check_box_tag "#{@model.name.underscore}[#{cm_field.field_name}][]", '1', val,
302
+ def format_check_box(val, key, form_obj, cm_field, required_class, is_checked)
303
+ content_tag :div, class: 'form-check' do
304
+ concat check_box_tag "#{@model.name.underscore}[#{cm_field.field_name}][]", val, is_checked,
323
305
  merge_wrapper_options(
324
306
  {
325
- class: "cm-checkbox multiple-checkbox #{required_class} #{target_action.present? ? 'linked-field-request' : ''}",
326
- disabled: cm_field.disabled.call(form_obj.object),
327
- data: {
328
- behaviour: 'multiple-checkbox',
329
- target_action: target_action&.name,
330
- target_url: target_action&.name ? cm_admin.send("#{@model.name.underscore}_#{target_action&.name}_path", ':param_1') : ''
331
- }
307
+ class: "form-check-input #{required_class}",
308
+ disabled: cm_field.disabled.call(form_obj.object)
332
309
  }, cm_field.html_attrs
333
310
  )
311
+ concat content_tag(:div, key, class: 'cm-checkbox-label')
334
312
  end
335
313
  end
336
314
 
337
- def format_radio_button_options(options, form_obj)
338
- content_tag :div do
339
- options.each do |val, key|
340
- concat format_radio_option(val, key, form_obj)
341
- end
342
- end
343
- end
344
-
345
- def format_radio_option(val, key, form_obj)
346
- content_tag :div, class: 'cm-radio-section' do
347
- concat format_radio_button(val, form_obj)
348
- concat content_tag(:div, key, class: 'cm-radio-label')
349
- end
350
- end
351
-
352
- def format_radio_button(val, form_obj)
353
- content_tag :div, class: 'cm-radio-tag' do
354
- concat form_obj.radio_button :level, val, class: 'field-control cm-radio'
315
+ def format_radio_option(val, key, cm_field, form_obj)
316
+ content_tag :div, class: 'form-check' do
317
+ concat form_obj.radio_button cm_field.field_name, val, merge_wrapper_options({ class: 'form-check-input' }, cm_field.html_attrs)
318
+ concat content_tag(:div, key, class: 'form-check-label')
355
319
  end
356
320
  end
357
321
 
@@ -112,7 +112,7 @@ module CmAdmin
112
112
  concat input_field_for_column(form_obj, field)
113
113
  else
114
114
  concat(content_tag(:div, class: "form-field #{field.disabled ? 'disabled' : ''}") do
115
- if field.label
115
+ if field.label && %i[check_box switch].exclude?(field.input_type)
116
116
  concat form_obj.label field.label, field.label, class: 'field-label'
117
117
  concat tag.br
118
118
  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.41
4
+ version: 1.5.42
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-08-01 00:00:00.000000000 Z
17
+ date: 2024-08-05 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: caxlsx_rails