cm-admin 1.5.1 → 1.5.2

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: 4ff4795451733611c79424a5a0ac4aaacd838b34c8d7aea5fdfe6cb127367a97
4
- data.tar.gz: 4f856a769adc82e99b13a243973906ef387cb00fe892eec14422286f622e80b7
3
+ metadata.gz: 6f7069da141483288102690ee44cb4343f343822031103677ab598d0a5ccb0b1
4
+ data.tar.gz: 50aa27e800231369711bd021dbe17f7ad456b76bc935acee234be6eb87f636b0
5
5
  SHA512:
6
- metadata.gz: faa21284eae53b8fe3a1834bf6a27d0820197e714da9e23d6243d14ed54d94db314260da3db6893dba3dff37ec1e8e377af27eb668a98fa5de513b94edb1c29f
7
- data.tar.gz: ad2570287ad72e499c468e9006720022fe67d1a1f98d10ab60c88cbdeaccf0d1f6fd0c492f5141ad08b3de745bb2d1373797b6af1343b721fbdec121404e9fd8
6
+ metadata.gz: d6ed0804824162768e7edcd8156e58016760a038a1e4e018410b54caec4b197f7d79384e3c54383a5a977754a08b57818d86fdc2a41df596b0c2f74cb4a8bf57
7
+ data.tar.gz: f06e7efe409134da48d7fd95b3e741fa191cff10ae50ab18da19270653c7fccd316ce893d7fd91c4277deecade00ee2424ad808dd88e9a69e02397b0acfe4351
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cm-admin (1.5.1)
4
+ cm-admin (1.5.2)
5
5
  caxlsx_rails
6
6
  cocoon (~> 1.2.15)
7
7
  csv-importer (~> 0.8.2)
@@ -214,9 +214,11 @@ var unhideClearFilterBtn = function(filterValue) {
214
214
  }
215
215
  }
216
216
 
217
+ $(document).on('click', '[data-behaviour="select-option"] .cm-checkbox', function(e) {
218
+ $(this).prop('checked', !$(this).prop('checked'));
219
+ })
217
220
  // Selecting options for single and multi select filters
218
221
  $(document).on('click', '[data-behaviour="select-option"]', function(e) {
219
- debugger
220
222
  var filterType = $(this).data('filter-type')
221
223
  var filterColumn = $(this).data('db-column')
222
224
 
@@ -1,4 +1,4 @@
1
- $(document).on('click', '.form_submit', function (e) {
1
+ $(document).on('click', '[data-behaviour="form_submit"]', function (e) {
2
2
  e.preventDefault();
3
3
  var submit = [];
4
4
  var form_class = $(this).data('form-class');
@@ -30,6 +30,6 @@ $(document).on('click', '.form_submit', function (e) {
30
30
  });
31
31
  if (submit.length === 0) {
32
32
  $('.' + form_class).submit();
33
- return $('.form_submit').button('loading');
33
+ return $('[data-behaviour="form_submit"]').button('loading');
34
34
  }
35
35
  });
@@ -323,6 +323,7 @@ module CmAdmin
323
323
  column_names << generate_nested_params(associated_field)
324
324
  end
325
325
  end
326
+ column_names += attachment_fields(table_name.to_s.classify.constantize)
326
327
  Hash[
327
328
  "#{table_name}_attributes",
328
329
  column_names
@@ -335,14 +336,7 @@ module CmAdmin
335
336
  }
336
337
  columns += @model.ar_model.stored_attributes.values.flatten
337
338
  permittable_fields = @model.additional_permitted_fields + columns.reject { |i| CmAdmin::REJECTABLE_FIELDS.include?(i) }
338
- permittable_fields += @model.ar_model.name.constantize.reflect_on_all_associations.map {|x|
339
- next if x.options[:polymorphic]
340
- if x.class.name.include?('HasOne')
341
- x.name.to_s.gsub('_attachment', '').gsub('rich_text_', '').to_sym
342
- elsif x.class.name.include?('HasMany')
343
- Hash[x.name.to_s.gsub('_attachments', ''), []]
344
- end
345
- }.compact
339
+ permittable_fields += attachment_fields(@model.ar_model.name.constantize)
346
340
  nested_table_fields = get_nested_table_fields(@model.available_fields[:new])
347
341
  nested_table_fields += get_nested_table_fields(@model.available_fields[:edit])
348
342
  nested_fields = nested_table_fields.uniq.map {|nested_table_field|
@@ -358,5 +352,18 @@ module CmAdmin
358
352
 
359
353
  model_object.find(id)
360
354
  end
355
+
356
+ private
357
+
358
+ def attachment_fields(model_object)
359
+ model_object.reflect_on_all_associations.map {|reflection|
360
+ next if reflection.options[:polymorphic]
361
+ if reflection.class.name.include?('HasOne')
362
+ reflection.name.to_s.gsub('_attachment', '').gsub('rich_text_', '').to_sym
363
+ elsif reflection.class.name.include?('HasMany')
364
+ Hash[reflection.name.to_s.gsub('_attachments', ''), []]
365
+ end
366
+ }.compact
367
+ end
361
368
  end
362
369
  end
@@ -1,3 +1,3 @@
1
1
  module CmAdmin
2
- VERSION = '1.5.1'
2
+ VERSION = '1.5.2'
3
3
  end
@@ -135,8 +135,7 @@ module CmAdmin
135
135
  end
136
136
  concat split_form_into_section(resource, form_obj, entities)
137
137
  concat tag.br
138
- # TODO: form_submit class is used for JS functionality, Have to remove
139
- concat form_obj.submit 'Save', class: 'btn-cta form_submit', data: {form_class: "cm_#{form_obj.object.class.name.downcase}_form"}
138
+ concat form_obj.submit 'Save', class: 'btn-cta', data: {behaviour: 'form_submit', form_class: "cm_#{form_obj.object.class.name.downcase}_form"}
140
139
  end
141
140
  end
142
141
  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.1
4
+ version: 1.5.2
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-05-02 00:00:00.000000000 Z
13
+ date: 2024-05-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: caxlsx_rails