cm-admin 1.2.8 → 1.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: ae65becafa199e298f7a291d69efcfb82bfd21ea14727d091bf0a6ec5040d642
4
- data.tar.gz: 3b91abd5664970b2fcb6a4bcec060cd97d0461f62718a502fe0e78a5fe80762b
3
+ metadata.gz: f7e6efbcc18df89a3b37963b143cb81564c1ba2aa07df3972d452f7d79a5615e
4
+ data.tar.gz: d779de03dae22b2c81c568205a29e3a785c62e4d14bb4a2633c7ee4e9a3c4944
5
5
  SHA512:
6
- metadata.gz: 60dbdf4ad38f21fc435d3eda1bf0dbff8498fee67fd43622f8853a29954cb6b31de0dcf4f58057fa02e9a7e87eb83f360617940d303fb23d7ca5e9e930891595
7
- data.tar.gz: d251828725a456d7acc754a7006ab5c995f2bf8188b8f88e8559e9cd0620c603df64f74fa47b6435d2b717a67ba832c26e06a0354e54af0d3460b182568fd994
6
+ metadata.gz: b878ed9eb649bb0838b2901d89f1dee2eab61c03bda22a05dd07d27929e0bfbf0c08aad3c0d6c02ebb652ce989330177d168bf4200707a65983ac1de9724a141
7
+ data.tar.gz: 406bf4e9fe8311d52af3e0f733faf8136c19ef3e3f3bc0547e399afaf13d4cf591d555d031120c3fab1f6f0b7e93c7e6aac1e955eab6d22182c0b49356964874
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cm-admin (1.2.8)
4
+ cm-admin (1.3.0)
5
5
  caxlsx_rails
6
6
  cocoon (~> 1.2.15)
7
7
  csv-importer (~> 0.8.2)
@@ -135,7 +135,9 @@ module CmAdmin
135
135
  end
136
136
  elsif @action.display_type == :page
137
137
  data = @action.parent == "index" ? @ar_object.data : @ar_object
138
- format.html { render @action.partial }
138
+ # TODO: To set a default value for @action.layout, Since it is used in render above,
139
+ # Need to check and fix it.
140
+ format.html { render @action.partial, layout: @action.layout || 'cm_admin' }
139
141
  else
140
142
  begin
141
143
  response_object = @action.code_block.call(@response_object)
@@ -19,7 +19,7 @@
19
19
  = render partial: '/cm_admin/main/nested_fields', locals: { f: record, assoc_name: assoc_name, nested_table_field: nested_table_field }
20
20
  - if f.object._reflections[assoc_name.to_s]&.macro == :has_many
21
21
  .nested-table-footer
22
- = link_to_add_association "+ Add #{assoc_name.to_s.titleize}", f, table_name, partial: '/cm_admin/main/nested_fields', render_options: {locals: { assoc_name: assoc_name, nested_table_field: nested_table_field }}, data: { association_insertion_node: ".insert-cocoon-position-#{uniq_no}", association_insertion_method: 'append' }, class: 'btn-primary'
22
+ = link_to_add_association "#{nested_table_field.submit_text}", f, table_name, partial: '/cm_admin/main/nested_fields', render_options: {locals: { assoc_name: assoc_name, nested_table_field: nested_table_field }}, data: { association_insertion_node: ".insert-cocoon-position-#{uniq_no}", association_insertion_method: 'append' }, class: 'btn-primary'
23
23
  - else
24
24
  .nested-field-wrapper data-table-name=assoc_name data-model-name=assoc_name.to_s.classify
25
25
  / label.nested-field-label = assoc_name.to_s.titleize
@@ -29,4 +29,4 @@
29
29
  = render partial: '/cm_admin/main/nested_fields', locals: { f: record, assoc_name: assoc_name, nested_table_field: nested_table_field }
30
30
  - if f.object._reflections[assoc_name.to_s]&.macro == :has_many
31
31
  .links.mt-3
