cm-admin 1.4.4 → 1.4.6
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 +4 -4
- data/app/controllers/cm_admin/resource_controller.rb +15 -12
- data/app/views/cm_admin/main/_actions_dropdown.html.slim +4 -4
- data/app/views/cm_admin/main/_table.html.slim +1 -1
- data/app/views/cm_admin/main/_tabs.html.slim +3 -3
- data/app/views/layouts/_destroy_action_modal.html.slim +4 -5
- data/lib/cm_admin/version.rb +1 -1
- data/lib/cm_admin/view_helpers/field_display_helper.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15cf5f7ed76c8f535bbdea485c0c67075d5bd8c98c4b92346d99212b6ff45d8d
|
4
|
+
data.tar.gz: fffe55bb0ceabb342a712073c7003f329871e24362f6b22cd4165c7fc7d0455b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbc644ba1802f3e1120ce6f461718a08230f9777b2abd3d442a008510c18156710b8374106f300a6fe70707f63d9a4f69d2eb4ba0adde35daf8696a53b3b7346
|
7
|
+
data.tar.gz: '06967882302a44acd967fee3812538635609f1358e0b5a6dade1b1e32228f6e30fe941d6831e407a6cddfba98e7fc56e2c5a8d1006123e56885423a57d262f5a'
|
@@ -31,7 +31,7 @@ module CmAdmin
|
|
31
31
|
def cm_show(params)
|
32
32
|
@current_action = CmAdmin::Models::Action.find_by(@model, name: 'show')
|
33
33
|
scoped_model = "CmAdmin::#{@model.name}Policy::Scope".constantize.new(Current.user, @model.name.constantize).resolve
|
34
|
-
@ar_object = scoped_model
|
34
|
+
@ar_object = fetch_ar_object(scoped_model, params[:id])
|
35
35
|
resource_identifier
|
36
36
|
respond_to do |format|
|
37
37
|
if request.xhr?
|
@@ -53,7 +53,7 @@ module CmAdmin
|
|
53
53
|
|
54
54
|
def cm_edit(params)
|
55
55
|
@current_action = CmAdmin::Models::Action.find_by(@model, name: 'edit')
|
56
|
-
@ar_object = @model.ar_model.name.classify.constantize
|
56
|
+
@ar_object = fetch_ar_object(@model.ar_model.name.classify.constantize, params[:id])
|
57
57
|
resource_identifier
|
58
58
|
respond_to do |format|
|
59
59
|
format.html { render '/cm_admin/main/' + action_name }
|
@@ -61,7 +61,7 @@ module CmAdmin
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def cm_update(params)
|
64
|
-
@ar_object = @model.ar_model.name.classify.constantize
|
64
|
+
@ar_object = fetch_ar_object(@model.ar_model.name.classify.constantize, params[:id])
|
65
65
|
@ar_object.assign_attributes(resource_params(params))
|
66
66
|
resource_identifier
|
67
67
|
resource_responder
|
@@ -74,7 +74,7 @@ module CmAdmin
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def cm_destroy(params)
|
77
|
-
@ar_object = @model.ar_model.name.classify.constantize
|
77
|
+
@ar_object = fetch_ar_object(@model.ar_model.name.classify.constantize, params[:id])
|
78
78
|
redirect_url = request.referrer || cm_admin.send("#{@model.name.underscore}_index_path")
|
79
79
|
respond_to do |format|
|
80
80
|
if @ar_object.destroy
|
@@ -185,7 +185,7 @@ module CmAdmin
|
|
185
185
|
@ar_object, @associated_model, @associated_ar_object = custom_controller_action(action_name, params.permit!) if !@ar_object.present? && params[:id].present?
|
186
186
|
authorize @ar_object, policy_class: "CmAdmin::#{controller_name.classify}Policy".constantize if defined? "CmAdmin::#{controller_name.classify}Policy".constantize
|
187
187
|
aar_model = request.url.split('/')[-2].classify.constantize if params[:aar_id]
|
188
|
-
@associated_ar_object = aar_model
|
188
|
+
@associated_ar_object = fetch_ar_object(aar_model, params[:aar_id]) if params[:aar_id]
|
189
189
|
nested_fields = get_nested_table_fields(@model.available_fields[:new])
|
190
190
|
nested_fields += get_nested_table_fields(@model.available_fields[:edit])
|
191
191
|
@reflections = @model.ar_model.reflect_on_all_associations
|
@@ -202,12 +202,12 @@ module CmAdmin
|
|
202
202
|
|
203
203
|
def resource_responder
|
204
204
|
respond_to do |format|
|
205
|
-
if params["referrer"]
|
206
|
-
redirect_url = params["referrer"]
|
207
|
-
else
|
208
|
-
redirect_url = CmAdmin::Engine.mount_path + "/#{@model.name.underscore.pluralize}/#{@ar_object.id}"
|
209
|
-
end
|
210
205
|
if @ar_object.save
|
206
|
+
redirect_url = if params['referrer']
|
207
|
+
params['referrer']
|
208
|
+
else
|
209
|
+
cm_admin.send("#{@model.name.underscore}_show_path", @ar_object)
|
210
|
+
end
|
211
211
|
if params['attachment_destroy_ids'].present?
|
212
212
|
ActiveStorage::Attachment.where(id: params['attachment_destroy_ids']).destroy_all
|
213
213
|
end
|
@@ -222,7 +222,7 @@ module CmAdmin
|
|
222
222
|
@current_action = CmAdmin::Models::Action.find_by(@model, name: action_name.to_s)
|
223
223
|
return unless @current_action
|
224
224
|
|
225
|
-
@ar_object = @model.ar_model.name.classify.constantize
|
225
|
+
@ar_object = fetch_ar_object(@model.ar_model.name.classify.constantize, params[:id])
|
226
226
|
return @ar_object unless @current_action.child_records
|
227
227
|
|
228
228
|
child_records = @ar_object.send(@current_action.child_records)
|
@@ -353,7 +353,10 @@ module CmAdmin
|
|
353
353
|
params.require(@model.name.underscore.to_sym).permit(*permittable_fields)
|
354
354
|
end
|
355
355
|
|
356
|
-
|
356
|
+
def fetch_ar_object(model_object, id)
|
357
|
+
return model_object.friendly.find(id) if model_object.respond_to?(:friendly)
|
357
358
|
|
359
|
+
model_object.find(id)
|
360
|
+
end
|
358
361
|
end
|
359
362
|
end
|
@@ -11,9 +11,9 @@
|
|
11
11
|
.popup-card.table-export-popup.hidden
|
12
12
|
- if edit_action.present?
|
13
13
|
- if @associated_model
|
14
|
-
- path = cm_admin.send("#{current_model.name.underscore}_edit_path", ar_object
|
14
|
+
- path = cm_admin.send("#{current_model.name.underscore}_edit_path", ar_object, referrer: request.path)
|
15
15
|
- else
|
16
|
-
- path = cm_admin.send("#{current_model.name.underscore}_edit_path", ar_object
|
16
|
+
- path = cm_admin.send("#{current_model.name.underscore}_edit_path", ar_object)
|
17
17
|
= link_to path do
|
18
18
|
.popup-option
|
19
19
|
span
|
@@ -21,13 +21,13 @@
|
|
21
21
|
| Edit
|
22
22
|
- if destroy_action.present?
|
23
23
|
- if @associated_model
|
24
|
-
= button_to cm_admin.send("#{current_model.name.underscore}_destroy_path", ar_object
|
24
|
+
= button_to cm_admin.send("#{current_model.name.underscore}_destroy_path", ar_object, referrer: request.path), method: :delete, form: { data: { turbo_confirm: 'Are you sure?' } } do
|
25
25
|
.popup-option
|
26
26
|
span
|
27
27
|
i.fa.fa-trash
|
28
28
|
| Destroy
|
29
29
|
- else
|
30
|
-
= link_to '', data: { bs_toggle: 'modal', bs_target: "##{@model.name.classify}DestroyModal-#{ar_object.id.to_s}" } do
|
30
|
+
= link_to '', data: { bs_toggle: 'modal', bs_target: "##{@model.name.classify}DestroyModal-#{ar_object.id.to_s}" } do
|
31
31
|
.popup-option
|
32
32
|
span
|
33
33
|
i.fa.fa-trash
|
@@ -45,7 +45,7 @@
|
|
45
45
|
- if column.display_if.call(Current.user) && column.viewable
|
46
46
|
td.text-ellipsis data-field-type="#{column.field_type || 'string'}"
|
47
47
|
- if index == 0 && is_show_action_available(@model, ar_object) && !([:link, :custom, :attachment, :drawer, :image].include?(column.field_type))
|
48
|
-
= link_to ar_object.send(column.field_name), cm_admin.send("#{ar_object.model_name.singular}_show_path", ar_object
|
48
|
+
= link_to ar_object.send(column.field_name), cm_admin.send("#{ar_object.model_name.singular}_show_path", ar_object)
|
49
49
|
- else
|
50
50
|
= show_field_value(ar_object, column)
|
51
51
|
- if column.field_type == :drawer
|
@@ -5,10 +5,10 @@ ul.tabs
|
|
5
5
|
li.nav-item
|
6
6
|
- nav_item_action_name = nav_item.custom_action.present? ? nav_item.custom_action : 'show'
|
7
7
|
- if via_xhr
|
8
|
-
= link_to tab_display_name(nav_item.nav_item_name), cm_admin.send("#{@ar_object.model_name.singular}_#{nav_item_action_name}_path", @ar_object
|
8
|
+
= link_to tab_display_name(nav_item.nav_item_name), cm_admin.send("#{@ar_object.model_name.singular}_#{nav_item_action_name}_path", @ar_object), class: "nav-link #{ nav_item_action_name == action_name ? 'active' : ''}", target: '_blank'
|
9
9
|
- else
|
10
|
-
= link_to tab_display_name(nav_item.nav_item_name), cm_admin.send("#{@ar_object.model_name.singular}_#{nav_item_action_name}_path", @ar_object
|
10
|
+
= link_to tab_display_name(nav_item.nav_item_name), cm_admin.send("#{@ar_object.model_name.singular}_#{nav_item_action_name}_path", @ar_object), class: "nav-link #{ nav_item_action_name == action_name ? 'active' : ''}"
|
11
11
|
// current_action_name is defined when action trail is added to that model
|
12
12
|
- if policy([:cm_admin, @model.name.classify.constantize]).send(:history?)
|
13
13
|
li.nav-item
|
14
|
-
= link_to 'History', cm_admin.send("#{@ar_object.model_name.singular}_history_path", @ar_object
|
14
|
+
= link_to 'History', cm_admin.send("#{@ar_object.model_name.singular}_history_path", @ar_object), class: "nav-link #{ action_name == 'history' ? 'active' : ''}"
|
@@ -1,16 +1,15 @@
|
|
1
|
-
.modal.fade id="#{@model.name.classify}DestroyModal-#{ar_object.id}" aria-hidden="true" aria-labelledby="#{@model.name.classify}DestroyModalLabel" tabindex="1"
|
1
|
+
.modal.fade id="#{@model.name.classify}DestroyModal-#{ar_object.id}" aria-hidden="true" aria-labelledby="#{@model.name.classify}DestroyModalLabel" tabindex="1"
|
2
2
|
.modal-dialog
|
3
3
|
.modal-content
|
4
4
|
.modal-header
|
5
5
|
h5.modal-title id="#{@model.name.classify}DestroyModalLabel" = "#{@model.name.classify} Destroy"
|
6
|
-
button.btn-close aria-label="Close" data-bs-dismiss="modal" type="button"
|
6
|
+
button.btn-close aria-label="Close" data-bs-dismiss="modal" type="button"
|
7
7
|
.modal-body
|
8
8
|
.custom-modal-body
|
9
9
|
.modal-info data-section="bulk-action"
|
10
10
|
| Are you sure you want to delete this #{@model.name.classify}
|
11
11
|
.modal-footer
|
12
|
-
= button_to cm_admin.send("#{@model.name.underscore}_destroy_path", ar_object
|
12
|
+
= button_to cm_admin.send("#{@model.name.underscore}_destroy_path", ar_object), method: :delete, class: "btn btn-primary" do
|
13
13
|
span
|
14
14
|
i.fa.fa-trash
|
15
|
-
| Destroy
|
16
|
-
|
15
|
+
| Destroy
|
data/lib/cm_admin/version.rb
CHANGED
@@ -102,9 +102,9 @@ module CmAdmin
|
|
102
102
|
if field.association_type.to_s == 'polymorphic'
|
103
103
|
association_name = ar_object.send(field.association_name).class.to_s.underscore
|
104
104
|
field_name = find_field_name(field, association_name)
|
105
|
-
link_to ar_object.send(field.association_name).send(field_name), cm_admin.send("#{association_name}_show_path", ar_object.send(field.association_name)
|
105
|
+
link_to ar_object.send(field.association_name).send(field_name), cm_admin.send("#{association_name}_show_path", ar_object.send(field.association_name))
|
106
106
|
elsif ['belongs_to', 'has_one'].include? field.association_type.to_s
|
107
|
-
link_to ar_object.send(field.association_name).send(field.field_name), cm_admin.send("#{field.association_name}_show_path", ar_object.send(field.association_name)
|
107
|
+
link_to ar_object.send(field.association_name).send(field.field_name), cm_admin.send("#{field.association_name}_show_path", ar_object.send(field.association_name))
|
108
108
|
end
|
109
109
|
end
|
110
110
|
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.
|
4
|
+
version: 1.4.6
|
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-
|
13
|
+
date: 2024-03-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: caxlsx_rails
|
@@ -498,7 +498,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
498
498
|
- !ruby/object:Gem::Version
|
499
499
|
version: '0'
|
500
500
|
requirements: []
|
501
|
-
rubygems_version: 3.
|
501
|
+
rubygems_version: 3.5.4
|
502
502
|
signing_key:
|
503
503
|
specification_version: 4
|
504
504
|
summary: CmAdmin is a robust gem designed to assist in creating admin panels for Rails
|