1- # ActiveAdminSidebar
1+ # ActiveAdmin Sidebar
22
3- Provides ability to manipulate sidebar position with activeadmin (tested with activeadmin ~ > 1.0.0.pre )
3+ Provides ability to manipulate sidebar position for ActiveAdmin (tested with ActiveAdmin ~ > 1.0.0)
44
5+ ## Install
56
6- Add including of css file
7+ ``` ruby
8+ gem ' active_admin_sidebar'
9+ # or latest from GitHub
10+ gem ' active_admin_sidebar' , git: ' https://github.com/activeadmin-plugins/active_admin_sidebar.git'
11+ ```
12+
13+ Add including of CSS file
714
815``` scss
9- @import " active_admin_sidebar" ;
16+ @import " active_admin_sidebar" ;
1017```
1118
1219to the
13- ```
14- app/assets/stylesheets/active_admin.css.scss
20+ ```
21+ app/assets/stylesheets/active_admin.css.scss
1522```
1623
1724And including of coffee file (optional, need only for collapsed sidebar)
1825
19- ``` js
20- // = require active_admin_sidebar
26+ ``` coffeescript
27+ # = require active_admin_sidebar
2128```
2229
2330to the
24- ```
31+
32+ ``` scss
2533app/assets/javascripts/active_admin.js
2634```
2735
28- Changing sidebar position dynamically with before_filter
36+ # Configuration per resource
37+
38+ Changing sidebar position dynamically with before_action
39+
2940``` ruby
3041 # app/admin/posts.rb
3142 ActiveAdmin .register Post do
32- before_filter :left_sidebar! , only: [:show ]
43+ before_action :left_sidebar! , only: [:show ]
3344 end
3445
3546 # app/admin/comments.rb
3647 ActiveAdmin .register Comment do
37- before_filter :right_sidebar!
48+ before_action :right_sidebar!
3849 end
3950```
4051
52+ ## Global configuration
4153
42- Moving sidebar to the left within all resource ( config/initializers/active_admin.rb)
54+ Moving sidebar to the left within all resource. Set configuration in ` config/initializers/active_admin.rb `
4355
4456``` ruby
45- # == Controller Filters
57+ # == Controller before-actions
4658 #
47- # You can add before, after and around filters to all of your
48- # Active Admin resources from here.
49- #
50- config.before_filter do
51- left_sidebar! if respond_to?( :left_sidebar! )
52- end
59+ # You can add before, after and around actions to all of your resources
60+ ActiveAdmin .setup do | config |
61+ config.before_action do
62+ left_sidebar! if respond_to?( :left_sidebar! )
63+ end
64+ end
5365```
5466
55- Also you can use sidebar collapsing. It will add css icon in title of first sidebar will save current state in session
67+ ## Collapsing sidebar
68+
69+ You can use sidebar collapsing.
70+ It will add "hide/show" button. Shown/Hidden state is persisted across all pages.
71+
5672``` ruby
5773 left_sidebar!(collapsed: true )
5874```
59- You can override button color according to your color theme:
60- ``` css
75+
76+ You can override button color according to your color theme. For example:
77+
78+ ``` scss
6179 body .active_admin {
6280 #active_admin_content .left_sidebar , #active_admin_content .collapsed_sidebar {
6381 .collapse_btn , .uncollapse_btn {
@@ -70,8 +88,3 @@ You can override button color according to your color theme:
7088Example
7189
7290![ Alt text] ( https://raw.githubusercontent.com/activeadmin-plugins/active_admin_sidebar/master/screen/sidebar.jpg " Example ")
73-
74-
75-
76-
77-
0 commit comments