32
- = link_to_add_association "+ Add #{assoc_name.to_s.titleize}", f, table_name, partial: '/cm_admin/main/nested_fields', render_options: {locals: { assoc_name: assoc_name, nested_table_field: nested_table_field }}, class: 'd-inline-block btn-primary mt-2'
32
+ = link_to_add_association "#{nested_table_field.submit_text}", f, table_name, partial: '/cm_admin/main/nested_fields', render_options: {locals: { assoc_name: assoc_name, nested_table_field: nested_table_field }}, class: 'd-inline-block btn-primary mt-2'
@@ -3,7 +3,7 @@ require_relative 'actions/blocks'
3
3
  module CmAdmin
4
4
  module Models
5
5
  class CustomAction < Action
6
- attr_accessor :modal_configuration
6
+ attr_accessor :modal_configuration, :url_params
7
7
 
8
8
  def initialize(attributes = {}, &block)
9
9
  super
@@ -121,13 +121,14 @@ module CmAdmin
121
121
  # end
122
122
  # end
123
123
  # end
124
- def custom_action(name: nil, page_title: nil, page_description: nil, display_name: nil, verb: nil, layout: nil, layout_type: nil, partial: nil, path: nil, display_type: nil, modal_configuration: {}, display_if: lambda { |arg| return true }, route_type: nil, icon_name: 'fa fa-th-large', &block)
124
+ def custom_action(name: nil, page_title: nil, page_description: nil, display_name: nil, verb: nil, layout: nil, layout_type: nil, partial: nil, path: nil, display_type: nil, modal_configuration: {}, url_params: {}, display_if: lambda { |arg| return true }, route_type: nil, icon_name: 'fa fa-th-large', &block)
125
125
  action = CmAdmin::Models::CustomAction.new(
126
126
  page_title: page_title, page_description: page_description,
127
127
  name: name, display_name: display_name, verb: verb, layout: layout,
128
128
  layout_type: layout_type, partial: partial, path: path,
129
129
  parent: self.current_action.name, display_type: display_type, display_if: display_if,
130
- action_type: :custom, route_type: route_type, icon_name: icon_name, modal_configuration: modal_configuration, &block)
130
+ action_type: :custom, route_type: route_type, icon_name: icon_name, modal_configuration: modal_configuration,
131
+ url_params: url_params, &block)
131
132
  @available_actions << action
132
133
  # self.class.class_eval(&block)
133
134
  end
@@ -4,7 +4,7 @@ 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
7
+ attr_accessor :field_name, :display_type, :fields, :associated_fields, :parent_field, :header, :label, :submit_text
8
8
 
9
9
  def initialize(field_name, attributes={})
10
10
  @field_name = field_name
@@ -18,6 +18,7 @@ module CmAdmin
18
18
  self.display_type = :table
19
19
  self.fields = []
20
20
  self.associated_fields = []
21
+ self.submit_text = "+ Add #{@field_name.to_s.titleize}"
21
22
  end
22
23
 
23
24
  end
@@ -1,3 +1,3 @@
1
1
  module CmAdmin
2
- VERSION = '1.2.8'
2
+ VERSION = '1.3.0'
3
3
  end
@@ -49,6 +49,10 @@ module CmAdmin
49
49
  local_date(ar_object.send(field.field_name), (field.format || '%B %e, %Y'))
50
50
  when :text
51
51
  ar_object.send(field.field_name)
52
+ when :money
53
+ humanized_money(ar_object.send(field.field_name))
54
+ when :money_with_symbol
55
+ humanized_money_with_symbol(ar_object.send(field.field_name))
52
56
  when :custom
53
57
  send(field.helper_method, ar_object, field.field_name)
54
58
  when :link
@@ -48,7 +48,7 @@ module CmAdmin
48
48
  when :modal
49
49
  custom_modal_button(custom_action)
50
50
  when :page
51
- path = cm_admin.send("#{@model.name.underscore}_#{custom_action.name}_path", @ar_object.id)
51
+ path = cm_admin.send("#{@model.name.underscore}_#{custom_action.name}_path", @ar_object.id, custom_action.url_params)
52
52
  link_to custom_action_title(custom_action), path, class: 'btn-secondary ms-2', method: custom_action.verb
53
53
  end
54
54
  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.2.8
4
+ version: 1.3.0
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: 2023-10-18 00:00:00.000000000 Z
13
+ date: 2023-10-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails