Skip to content
This repository
Newer
Older
100644 137 lines (114 sloc) 3.954 kb
bdc85cb4 » bbenezech
2012-02-20 changed RailsAdmin.config(abstract_model) => abstract_model.config
1 require 'rails_admin/config/proxyable'
2 require 'rails_admin/config/configurable'
11028c41 » bbenezech
2012-01-06 actions refactoring stub [ci skip]
3 require 'rails_admin/config/hideable'
4
5 module RailsAdmin
6 module Config
7 module Actions
bdc85cb4 » bbenezech
2012-02-20 changed RailsAdmin.config(abstract_model) => abstract_model.config
8 class Base
9 include RailsAdmin::Config::Proxyable
10 include RailsAdmin::Config::Configurable
11028c41 » bbenezech
2012-01-06 actions refactoring stub [ci skip]
11 include RailsAdmin::Config::Hideable
0b31d902 »
2012-11-05 Cleanup trailing whitespace
12
710715e2 » bbenezech
2012-09-10 add Actions::Base#only
13 register_instance_option :only do
14 nil
15 end
d3b313dc »
2012-02-23 Cleanup trailing whitespace
16
0b6e2fa9 » bbenezech
2012-09-10 added Actions::Base#except, fixed specs
17 register_instance_option :except do
18 []
19 end
20
383d24f2 » nfedyashev
2014-05-25 Fix Twitter Bootstrap reference URLs
21 # http://getbootstrap.com/2.3.2/base-css.html#icons
b9f78d14 » bbenezech
2012-02-07 add icons, fix history rendering
22 register_instance_option :link_icon do
23 'icon-question-sign'
24 end
d3b313dc »
2012-02-23 Cleanup trailing whitespace
25
94896f06 » bbenezech
2012-01-19 refactored helpers
26 # Should the action be visible
27 register_instance_option :visible? do
929a7db5 » bbenezech
2012-09-18 refactor authorized/visible to make authorized easier to reuse in vis…
28 authorized?
29 end
30
31 register_instance_option :authorized? do
32 (
03431bcb »
2014-02-02 Autocorrect all autocorrectable offenses
33 bindings[:controller].nil? || bindings[:controller].authorized?(authorization_key, bindings[:abstract_model], bindings[:object])
34 ) && (
35 bindings[:abstract_model].nil? || (
36 (only.nil? || [only].flatten.collect(&:to_s).include?(bindings[:abstract_model].to_s)) &&
37 ![except].flatten.collect(&:to_s).include?(bindings[:abstract_model].to_s) &&
0b6e2fa9 » bbenezech
2012-09-10 added Actions::Base#except, fixed specs
38 bindings[:abstract_model].config.with(bindings).visible?
39 ))
e63e4be9 » bbenezech
2012-02-03 refactor main navigation
40 end
d3b313dc »
2012-02-23 Cleanup trailing whitespace
41
36255185 » bbenezech
2012-01-17 actions API [ci skip]
42 # Is the action acting on the root level (Example: /admin/contact)
94896f06 » bbenezech
2012-01-19 refactored helpers
43 register_instance_option :root? do
ea263489 » bbenezech
2012-01-11 wip
44 false
45 end
d3b313dc »
2012-02-23 Cleanup trailing whitespace
46
e63e4be9 » bbenezech
2012-02-03 refactor main navigation
47 # Is the action on a model scope (Example: /admin/team/export)
94896f06 » bbenezech
2012-01-19 refactored helpers
48 register_instance_option :collection? do
ea263489 » bbenezech
2012-01-11 wip
49 false
50 end
d3b313dc »
2012-02-23 Cleanup trailing whitespace
51
e63e4be9 » bbenezech
2012-02-03 refactor main navigation
52 # Is the action on an object scope (Example: /admin/team/1/edit)
94896f06 » bbenezech
2012-01-19 refactored helpers
53 register_instance_option :member? do
ea263489 » bbenezech
2012-01-11 wip
54 false
55 end
d3b313dc »
2012-02-23 Cleanup trailing whitespace
56
9a7f17c0 » stympy
2012-08-25 Added a configurable option for pjax
57 # Render via pjax?
58 register_instance_option :pjax? do
59 true
60 end
61
36255185 » bbenezech
2012-01-17 actions API [ci skip]
62 # This block is evaluated in the context of the controller when action is called
63 # You can access:
1d19bf5d » bbenezech
2012-02-21 root and parent don't belong to Configurable
64 # - @objects if you're on a model scope
65 # - @abstract_model & @model_config if you're on a model or object scope
36255185 » bbenezech
2012-01-17 actions API [ci skip]
66 # - @object if you're on an object scope
11028c41 » bbenezech
2012-01-06 actions refactoring stub [ci skip]
67 register_instance_option :controller do
03431bcb »
2014-02-02 Autocorrect all autocorrectable offenses
68 proc do
69 render action: @action.template_name
ea263489 » bbenezech
2012-01-11 wip
70 end
11028c41 » bbenezech
2012-01-06 actions refactoring stub [ci skip]
71 end
d3b313dc »
2012-02-23 Cleanup trailing whitespace
72
36255185 » bbenezech
2012-01-17 actions API [ci skip]
73 # Model scoped actions only. You will need to handle params[:bulk_ids] in controller
11c6ca14 » bbenezech
2012-01-12 wip. tests pass.
74 register_instance_option :bulkable? do
75 false
76 end
d3b313dc »
2012-02-23 Cleanup trailing whitespace
77
36255185 » bbenezech
2012-01-17 actions API [ci skip]
78 # View partial name (called in default :controller block)
11028c41 » bbenezech
2012-01-06 actions refactoring stub [ci skip]
79 register_instance_option :template_name do
ea263489 » bbenezech
2012-01-11 wip
80 key.to_sym
11028c41 » bbenezech
2012-01-06 actions refactoring stub [ci skip]
81 end
d3b313dc »
2012-02-23 Cleanup trailing whitespace
82
36255185 » bbenezech
2012-01-17 actions API [ci skip]
83 # For Cancan and the like
ea263489 » bbenezech
2012-01-11 wip
84 register_instance_option :authorization_key do
85 key.to_sym
11028c41 » bbenezech
2012-01-06 actions refactoring stub [ci skip]
86 end
d3b313dc »
2012-02-23 Cleanup trailing whitespace
87
36255185 » bbenezech
2012-01-17 actions API [ci skip]
88 # List of methods allowed. Note that you are responsible for correctly handling them in :controller block
ea263489 » bbenezech
2012-01-11 wip
89 register_instance_option :http_methods do
11028c41 » bbenezech
2012-01-06 actions refactoring stub [ci skip]
90 [:get]
91 end
d3b313dc »
2012-02-23 Cleanup trailing whitespace
92
36255185 » bbenezech
2012-01-17 actions API [ci skip]
93 # Url fragment
ea263489 » bbenezech
2012-01-11 wip
94 register_instance_option :route_fragment do
95 custom_key.to_s
96 end
d3b313dc »
2012-02-23 Cleanup trailing whitespace
97
36255185 » bbenezech
2012-01-17 actions API [ci skip]
98 # Controller action name
ea263489 » bbenezech
2012-01-11 wip
99 register_instance_option :action_name do
100 custom_key.to_sym
11028c41 » bbenezech
2012-01-06 actions refactoring stub [ci skip]
101 end
d3b313dc »
2012-02-23 Cleanup trailing whitespace
102
36255185 » bbenezech
2012-01-17 actions API [ci skip]
103 # I18n key
50c33eff » bbenezech
2012-01-13 wip
104 register_instance_option :i18n_key do
105 key
106 end
d3b313dc »
2012-02-23 Cleanup trailing whitespace
107
36255185 » bbenezech
2012-01-17 actions API [ci skip]
108 # User should override only custom_key (action name and route fragment change, allows for duplicate actions)
ea263489 » bbenezech
2012-01-11 wip
109 register_instance_option :custom_key do
11028c41 » bbenezech
2012-01-06 actions refactoring stub [ci skip]
110 key
111 end
d3b313dc »
2012-02-23 Cleanup trailing whitespace
112
36255185 » bbenezech
2012-01-17 actions API [ci skip]
113 # Breadcrumb parent
843e0b02 » bbenezech
2012-01-12 dynamic breadcrumb
114 register_instance_option :breadcrumb_parent do
e63e4be9 » bbenezech
2012-02-03 refactor main navigation
115 case
94896f06 » bbenezech
2012-01-19 refactored helpers
116 when root?
e63e4be9 » bbenezech
2012-02-03 refactor main navigation
117 [:dashboard]
94896f06 » bbenezech
2012-01-19 refactored helpers
118 when collection?
e63e4be9 » bbenezech
2012-02-03 refactor main navigation
119 [:index, bindings[:abstract_model]]
94896f06 » bbenezech
2012-01-19 refactored helpers
120 when member?
e63e4be9 » bbenezech
2012-02-03 refactor main navigation
121 [:show, bindings[:abstract_model], bindings[:object]]
843e0b02 » bbenezech
2012-01-12 dynamic breadcrumb
122 end
123 end
d3b313dc »
2012-02-23 Cleanup trailing whitespace
124
36255185 » bbenezech
2012-01-17 actions API [ci skip]
125 # Off API.
d3b313dc »
2012-02-23 Cleanup trailing whitespace
126
11c6ca14 » bbenezech
2012-01-12 wip. tests pass.
127 def key
ea263489 » bbenezech
2012-01-11 wip
128 self.class.key
129 end
d3b313dc »
2012-02-23 Cleanup trailing whitespace
130
11028c41 » bbenezech
2012-01-06 actions refactoring stub [ci skip]
131 def self.key
03431bcb »
2014-02-02 Autocorrect all autocorrectable offenses
132 name.to_s.demodulize.underscore.to_sym
11028c41 » bbenezech
2012-01-06 actions refactoring stub [ci skip]
133 end
134 end
135 end
136 end
137 end
Something went wrong with that request. Please try again.