cm-admin 2.2.1 → 2.3.0

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: 1ececfae1032574362b71ffb26c47007efbfaefc7ebda5aa82cf99786146f99d
4
- data.tar.gz: 1f3f944038ea3f1102656e9ffeaf3a22c587de8ae7d7b433e397d48d3b1fe5d3
3
+ metadata.gz: f02c4921628126ddc305b8f76fefe27c325d11a90b6649166f30376af4983b9d
4
+ data.tar.gz: a0f263e975a1b4e7505bb6174a4cfe9942c55103259fda85d33e2cbf1b29af4b
5
5
  SHA512:
6
- metadata.gz: c3426a35c54e2b0eac13b6e7b05b3056fac953c2e21b44731d77482aa5d23a6642d78da984c16d17275ca815dfa97548f71a4f485dbca4b827ad9ac5eb376444
7
- data.tar.gz: 0f863ebd46889e605972b226f1e2b20327cd79b855bd46b800168a60bc611661ed44a12335099f18797d329096b5dd8cf5117f526fec4643c2583fda0cd61d58
6
+ metadata.gz: '0286312409deddb904e8f85ec754fc07c62b91db53f8d46171bfcb65e94bf3418578eca0ea9d329cf6b11a1c7447941508da91152b132d74e2e207bc93c3818e'
7
+ data.tar.gz: 66ca0d6ccacf4440b180a7e5b1b37e723e5f1363a96b3fa0e30d88d365476a94d5ff6a67590fdca34af18ebf08c026b6eecd6fae0739286512e9a858644d68e5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cm-admin (2.2.1)
4
+ cm-admin (2.3.0)
5
5
  caxlsx_rails
6
6
  cocoon (~> 1.2.15)
7
7
  csv-importer (~> 0.8.2)
@@ -4,6 +4,8 @@
4
4
  p.section-heading = section.section_name
5
5
  .card
6
6
  .card-body
7
+ - if section.partial.present?
8
+ = render partial: section.partial, locals: { ar_object: @ar_object }
7
9
  - if !section.section_fields.empty?
8
10
  - section.section_fields.each do |field|
9
11
  = show_field(@ar_object, field)
@@ -3,5 +3,7 @@
3
3
  p.section-heading = section.section_name
4
4
  .card
5
5
  .card-body
6
+ - if section.partial.present?
7
+ = render partial: section.partial, locals: { ar_object: @associated_ar_object }
6
8
  - section.section_fields.each do |field|
7
9
  = show_field(@associated_ar_object, field)
@@ -5,12 +5,31 @@
5
5
  .show-page__inner
6
6
  .card.col-7
7
7
  .card-body
8
- ul.history-items-list
9
- - @ar_object.action_trails.each do |at|
8
+ ul.history-items-list
9
+ - @ar_object.versions.each do |version|
10
10
  li.history-item
11
11
  .d-inline-flex.mb-2
12
- span.fw-bold.me-1 = at.actor.first_name
13
- span.me-1 = at.trail_type.titleize
12
+ span.fw-bold.me-1 = User.find_by(id: version.whodunnit).present? ? User.find_by(id: version.whodunnit).full_name : "Anonymous"
13
+ span.me-1 = version.event
14
14
  span.me-1 the
15
- span.fw-bold.me-1 = at.entity_type
16
- span.text-body-tertiary.me-1 = at.created_at.strftime("%B")
15
+ span.fw-bold.me-1 = version.item_type
16
+ span.text-body-tertiary.me-1 = version.created_at.strftime("%B %d, %Y, %H:%M %p")
17
+ - if version.event == 'update' && version.changeset.present?
18
+ .history-details
19
+ table.table.table-bordered.table-light style="width: 600px;"
20
+ thead
21
+ tr
22
+ th
23
+ | Updated Column
24
+ th
25
+ | Previous Value
26
+ th
27
+ | Updated Value
28
+ tbody
29
+ - version.changeset.each do |key, value|
30
+ tr
31
+ td = key
32
+ td = value[0] || '-'
33
+ td = value[1].instance_of?(ActiveSupport::TimeWithZone) ? value[1].strftime("%B %d, %Y, %H:%M %p") : value[1]
34
+
35
+
@@ -175,14 +175,14 @@ module CmAdmin
175
175
  # cm_section('Basic Information', display_if: ->(current_object) { current_object.name == 'John' }, col_size: 6, html_attrs: { class: 'section-class' }) do
176
176
  # field :title, input_type: :string
177
177
  # end
178
- def cm_section(section_name, display_if: nil, col_size: nil, html_attrs: nil, &block)
178
+ def cm_section(section_name, display_if: nil, col_size: nil, html_attrs: nil, partial: nil, &block)
179
179
  @available_fields[@current_action.name.to_sym] ||= []
180
- @available_fields[@current_action.name.to_sym] << CmAdmin::Models::Section.new(section_name, @current_action, @model, display_if, html_attrs, col_size, &block)
180
+ @available_fields[@current_action.name.to_sym] << CmAdmin::Models::Section.new(section_name, @current_action, @model, display_if, html_attrs, col_size, partial, &block)
181
181
  end
