cm-admin 0.5.9 → 0.6.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: b0f2b3549e1dfc742d740ac99368efcd98d19fb70f490581568816a2eb88d238
4
- data.tar.gz: 515da90e85fdf498116babe7798decc32453d2667d95e9dc0eb74e1ab89c64db
3
+ metadata.gz: 79781db6dbcc1960715b78d50655f618144a805150a64072be3267cc1c79f110
4
+ data.tar.gz: 3cfa1956fe446d22cc275b5b0bf2b883a42b5c86136ebb4c0361058b3f73b96e
5
5
  SHA512:
6
- metadata.gz: 8630a7ce57b1b00ca9497d2f4209ee8d86df18304a44f5fbf6ee85c8f70eda19bd9d415abc4502793eeee9f93aa5d4c83630555ae46b1e456fffa45cd0e3d922
7
- data.tar.gz: 50c02b1132b2382e4adbdde2799c7f3104de07f95a421dbbe371e546424a62c3a000c4a487c494300f9bf5dc36ad7ec317cbeb2d0187802c565f1fac23321900
6
+ metadata.gz: 209bd560223da704b275c9473ccf7b59f0ac074b39f3cfc6b01e37c56c1599209a551de4668c8614a7f98d6e9cbeef0043a51a3108b2d85a462289ae7e0f48c0
7
+ data.tar.gz: 46f11879d4b8fcb8fe0033c79397e4922a4714c18ae496c96962d949e344dd512af4250d4f4641e697f89465d7ad2a00bc36485a4de8b0291c6a812eb5d8e7b3
@@ -43,13 +43,14 @@
43
43
  span
44
44
  i.fa.fa-angle-down
45
45
  .popup-card.table-export-popup.hidden
46
- - if edit_action.any?
46
+ - if edit_action.any? && policy([:cm_admin, @model.name.classify.constantize]).edit?
47
47
  = link_to "#{page_url('edit', ar_object)}" do
48
48
  .popup-option Edit
49
49
  - custom_actions.each do |custom_action|
50
- - if custom_action.display_if.call(ar_object)
51
- = link_to custom_action.path.gsub(':id', ar_object.id.to_s), method: custom_action.verb do
52
- .popup-option = custom_action.name.titleize
50
+ - if custom_action.name.present? && policy([:cm_admin, @model.name.classify.constantize]).send(:"#{custom_action.name}?")
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
53
+ .popup-option = custom_action.name.titleize
53
54
 
54
55
  .cm-pagination
55
56
  .cm-pagination__lhs Showing #{@ar_object.pagy.from} to #{@ar_object.pagy.to} out of #{@ar_object.pagy.count}
@@ -21,20 +21,22 @@
21
21
  .popup-option.pointer data-bs-toggle='modal' data-bs-target='#exportmodal'
22
22
  span Export
23
23
  - new_action = @model.available_actions.select{|act| act if act.action_type.eql?(:default) && act.name.eql?('new')}
24
- - if new_action.any?
24
+ - if new_action.any? && policy([:cm_admin, @model.name.classify.constantize]).new?
25
25
  = link_to 'Add', "#{page_url('new')}", class: 'primary-btn ml-2'
26
26
  - @model.available_actions.select{|act| act if act.route_type == 'collection'}.each do |custom_action|
27
- - if custom_action.display_type == :button
28
- = link_to custom_action.name.titleize, @model.ar_model.table_name + '/' + custom_action.path, class: 'primary-btn ml-2', method: custom_action.verb
29
- - elsif custom_action.display_type == :modal
30
- = link_to custom_action.name.titleize, '', class: 'primary-btn ml-2', data: { bs_toggle: "modal", bs_target: "##{custom_action.name.classify}Modal" }
27
+ - if custom_action.name.present? && policy([:cm_admin, @model.name.classify.constantize]).send(:"#{custom_action.name}?")
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" }
31
32
  - elsif @model.current_action.name == 'show'
32
33
  - @model.available_actions.select{|act| act if act.route_type == 'member'}.each do |custom_action|
33
- - if custom_action.display_type == :button && custom_action.display_if.call(@ar_object)
34
- = link_to custom_action.name.titleize, custom_action.path.gsub(':id', params[:id]), class: 'primary-btn ml-2', method: custom_action.verb
35
- - elsif custom_action.display_type == :modal && custom_action.display_if.call(@ar_object)
36
- = link_to custom_action.name.titleize, '', class: 'primary-btn ml-2', data: { bs_toggle: "modal", bs_target: "##{custom_action.name.classify}Modal" }
34
+ - if custom_action.name.present? && policy([:cm_admin, @model.name.classify.constantize]).send(:"#{custom_action.name}?")
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" }
37
39
 
38
40
  - edit_action = @model.available_actions.select{|act| act if act.action_type.eql?(:default) && act.name.eql?('edit')}
39
- - if edit_action.any?
41
+ - if edit_action.any? && policy([:cm_admin, @model.name.classify.constantize]).edit?
40
42
  = link_to "Edit #{@model.name}", "#{page_url('edit', @ar_object)}", class: 'primary-btn ml-2'
@@ -1,3 +1,3 @@
1
1
  module CmAdmin
2
- VERSION = "0.5.9"
2
+ VERSION = "0.6.0"
3
3
  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: 0.5.9
4
+ version: 0.6.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: 2022-03-24 00:00:00.000000000 Z
13
+ date: 2022-03-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: pagy