cm-admin 2.3.1 → 2.3.3

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: e42e9b9dc9b550386fa213a199184d24274ff133e0b0a14e690eb29c92474749
4
- data.tar.gz: 189dbd6e4b5c140c329a50c3def2b7e7206c9f9a255fa799704673270ade5b45
3
+ metadata.gz: 2f85a062f8d926712d7817aeb392c0233208690eacbefeccdbcadb90ac6e85cf
4
+ data.tar.gz: eb59e86b5c40e9e592d8c1c488cbb5bf9ab2d7de5e66fbad97c0abb401449688
5
5
  SHA512:
6
- metadata.gz: 618be634d246ba8f11011e3942e8dd3198ce2aedc152ec26e1f70765407b8395988900b2846fedbb41322643f92924c65db7f6b57011adc6c2fe39e8c281003c
7
- data.tar.gz: 75160181e254c266c6b9ecdd04206ef0b502d08f7cd5456e13cddb4762fe3b8b698932441ce46abb372f54579e7531525c6fa675c311b1afeeb6cca18e1fab2f
6
+ metadata.gz: e4bf5998df379c42994928003eac0f18770c1650983520aae1fd2940f062d239f567066ea16469b1c7fa5135d9d77a0307be7df13c2a34342625b02da0ed2445
7
+ data.tar.gz: 0a7d326057c1a49aff2ef3db674ab7e21f1634634f1b527d4cb85bc535c49c0ef441b102bcb16b6d8077f33f5866d333b49c9ab6d096c9833bd7da019c43e961
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cm-admin (2.3.1)
4
+ cm-admin (2.3.3)
5
5
  caxlsx_rails
6
6
  cocoon (~> 1.2.15)
7
7
  csv-importer (~> 0.8.2)
@@ -40,6 +40,19 @@ document.addEventListener("turbo:load", function () {
40
40
  });
41
41
  jqueryJgrowl();
42
42
  setup_select_2_ajax();
43
+ var el = $("[data-section='nested-form-body']")
44
+ if(el[0]) {
45
+ Sortable.create(el[0],{
46
+ handle: '.drag-handle',
47
+ animation: 150,
48
+ onUpdate: function (evt) {
49
+ var itemEl = evt.item
50
+ $("[data-section='nested-form-body'] tr").each(function(index, el){
51
+ $(el).find('.hidden-position').val(index+1)
52
+ })
53
+ }
54
+ });
55
+ }
43
56
  });
44
57
 
45
58
  $(document).on(
@@ -147,4 +147,31 @@ var replaceAccordionTitle = function (element) {
147
147
  .attr("data-bs-target", "#" + accordion_id);
148
148
  $(this).find(".accordion-collapse").attr("id", accordion_id);
149
149
  });
150
+ initializeComponents();
150
151
  };
152
+
153
+ export function initializeComponents() {
154
+ $('.select-2').select2({
155
+ theme: "bootstrap-5",
156
+ });
157
+ flatpickr("[data-behaviour='date-only']", {
158
+ dateFormat: "d-m-Y"
159
+ })
160
+ flatpickr("[data-behaviour='date-time']", {
161
+ enableTime: true
162
+ })
163
+ flatpickr("[data-behaviour='filter'][data-filter-type='date']", {
164
+ mode: 'range'
165
+ })
166
+ var el = document.getElementsByClassName('columns-list')
167
+ if(el[0]) {
168
+ Sortable.create(el[0],{
169
+ handle: '.dragger',
170
+ animation: 150
171
+ });
172
+ }
173
+
174
+ var headerElemHeight = $('.page-top-bar').height() + 64
175
+ var calculatedHeight = "calc(100vh - " + headerElemHeight+"px"+")"
176
+ $('.table-wrapper').css("maxHeight", calculatedHeight);
177
+ }
@@ -1,38 +1,5 @@
1
- $(document).on('turbolinks:load', function () {
2
- $('.select-2').select2({
3
- theme: "bootstrap-5",
4
- });
5
- flatpickr("[data-behaviour='date-only']", {
6
- dateFormat: "d-m-Y"
7
- })
8
- flatpickr("[data-behaviour='date-time']", {
9
- enableTime: true
10
- })
11
- flatpickr("[data-behaviour='filter'][data-filter-type='date']", {
12
- mode: 'range'
13
- })
14
- var el = document.getElementsByClassName('columns-list')
15
- if(el[0]) {
16
- Sortable.create(el[0],{
17
- handle: '.dragger',
18
- animation: 150
19
- });
20
- }
21
-
22
- // var array = $('#searchKeywords').val().split(",");
23
- // $.each(array,function(i){
24
- // alert(array[i]);
25
- // });
26
-
27
- // var el = document.getElementsByClassName('kanban-list')
28
- // if(el[0]) {
29
- // Sortable.create(el,{
30
- // handle: '.kanban-item',
31
- // animation: 150
32
- // });
33
- // }
1
+ import { initializeComponents } from "../../../assets/javascripts/cm_admin/shared_scaffolds";
34
2
 
35
- var headerElemHeight = $('.page-top-bar').height() + 64
36
- var calculatedHeight = "calc(100vh - " + headerElemHeight+"px"+")"
37
- $('.table-wrapper').css("maxHeight", calculatedHeight);
3
+ $(document).on('turbolinks:load', function () {
4
+ initializeComponents();
38
5
  });
@@ -1,7 +1,11 @@
1
1
  - if nested_table_field.display_type == :table
2
2
  tr.nested-fields
3
- td.item-delete-cell
4
- - if nested_table_field.is_deletable.call(f.object)
3
+ - if nested_table_field.is_positionable.call(f.object)
4
+ td
5
+ i class='fa-solid fa-arrows-up-down-left-right drag-handle'
6
+ = f.hidden_field :position, class: 'hidden-position'
7
+ - if nested_table_field.is_deletable.call(f.object)
8
+ td.item-delete-cell
5
9
  = link_to_remove_association "", f, class: 'fa-regular fa-trash-can btn-ghost'
6
10
  - nested_table_field.fields.each do |field|
7
11
  td data-field-type="#{field.input_type}"
@@ -8,13 +8,17 @@
8
8
  table.nested-form-table
9
9
  thead
10
10
  tr
11
- th
12
- |
13
- - nested_table_field.fields.each do |field|
11
+ - if nested_table_field.is_positionable.call(f.object)
12
+ th
13
+ |
14
+ - if nested_table_field.is_deletable.call(f.object)
15
+ th
16
+ |
17
+ - nested_table_field.fields.each do |field|
14
18
  th data-field-type="#{field.input_type}"
15
19
  - if field.label
16
20
  = field.label.to_s || field.field_name.to_s.titleize
17
- tbody class="insert-cocoon-position-#{uniq_no}"
21
+ tbody class="insert-cocoon-position-#{uniq_no}" data-section='nested-form-body'
18
22
  = f.fields_for table_name do |record|
19
23
  - if record.object.persisted? || @ar_object.errors.present?
20
24
  = render partial: '/cm_admin/main/nested_fields', locals: { f: record, assoc_name: assoc_name, nested_table_field: nested_table_field }
@@ -6,7 +6,8 @@ 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_attrs, :target, :col_size, :ajax_url, :helper_text
9
+ :placeholder, :display_if, :html_attrs, :target, :col_size, :ajax_url, :helper_text,
10
+ :image_preview
10
11
 
11
12
  VALID_INPUT_TYPES = %i[
12
13
  integer decimal string single_select multi_select date date_time text switch custom_single_select checkbox_group
@@ -32,6 +33,7 @@ module CmAdmin
32
33
  self.html_attrs = {}
33
34
  self.target = {}
34
35
  self.col_size = nil
36
+ self.image_preview = false
35
37
  end
36
38
 
37
39
  def set_default_placeholder
@@ -4,7 +4,8 @@ module CmAdmin
4
4
 
5
5
  # NestedField is like a container to hold Field and FormField object
6
6
 
7
- attr_accessor :field_name, :display_type, :fields, :associated_fields, :parent_field, :header, :label, :submit_text, :is_deletable, :is_creatable
7
+ attr_accessor :field_name, :display_type, :fields, :associated_fields, :parent_field,
8
+ :header, :label, :submit_text, :is_deletable, :is_creatable, :is_positionable
8
9
 
9
10
  def initialize(field_name, attributes={})
10
11
  @field_name = field_name
@@ -21,6 +22,7 @@ module CmAdmin
21
22
  self.submit_text = "+ Add #{@field_name.to_s.titleize}"
22
23
  self.is_deletable = lambda { |arg| return true }
23
24
  self.is_creatable = lambda { |arg| return true }
25
+ self.is_positionable = lambda { |arg| return false }
24
26
  end
25
27
 
26
28
  end
@@ -1,3 +1,3 @@
1
1
  module CmAdmin
2
- VERSION = '2.3.1'
2
+ VERSION = '2.3.3'
3
3
  end
@@ -222,20 +222,25 @@ module CmAdmin
222
222
  content_tag(:div) do
223
223
  if attached.class == ActiveStorage::Attached::Many
224
224
  attached.each do |attachment|
225
- concat attachment_with_icon(attachment, attachment_name:)
225
+ concat attachment_with_icon(cm_field, attachment, attachment_name:)
226
226
  end
227
227
  elsif attached.attached?
228
- concat attachment_with_icon(attached, attachment_name:)
228
+ concat attachment_with_icon(cm_field, attached, attachment_name:)
229
229
  end
230
230
  end
231
231
  end
232
232
 
233
- def attachment_with_icon(attachment, attachment_name:)
233
+ def attachment_with_icon(cm_field, attachment, attachment_name:)
234
234
  content_tag(:div, class: 'destroy-attachment', data: { ar_id: attachment.id, attachment_name: }) do
235
235
  concat(content_tag(:button, '', class: 'btn-ghost') do
236
236
  concat tag.i(class: 'fa-regular fa-trash-can')
237
237
  end)
238
238
  concat content_tag(:span, attachment.filename.to_s, class: 'btn-link')
239
+ concat(content_tag(:a, href: attachment.url, target: '_blank') do
240
+ if attachment.content_type.include?('image')
241
+ image_tag(attachment.url, height: 50, width: 50, class: "rounded")
242
+ end
243
+ end) if cm_field.image_preview
239
244
  end
240
245
  end
241
246
 
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: 2.3.1
4
+ version: 2.3.3
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-10-04 00:00:00.000000000 Z
17
+ date: 2024-10-08 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: caxlsx_rails
@@ -184,7 +184,6 @@ files:
184
184
  - ".rubocop-https---raw-githubusercontent-com-commutatus-cm-linters-main-rubocop-yml"
185
185
  - ".rubocop.yml"
186
186
  - ".stylelintrc.json"
187
- - ".travis.yml"
188
187
  - ".vscode/settings.json"
189
188
  - ".yardopts"
190
189
  - CNAME
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.7.2
6
- before_install: gem install bundler -v 2.1.4