182
182
 
183
183
  # @deprecated Use {#cm_section} instead of this method
184
- def cm_show_section(section_name, display_if: nil, html_attrs: nil, &block)
185
- cm_section(section_name, display_if:, html_attrs:, &block)
184
+ def cm_show_section(section_name, display_if: nil, html_attrs: nil, partial: nil, &block)
185
+ cm_section(section_name, display_if:, html_attrs:, partial:, &block)
186
186
  end
187
187
 
188
188
  # Create a new column on index layout.
@@ -35,17 +35,17 @@ module CmAdmin
35
35
  end
36
36
  end
37
37
 
38
- def cm_section(section_name, col_size: nil, display_if: nil, html_attrs: nil, &block)
39
- @sections << CmAdmin::Models::Section.new(section_name, @current_action, @model, display_if, html_attrs, col_size, &block)
38
+ def cm_section(section_name, col_size: nil, display_if: nil, html_attrs: nil, partial: nil, &block)
39
+ @sections << CmAdmin::Models::Section.new(section_name, @current_action, @model, display_if, html_attrs, col_size, partial, &block)
40
40
  end
41
41
 
42
42
  # This method is deprecated. Use cm_section instead.
43
- def cm_show_section(section_name, col_size: nil, display_if: nil, html_attrs: nil, &block)
44
- cm_section(section_name, col_size: col_size, display_if: display_if, html_attrs: html_attrs, &block)
43
+ def cm_show_section(section_name, col_size: nil, display_if: nil, html_attrs: nil, partial: nil, &block)
44
+ cm_section(section_name, col_size: col_size, display_if: display_if, html_attrs: html_attrs, partial: partial, &block)
45
45
  end
46
46
 
47
- def nested_form_section(section_name, display_if: nil, col_size: nil, html_attrs: nil, &block)
48
- nested_section = CmAdmin::Models::Section.new(section_name, @current_action, @cm_model, display_if, html_attrs, col_size, &block)
47
+ def nested_form_section(section_name, display_if: nil, col_size: nil, html_attrs: nil, partial: nil, &block)
48
+ nested_section = CmAdmin::Models::Section.new(section_name, @current_action, @cm_model, display_if, html_attrs, col_size, partial, &block)
49
49
  nested_section.parent_section = self
50
50
  @row_fields << nested_section
51
51
  end
@@ -7,9 +7,9 @@ module CmAdmin
7
7
  # It also contains rows, which contains sections and fields.
8
8
 
9
9
  attr_accessor :section_name, :section_fields, :display_if, :current_action, :cm_model, :parent_section,
10
- :nested_table_fields, :rows, :col_size, :current_nested_field, :nested_sections, :html_attrs
10
+ :nested_table_fields, :rows, :col_size, :current_nested_field, :nested_sections, :html_attrs, :partial
11
11
 
12
- def initialize(section_name, current_action, cm_model, display_if, html_attrs, col_size, &block)
12
+ def initialize(section_name, current_action, cm_model, display_if, html_attrs, col_size, partial, &block)
13
13
  @section_fields = []
14
14
  @rows = []
15
15
  @nested_table_fields = []
@@ -22,6 +22,7 @@ module CmAdmin
22
22
  @current_nested_field = nil
23
23
  @nested_sections = []
24
24
  @parent_section = nil
25
+ @partial = partial || nil
25
26
  instance_eval(&block)
26
27
  end
27
28
 
@@ -63,8 +64,8 @@ module CmAdmin
63
64
  @rows << CmAdmin::Models::Row.new(@current_action, @model, display_if, html_attrs, &block)
64
65
  end
65
66
 
66
- def nested_form_section(section_name, display_if: nil, col_size: nil, html_attrs: nil, &block)
67
- nested_section = CmAdmin::Models::Section.new(section_name, @current_action, @cm_model, display_if, html_attrs, col_size, &block)
67
+ def nested_form_section(section_name, display_if: nil, col_size: nil, html_attrs: nil, partial: nil, &block)
68
+ nested_section = CmAdmin::Models::Section.new(section_name, @current_action, @cm_model, display_if, html_attrs, col_size, partial, &block)
68
69
  nested_section.parent_section = self
69
70
  @nested_sections ||= []
70
71
  @nested_sections << nested_section
@@ -1,3 +1,3 @@
1
1
  module CmAdmin
2
- VERSION = '2.2.1'
2
+ VERSION = '2.3.0'
3
3
  end
@@ -65,6 +65,7 @@ module CmAdmin
65
65
 
66
66
  def create_sections(resource, form_obj, section)
67
67
  content_tag :div, class: 'col form-container' do
68
+ return render partial: section.partial, locals: { form_obj: } if section.partial
68
69
  concat content_tag(:p, section.section_name, class: 'form-title') unless section.parent_section.present?
69
70
  concat set_form_for_fields(resource, form_obj, section)
70
71
  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: 2.2.1
4
+ version: 2.3.0
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-03 00:00:00.000000000 Z
17
+ date: 2024-10-04 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: caxlsx_rails