cm-admin 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/views/cm_admin/main/_table.html.slim +1 -1
- data/app/views/cm_admin/main/_tabs.html.slim +1 -1
- data/app/views/cm_admin/main/_top_navbar.html.slim +6 -12
- data/config/routes.rb +1 -1
- data/lib/cm_admin/version.rb +1 -1
- data/lib/cm_admin/view_helpers/page_info_helper.rb +25 -0
- data/lib/generators/cm_admin/install_generator.rb +2 -2
- data/yarn.lock +3 -3
- 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: dcd2e766f902e8045d4eba1ae60067d6636477625f6a51a7ce896c0e446ad8bc
|
4
|
+
data.tar.gz: d1ef041f20245116d4dafc04629b75768245a77b0f042e038675516e60692206
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e152f94b559e7f12d9d0d6cb82688d293c6a799fe0ade4b503c0dc2e8edc0337864741b7a7ae50e8ddcd7e175cc1813125f0409b5f62880fac3c386cae30638
|
7
|
+
data.tar.gz: d7b610b2ff1f329a09d3a31564f7f0d35bd5799803bcbdd31f15faad311803e516b6b828037524161993d139fabed9b08ef508cb2214a7dae6f2b74cb834dd32
|
@@ -49,7 +49,7 @@
|
|
49
49
|
- custom_actions.each do |custom_action|
|
50
50
|
- if custom_action.name.present? && has_valid_policy(@model.name, custom_action.name)
|
51
51
|
- if custom_action.display_if.call(ar_object)
|
52
|
-
= link_to custom_action.path.gsub(':id', ar_object.id.to_s), method: custom_action.verb do
|
52
|
+
= link_to cm_admin.send("#{@model.name.downcase}_index_path") + '/' + custom_action.path.gsub(':id', ar_object.id.to_s), method: custom_action.verb do
|
53
53
|
.popup-option = custom_action.name.titleize
|
54
54
|
|
55
55
|
.cm-pagination
|
@@ -1,6 +1,6 @@
|
|
1
1
|
ul.nav.nav-pills
|
2
2
|
- @model.available_tabs.each do |nav_item|
|
3
|
-
- if nav_item.custom_action.present? && policy([:cm_admin, @model.name.classify.constantize]).send(:"#{nav_item.custom_action}?")
|
3
|
+
- if nav_item.custom_action.empty? || (nav_item.custom_action.present? && policy([:cm_admin, @model.name.classify.constantize]).send(:"#{nav_item.custom_action}?"))
|
4
4
|
li.nav-item
|
5
5
|
- nav_item_action_name = nav_item.custom_action.present? ? nav_item.custom_action : 'show'
|
6
6
|
= link_to nav_item.nav_item_name.to_s.titleize, "/cm_admin/#{@model.name.underscore.pluralize}/#{@ar_object.id}/#{nav_item.custom_action}", class: "nav-link #{ nav_item_action_name == action_name ? 'active' : ''}"
|
@@ -1,7 +1,9 @@
|
|
1
1
|
.cm-navbar
|
2
2
|
.cm-navbar__lhs
|
3
|
-
.
|
4
|
-
|
3
|
+
- if cm_admin.method_defined?(:"#{@model.name.downcase}_index_path") && (@model.current_action.name == 'show' || @model.current_action.layout_type.present?)
|
4
|
+
.bread-crumb-area
|
5
|
+
.breadcrumb-text
|
6
|
+
= link_to @model.name + ' /', cm_admin.send(:"#{@model.name.downcase}_index_path")
|
5
7
|
.nav-title-area
|
6
8
|
p.title-text = action_title
|
7
9
|
p.title-sub-text = action_description
|
@@ -24,18 +26,10 @@
|
|
24
26
|
- if new_action.any? && policy([:cm_admin, @model.name.classify.constantize]).new?
|
25
27
|
= link_to 'Add', "#{page_url('new')}", class: 'primary-btn ml-2'
|
26
28
|
- @model.available_actions.select{|act| act if act.route_type == 'collection'}.each do |custom_action|
|
27
|
-
|
28
|
-
- if custom_action.display_type == :button
|
29
|
-
= link_to custom_action.name.titleize, @model.ar_model.table_name + '/' + custom_action.path, class: 'primary-btn ml-2', method: custom_action.verb
|
30
|
-
- elsif custom_action.display_type == :modal
|
31
|
-
= link_to custom_action.name.titleize, '', class: 'primary-btn ml-2', data: { bs_toggle: "modal", bs_target: "##{custom_action.name.classify}Modal" }
|
29
|
+
= custom_action_items(custom_action, 'index')
|
32
30
|
- elsif @model.current_action.name == 'show'
|
33
31
|
- @model.available_actions.select{|act| act if act.route_type == 'member'}.each do |custom_action|
|
34
|
-
|
35
|
-
- if custom_action.display_type == :button && custom_action.display_if.call(@ar_object)
|
36
|
-
= link_to custom_action.name.titleize, custom_action.path.gsub(':id', params[:id]), class: 'primary-btn ml-2', method: custom_action.verb
|
37
|
-
- elsif custom_action.display_type == :modal && custom_action.display_if.call(@ar_object)
|
38
|
-
= link_to custom_action.name.titleize, '', class: 'primary-btn ml-2', data: { bs_toggle: "modal", bs_target: "##{custom_action.name.classify}Modal" }
|
32
|
+
= custom_action_items(custom_action, 'show')
|
39
33
|
|
40
34
|
- edit_action = @model.available_actions.select{|act| act if act.action_type.eql?(:default) && act.name.eql?('edit')}
|
41
35
|
- if edit_action.any? && policy([:cm_admin, @model.name.classify.constantize]).edit?
|
data/config/routes.rb
CHANGED
@@ -10,7 +10,7 @@ CmAdmin::Engine.routes.draw do
|
|
10
10
|
|
11
11
|
# Defining action routes for each model
|
12
12
|
CmAdmin.config.cm_admin_models.each do |model|
|
13
|
-
model.available_actions.sort_by {|act| act.
|
13
|
+
model.available_actions.sort_by {|act| act.name}.each do |act|
|
14
14
|
scope model.name.tableize do
|
15
15
|
send(act.verb, act.path.present? ? act.path : act.name, to: "#{model.name.underscore}##{act.name}", as: "#{model.name.underscore}_#{act.name}")
|
16
16
|
end
|
data/lib/cm_admin/version.rb
CHANGED
@@ -53,6 +53,31 @@ module CmAdmin
|
|
53
53
|
base_path + "/#{ar_object.id}" + '/edit'
|
54
54
|
end
|
55
55
|
end
|
56
|
+
|
57
|
+
def custom_action_items(custom_action, current_action_name)
|
58
|
+
if custom_action.name.present? && policy([:cm_admin, @model.name.classify.constantize]).send(:"#{custom_action.name}?")
|
59
|
+
if custom_action.display_if.call(@ar_object)
|
60
|
+
case custom_action.display_type
|
61
|
+
when :button
|
62
|
+
custom_action_button(custom_action, current_action_name)
|
63
|
+
when :modal
|
64
|
+
custom_modal_button(custom_action)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def custom_action_button(custom_action, current_action_name)
|
71
|
+
if current_action_name == "index"
|
72
|
+
link_to custom_action.name.titleize, @model.ar_model.table_name + '/' + custom_action.path, class: 'secondary-btn ml-2', method: custom_action.verb
|
73
|
+
elsif current_action_name == "show"
|
74
|
+
link_to custom_action.name.titleize, custom_action.path.gsub(':id', params[:id]), class: 'secondary-btn ml-2', method: custom_action.verb
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def custom_modal_button(custom_action)
|
79
|
+
link_to custom_action.name.titleize, '', class: 'secondary-btn ml-2', data: { bs_toggle: "modal", bs_target: "##{custom_action.name.classify}Modal" }
|
80
|
+
end
|
56
81
|
end
|
57
82
|
end
|
58
83
|
end
|
@@ -7,8 +7,8 @@ module CmAdmin
|
|
7
7
|
|
8
8
|
def copy_initializer
|
9
9
|
copy_file 'cm_admin_initializer.rb', 'config/initializers/cm_admin.rb'
|
10
|
-
copy_file 'custom.js', 'app/assets/javascripts/custom.js'
|
11
|
-
copy_file 'custom.css', 'app/assets/stylesheets/custom.css'
|
10
|
+
copy_file 'custom.js', 'app/assets/javascripts/cm_admin/custom.js'
|
11
|
+
copy_file 'custom.css', 'app/assets/stylesheets/cm_admin/custom.css'
|
12
12
|
copy_file 'application_policy.rb', 'app/policies/application_policy.rb'
|
13
13
|
route 'mount CmAdmin::Engine => "/admin"'
|
14
14
|
end
|
data/yarn.lock
CHANGED
@@ -4123,9 +4123,9 @@ minimatch@^3.0.4:
|
|
4123
4123
|
brace-expansion "^1.1.7"
|
4124
4124
|
|
4125
4125
|
minimist@^1.2.0, minimist@^1.2.5:
|
4126
|
-
version "1.2.
|
4127
|
-
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.
|
4128
|
-
integrity sha512-
|
4126
|
+
version "1.2.6"
|
4127
|
+
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44"
|
4128
|
+
integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==
|
4129
4129
|
|
4130
4130
|
minipass-collect@^1.0.2:
|
4131
4131
|
version "1.0.2"
|
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: 0.6.
|
4
|
+
version: 0.6.3
|
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: 2022-04-
|
13
|
+
date: 2022-04-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: pagy
|