cm-admin 1.2.8 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/controllers/cm_admin/resource_controller.rb +3 -1
- data/app/views/cm_admin/main/_nested_table_form.html.slim +2 -2
- data/lib/cm_admin/models/custom_action.rb +1 -1
- data/lib/cm_admin/models/dsl_method.rb +3 -2
- data/lib/cm_admin/models/nested_field.rb +2 -1
- data/lib/cm_admin/version.rb +1 -1
- data/lib/cm_admin/view_helpers/field_display_helper.rb +4 -0
- data/lib/cm_admin/view_helpers/page_info_helper.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7e6efbcc18df89a3b37963b143cb81564c1ba2aa07df3972d452f7d79a5615e
|
4
|
+
data.tar.gz: d779de03dae22b2c81c568205a29e3a785c62e4d14bb4a2633c7ee4e9a3c4944
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b878ed9eb649bb0838b2901d89f1dee2eab61c03bda22a05dd07d27929e0bfbf0c08aad3c0d6c02ebb652ce989330177d168bf4200707a65983ac1de9724a141
|
7
|
+
data.tar.gz: 406bf4e9fe8311d52af3e0f733faf8136c19ef3e3f3bc0547e399afaf13d4cf591d555d031120c3fab1f6f0b7e93c7e6aac1e955eab6d22182c0b49356964874
|
data/Gemfile.lock
CHANGED
@@ -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
|
-
|
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 "
|
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 "
|
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'
|
@@ -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,
|
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
|
data/lib/cm_admin/version.rb
CHANGED
@@ -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.
|
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-
|
13
|
+
date: 2023-10-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|