active_admin_sidebar 0.1.0.rc2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +23 -0
- data/Gemfile +16 -2
- data/README.md +81 -0
- data/Rakefile +7 -1
- data/app/assets/javascripts/active_admin_sidebar.js +29 -0
- data/app/assets/stylesheets/active_admin_sidebar.scss +91 -0
- data/app/assets/stylesheets/active_admin_sidebar_pure_icons.scss +66 -0
- data/lib/active_admin_sidebar.rb +4 -6
- data/lib/active_admin_sidebar/activeadmin_views_pages_base.rb +33 -18
- data/lib/active_admin_sidebar/positions.rb +21 -3
- data/lib/active_admin_sidebar/version.rb +1 -1
- data/screen/sidebar.jpg +0 -0
- data/spec/sidebars_spec.rb +53 -0
- data/spec/spec_helper.rb +50 -0
- data/spec/support/admin.rb +21 -0
- data/spec/support/capybara.rb +13 -0
- data/spec/support/rails_template.rb +49 -0
- data/tasks/test.rake +15 -0
- metadata +27 -12
- data/README.rdoc +0 -53
- data/app/assets/stylesheets/active_admin_sidebar.css.scss +0 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cf32ccf4b0aa40e39121ac1fd4b207fbc5b169cc1f3b7ea8b9ea8412ed8ab58e
|
4
|
+
data.tar.gz: d2d59d557d0849aec9546c0ecd14f4c2d4bbf4845e462d7cfd6c64f73c245736
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a74c0276007f4b2f77a70186bd588780e19283af299397b457e7b78363b7cdff70bbd24ef8d51936395521748b04f610eec774a76d0990ec8b489874af95438
|
7
|
+
data.tar.gz: 4f217901c2e5a781b433315ac9eb735347daea5a5611aa550bbfbb7048f4fb0b2989be0ed8e7debad0ee5d15c0762e626ecf01bb5936449343368018eea42bd5
|
data/.travis.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
sudo: required
|
2
|
+
|
3
|
+
language: ruby
|
4
|
+
|
5
|
+
addons:
|
6
|
+
chrome: stable
|
7
|
+
|
8
|
+
before_install:
|
9
|
+
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
|
10
|
+
- gem install bundler -v '< 2'
|
11
|
+
|
12
|
+
script: bundle exec rspec
|
13
|
+
|
14
|
+
env:
|
15
|
+
matrix:
|
16
|
+
- RAILS=5.1.6 AA=1.1.0
|
17
|
+
- RAILS=5.2.1 AA=1.4.0
|
18
|
+
- RAILS=5.2.2 AA=2.8.0
|
19
|
+
- RAILS=6.0.0 AA=2.8.0
|
20
|
+
|
21
|
+
rvm:
|
22
|
+
- 2.5
|
23
|
+
- 2.6
|
data/Gemfile
CHANGED
@@ -1,4 +1,18 @@
|
|
1
|
-
source
|
2
|
-
# Specify your gem's dependencies in active_admin_sidebar.gemspec
|
1
|
+
source 'https://rubygems.org'
|
3
2
|
|
3
|
+
# Specify your gem's dependencies in activeadmin_scoped_collection_actions.gemspec
|
4
4
|
gemspec
|
5
|
+
|
6
|
+
group :test do
|
7
|
+
gem 'rails', "~> #{ENV['RAILS'] || '5.2.1'}"
|
8
|
+
gem 'activeadmin', "~> #{ENV['AA'] || '1.3.1'}"
|
9
|
+
|
10
|
+
gem 'rspec-rails'
|
11
|
+
gem 'sqlite3'
|
12
|
+
gem 'database_cleaner'
|
13
|
+
gem 'capybara'
|
14
|
+
gem 'selenium-webdriver'
|
15
|
+
gem 'chromedriver-helper'
|
16
|
+
gem 'byebug'
|
17
|
+
gem 'sassc-rails'
|
18
|
+
end
|
data/README.md
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
# ActiveAdmin Sidebar
|
2
|
+
|
3
|
+
Provides ability to manipulate sidebar position for ActiveAdmin (tested with ActiveAdmin ~> 1.0.0)
|
4
|
+
|
5
|
+
## Install
|
6
|
+
|
7
|
+
Add following line to the `Gemfile`
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'active_admin_sidebar'
|
11
|
+
```
|
12
|
+
|
13
|
+
Add following line to the `app/assets/stylesheets/active_admin.css.scss`
|
14
|
+
|
15
|
+
```scss
|
16
|
+
@import "active_admin_sidebar";
|
17
|
+
```
|
18
|
+
|
19
|
+
If you want to use collapsing feature, add following line
|
20
|
+
|
21
|
+
```javascripts
|
22
|
+
//= require active_admin_sidebar
|
23
|
+
```
|
24
|
+
|
25
|
+
to the `app/assets/javascripts/active_admin.js`
|
26
|
+
|
27
|
+
# Configuration per resource
|
28
|
+
|
29
|
+
Changing sidebar position dynamically with before_action
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
# app/admin/posts.rb
|
33
|
+
ActiveAdmin.register Post do
|
34
|
+
before_action :left_sidebar!, only: [:show]
|
35
|
+
end
|
36
|
+
|
37
|
+
# app/admin/comments.rb
|
38
|
+
ActiveAdmin.register Comment do
|
39
|
+
before_action :right_sidebar!
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
## Global configuration
|
44
|
+
|
45
|
+
Moving sidebar to the left within all resource. Set configuration in `config/initializers/active_admin.rb`
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
# == Controller before-actions
|
49
|
+
#
|
50
|
+
# You can add before, after and around actions to all of your resources
|
51
|
+
ActiveAdmin.setup do |config|
|
52
|
+
config.before_action do
|
53
|
+
left_sidebar! if respond_to?(:left_sidebar!)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
```
|
57
|
+
|
58
|
+
## Collapsing sidebar
|
59
|
+
|
60
|
+
You can use sidebar collapsing.
|
61
|
+
It will add "hide/show" button. Shown/Hidden state is persisted across all pages.
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
left_sidebar!(collapsed: true)
|
65
|
+
```
|
66
|
+
|
67
|
+
You can override button color according to your color theme. For example:
|
68
|
+
|
69
|
+
```scss
|
70
|
+
body.active_admin {
|
71
|
+
#active_admin_content.left_sidebar, #active_admin_content.collapsed_sidebar {
|
72
|
+
.collapse_btn, .uncollapse_btn {
|
73
|
+
background-color: #767270;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
}
|
77
|
+
```
|
78
|
+
|
79
|
+
Example
|
80
|
+
|
81
|
+
![Alt text](https://raw.githubusercontent.com/activeadmin-plugins/active_admin_sidebar/master/screen/sidebar.jpg "Example")
|
data/Rakefile
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
(function() {
|
2
|
+
$(document).ready(function() {
|
3
|
+
var $aa_content, set_collapsed_sidebar;
|
4
|
+
if ($('body').hasClass('index') && ($('#active_admin_content').hasClass('collapsible_sidebar'))) {
|
5
|
+
$aa_content = $('#active_admin_content');
|
6
|
+
$aa_content.find('.sidebar_section:first>h3').append('<span class="collapse_btn icono-caret-left" title="Hide sidebar"></span>');
|
7
|
+
$aa_content.prepend('<span class="uncollapse_btn icono-caret-right" title="Show sidebar"></span>');
|
8
|
+
set_collapsed_sidebar = function(value) {
|
9
|
+
return $.getJSON(this.href, {
|
10
|
+
collapsed_sidebar: value
|
11
|
+
});
|
12
|
+
};
|
13
|
+
return $aa_content.on('click', '.collapse_btn, .uncollapse_btn', function(e) {
|
14
|
+
if (!$aa_content.hasClass('collapsed_sidebar')) {
|
15
|
+
set_collapsed_sidebar(true);
|
16
|
+
$aa_content.removeClass('left_sidebar');
|
17
|
+
$aa_content.addClass('collapsed_sidebar');
|
18
|
+
return $aa_content.trigger('collapsible_sidebar:collapsed');
|
19
|
+
} else {
|
20
|
+
set_collapsed_sidebar(false);
|
21
|
+
$aa_content.removeClass('collapsed_sidebar');
|
22
|
+
$aa_content.addClass('left_sidebar');
|
23
|
+
return $aa_content.trigger('collapsible_sidebar:uncollapsed');
|
24
|
+
}
|
25
|
+
});
|
26
|
+
}
|
27
|
+
});
|
28
|
+
|
29
|
+
}).call(this);
|
@@ -0,0 +1,91 @@
|
|
1
|
+
@import "active_admin_sidebar_pure_icons";
|
2
|
+
|
3
|
+
body.active_admin {
|
4
|
+
#active_admin_content.left_sidebar, #active_admin_content.collapsed_sidebar {
|
5
|
+
#sidebar {
|
6
|
+
display: block;
|
7
|
+
margin-left: 0;
|
8
|
+
}
|
9
|
+
|
10
|
+
.paginated_collection_contents {
|
11
|
+
clear: none;
|
12
|
+
float: left;
|
13
|
+
width: 100%;
|
14
|
+
}
|
15
|
+
|
16
|
+
.blank_slate_container {
|
17
|
+
clear: none;
|
18
|
+
}
|
19
|
+
|
20
|
+
.columns {
|
21
|
+
clear: none;
|
22
|
+
}
|
23
|
+
|
24
|
+
#main_content_wrapper {
|
25
|
+
float: inherit;
|
26
|
+
margin-left: 298px;
|
27
|
+
width: auto;
|
28
|
+
#main_content {
|
29
|
+
float: inherit;
|
30
|
+
margin: 0;
|
31
|
+
.tabs .comments {
|
32
|
+
.active_admin_comment {
|
33
|
+
clear: none;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
}
|
39
|
+
|
40
|
+
.table_tools:after {
|
41
|
+
clear: none;
|
42
|
+
padding-bottom: 16px;
|
43
|
+
}
|
44
|
+
|
45
|
+
.collapse_btn, .uncollapse_btn {
|
46
|
+
background-color: #767270;
|
47
|
+
border-radius: 5px;
|
48
|
+
color: #ffffff;
|
49
|
+
cursor: pointer;
|
50
|
+
}
|
51
|
+
|
52
|
+
.collapse_btn {
|
53
|
+
clear: both;
|
54
|
+
display: block;
|
55
|
+
float: right;
|
56
|
+
}
|
57
|
+
|
58
|
+
.uncollapse_btn {
|
59
|
+
display: none;
|
60
|
+
margin-top: 5px;
|
61
|
+
position: absolute;
|
62
|
+
}
|
63
|
+
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
body.active_admin #active_admin_content.collapsed_sidebar {
|
68
|
+
|
69
|
+
#main_content_wrapper {
|
70
|
+
margin-left: 30px;
|
71
|
+
}
|
72
|
+
|
73
|
+
#sidebar {
|
74
|
+
display: none;
|
75
|
+
}
|
76
|
+
|
77
|
+
.uncollapse_btn {
|
78
|
+
display: block;
|
79
|
+
}
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
body.active_admin.index #active_admin_content.with_sidebar.collapsible_sidebar {
|
84
|
+
#main_content_wrapper #main_content {
|
85
|
+
margin-right: 0;
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
.with_sidebar .comments .active_admin_comment {
|
90
|
+
overflow: auto;
|
91
|
+
}
|
@@ -0,0 +1,66 @@
|
|
1
|
+
/* .icono-caret-left */
|
2
|
+
.icono-caret-right, .icono-caret-left {
|
3
|
+
height: 19px;
|
4
|
+
width: 19px;
|
5
|
+
}
|
6
|
+
|
7
|
+
.icono-caret-right:before,
|
8
|
+
.icono-caret-right:after,
|
9
|
+
.icono-caret-left:before,
|
10
|
+
.icono-caret-left:after {
|
11
|
+
bottom: 1px;
|
12
|
+
box-shadow: inset 0 0 0 32px;
|
13
|
+
height: 2px;
|
14
|
+
margin: auto 0;
|
15
|
+
position: absolute;
|
16
|
+
right: 6px;
|
17
|
+
transform-origin: right;
|
18
|
+
width: 8px;
|
19
|
+
}
|
20
|
+
|
21
|
+
.icono-caret-right:before, .icono-caret-left:before {
|
22
|
+
top: 2px;
|
23
|
+
-moz-transform: rotate(45deg);
|
24
|
+
-ms-transform: rotate(45deg);
|
25
|
+
-o-transform: rotate(45deg);
|
26
|
+
-webkit-transform: rotate(45deg);
|
27
|
+
transform: rotate(45deg);
|
28
|
+
}
|
29
|
+
|
30
|
+
.icono-caret-right:after, .icono-caret-left:after {
|
31
|
+
top: 0;
|
32
|
+
-moz-transform: rotate(-45deg);
|
33
|
+
-ms-transform: rotate(-45deg);
|
34
|
+
-o-transform: rotate(-45deg);
|
35
|
+
-webkit-transform: rotate(-45deg);
|
36
|
+
transform: rotate(-45deg);
|
37
|
+
}
|
38
|
+
|
39
|
+
.icono-caret-left {
|
40
|
+
-moz-transform: rotate(180deg);
|
41
|
+
-ms-transform: rotate(180deg);
|
42
|
+
-o-transform: rotate(180deg);
|
43
|
+
-webkit-transform: rotate(180deg);
|
44
|
+
transform: rotate(180deg);
|
45
|
+
}
|
46
|
+
|
47
|
+
[class*="icono-"] {
|
48
|
+
direction: ltr;
|
49
|
+
display: inline-block;
|
50
|
+
font-style: normal;
|
51
|
+
position: relative;
|
52
|
+
text-align: left;
|
53
|
+
text-indent: -9999px;
|
54
|
+
vertical-align: middle;
|
55
|
+
}
|
56
|
+
|
57
|
+
[class*="icono-"]:before,
|
58
|
+
[class*="icono-"]:after {
|
59
|
+
content: "";
|
60
|
+
pointer-events: none;
|
61
|
+
}
|
62
|
+
|
63
|
+
[class*="icono-"],
|
64
|
+
[class*="icono-"] * {
|
65
|
+
box-sizing: border-box;
|
66
|
+
}
|
data/lib/active_admin_sidebar.rb
CHANGED
@@ -1,17 +1,15 @@
|
|
1
|
-
require
|
1
|
+
require "active_admin"
|
2
2
|
require "active_admin_sidebar/version"
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "active_admin_sidebar/activeadmin_views_pages_base"
|
4
|
+
require "active_admin_sidebar/positions"
|
5
5
|
|
6
6
|
module ActiveAdminSidebar
|
7
7
|
module Rails
|
8
8
|
class Engine < ::Rails::Engine
|
9
9
|
config.after_initialize do
|
10
|
+
ActiveAdmin::Views::Pages::Base.prepend ActiveAdminSidebar::ActiveAdminViewsPagesBase
|
10
11
|
ActiveAdmin::BaseController.send :include, ActiveAdminSidebar::Positions
|
11
12
|
end
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
15
|
-
|
16
|
-
|
17
|
-
|
@@ -1,36 +1,51 @@
|
|
1
|
-
|
1
|
+
module ActiveAdminSidebar::ActiveAdminViewsPagesBase
|
2
2
|
|
3
3
|
def build_page_content
|
4
4
|
build_flash_messages
|
5
|
-
|
6
|
-
|
7
|
-
if skip_sidebar?
|
8
|
-
classes << 'without_sidebar'
|
9
|
-
else
|
10
|
-
classes << 'with_sidebar'
|
11
|
-
classes << 'left_sidebar' if left_sidebar?
|
12
|
-
end
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
div :id => "active_admin_content", :class => classes do
|
17
|
-
|
5
|
+
div id: "active_admin_content", class: main_content_classes do
|
18
6
|
build_sidebar unless skip_sidebar? || right_sidebar?
|
19
7
|
build_main_content_wrapper
|
20
8
|
build_sidebar unless skip_sidebar? || left_sidebar?
|
21
|
-
|
22
9
|
end
|
23
10
|
end
|
24
11
|
|
12
|
+
def build_sidebar
|
13
|
+
if defined?(super)
|
14
|
+
super
|
15
|
+
else
|
16
|
+
sidebar sidebar_sections_for_action, id: 'sidebar'
|
17
|
+
end
|
18
|
+
end
|
25
19
|
|
26
20
|
def left_sidebar?
|
27
|
-
assigns[:
|
21
|
+
assigns[:sidebar_options].try!(:[], :position) == :left
|
22
|
+
end
|
23
|
+
|
24
|
+
def collapsible_sidebar?
|
25
|
+
left_sidebar? && !!assigns[:sidebar_options].try!(:[], :collapsed)
|
26
|
+
end
|
27
|
+
|
28
|
+
def sidebar_is_collapsed?
|
29
|
+
!!assigns[:sidebar_options].try!(:[], :is_collapsed)
|
28
30
|
end
|
29
31
|
|
30
32
|
def right_sidebar?
|
31
33
|
!left_sidebar?
|
32
34
|
end
|
33
35
|
|
36
|
+
def main_content_classes
|
37
|
+
classes = Arbre::HTML::ClassList.new
|
38
|
+
if skip_sidebar?
|
39
|
+
classes << "without_sidebar"
|
40
|
+
else
|
41
|
+
classes << "with_sidebar"
|
42
|
+
classes << "left_sidebar" if left_sidebar?
|
43
|
+
if collapsible_sidebar?
|
44
|
+
classes << "collapsible_sidebar"
|
45
|
+
classes << "collapsed_sidebar" if sidebar_is_collapsed?
|
46
|
+
end
|
47
|
+
end
|
48
|
+
classes
|
49
|
+
end
|
34
50
|
|
35
|
-
|
36
|
-
end
|
51
|
+
end
|
@@ -1,10 +1,28 @@
|
|
1
1
|
module ActiveAdminSidebar
|
2
2
|
module Positions
|
3
|
-
def left_sidebar!
|
4
|
-
|
3
|
+
def left_sidebar!(options = {})
|
4
|
+
@sidebar_options = { position: :left }
|
5
|
+
if options.fetch(:collapsed, false)
|
6
|
+
collapsed_sidebar
|
7
|
+
@sidebar_options.merge!(
|
8
|
+
is_collapsed: session[:collapsed_sidebar],
|
9
|
+
collapsed: true
|
10
|
+
)
|
11
|
+
end
|
5
12
|
end
|
13
|
+
|
6
14
|
def right_sidebar!
|
7
|
-
|
15
|
+
@sidebar_options = { position: :right }
|
16
|
+
end
|
17
|
+
|
18
|
+
def collapsed_sidebar
|
19
|
+
if request.xhr?
|
20
|
+
if params[:collapsed_sidebar].present?
|
21
|
+
collapsed = params[:collapsed_sidebar].to_s == 'true'
|
22
|
+
session[:collapsed_sidebar] = collapsed
|
23
|
+
render json: { collapsed_sidebar: collapsed } and return
|
24
|
+
end
|
25
|
+
end
|
8
26
|
end
|
9
27
|
|
10
28
|
end
|
data/screen/sidebar.jpg
ADDED
Binary file
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'authors index', type: :feature, js: true do
|
4
|
+
|
5
|
+
before do
|
6
|
+
Author.create!(name: 'John', last_name: 'Doe')
|
7
|
+
Author.create!(name: 'Jane', last_name: 'Roe')
|
8
|
+
add_author_resource
|
9
|
+
add_post_resource
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'left-sidebar with default settings' do
|
13
|
+
before do
|
14
|
+
visit '/admin/authors'
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'has left-sidebar with colapse-button' do
|
18
|
+
expect(page).to have_css('#filters_sidebar_section')
|
19
|
+
expect(page).to have_css('#filters_sidebar_section .collapse_btn.icono-caret-left')
|
20
|
+
expect(page).to have_css('#active_admin_content.with_sidebar.left_sidebar.collapsible_sidebar')
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when click on Collapse' do
|
24
|
+
before do
|
25
|
+
page.find('#filters_sidebar_section .collapse_btn').click
|
26
|
+
end
|
27
|
+
|
28
|
+
it "sidebar is hidden, and save it's state after going to another page" do
|
29
|
+
expect(page).to have_css('#sidebar', visible: :hidden)
|
30
|
+
|
31
|
+
# Posts page is configured as: "before_action :skip_sidebar!"
|
32
|
+
visit '/admin/posts'
|
33
|
+
# sidebar does not exists at all
|
34
|
+
expect(page).to have_css('#page_title', text: 'Posts')
|
35
|
+
expect(page).not_to have_css('#sidebar', visible: :all)
|
36
|
+
|
37
|
+
visit '/admin/authors'
|
38
|
+
# sidebar is hidden
|
39
|
+
expect(page).to have_css('#page_title', text: 'Authors')
|
40
|
+
expect(page).to have_css('#sidebar', visible: :hidden)
|
41
|
+
|
42
|
+
page.find('.uncollapse_btn').click
|
43
|
+
|
44
|
+
# sidebar is visible
|
45
|
+
expect(page).to have_css('#sidebar', visible: :visible)
|
46
|
+
expect(page).to have_css('.collapse_btn')
|
47
|
+
expect(page).not_to have_css('.uncollapse_btn')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH << File.expand_path('../support', __FILE__)
|
3
|
+
|
4
|
+
ENV['BUNDLE_GEMFILE'] = File.expand_path('../../Gemfile', __FILE__)
|
5
|
+
require "bundler"
|
6
|
+
Bundler.setup
|
7
|
+
|
8
|
+
ENV['RAILS_ENV'] = 'test'
|
9
|
+
# Ensure the Active Admin load path is happy
|
10
|
+
require 'rails'
|
11
|
+
ENV['RAILS'] = Rails.version
|
12
|
+
ENV['RAILS_ROOT'] = File.expand_path("../rails/rails-#{ENV['RAILS']}", __FILE__)
|
13
|
+
# Create the test app if it doesn't exists
|
14
|
+
unless File.exists?(ENV['RAILS_ROOT'])
|
15
|
+
system 'rake setup'
|
16
|
+
end
|
17
|
+
|
18
|
+
require 'rails/all'
|
19
|
+
require 'active_admin'
|
20
|
+
ActiveAdmin.application.load_paths = [ENV['RAILS_ROOT'] + "/app/admin"]
|
21
|
+
require ENV['RAILS_ROOT'] + '/config/environment.rb'
|
22
|
+
# Disabling authentication in specs so that we don't have to worry about
|
23
|
+
# it allover the place
|
24
|
+
ActiveAdmin.application.authentication_method = false
|
25
|
+
ActiveAdmin.application.current_user_method = false
|
26
|
+
|
27
|
+
require 'rspec/rails'
|
28
|
+
require 'capybara/rails'
|
29
|
+
require 'capybara/rspec'
|
30
|
+
require 'selenium-webdriver'
|
31
|
+
|
32
|
+
require 'support/admin'
|
33
|
+
require 'support/capybara'
|
34
|
+
|
35
|
+
RSpec.configure do |config|
|
36
|
+
config.use_transactional_fixtures = false
|
37
|
+
|
38
|
+
config.before(:suite) do
|
39
|
+
DatabaseCleaner.strategy = :truncation
|
40
|
+
DatabaseCleaner.clean_with(:truncation)
|
41
|
+
end
|
42
|
+
config.before(:each) do
|
43
|
+
DatabaseCleaner.strategy = :truncation
|
44
|
+
DatabaseCleaner.start
|
45
|
+
end
|
46
|
+
config.after(:each) do
|
47
|
+
DatabaseCleaner.clean
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
def add_author_resource(options = {}, &block)
|
2
|
+
|
3
|
+
ActiveAdmin.register Author do
|
4
|
+
config.filters = true
|
5
|
+
end
|
6
|
+
|
7
|
+
Rails.application.reload_routes!
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
def add_post_resource(options = {}, &block)
|
13
|
+
|
14
|
+
ActiveAdmin.register Post do
|
15
|
+
config.filters = true
|
16
|
+
before_action :skip_sidebar!
|
17
|
+
end
|
18
|
+
|
19
|
+
Rails.application.reload_routes!
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Capybara.configure do |config|
|
2
|
+
config.match = :prefer_exact
|
3
|
+
end
|
4
|
+
|
5
|
+
Capybara.register_driver :selenium_chrome do |app|
|
6
|
+
options = Selenium::WebDriver::Chrome::Options.new(
|
7
|
+
args: %w[headless disable-gpu no-sandbox]
|
8
|
+
)
|
9
|
+
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
|
10
|
+
end
|
11
|
+
|
12
|
+
Capybara.server = :webrick
|
13
|
+
Capybara.javascript_driver = :selenium_chrome
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# Rails template to build the sample app for specs
|
2
|
+
|
3
|
+
generate :model, 'author name:string{10}:uniq last_name:string birthday:date'
|
4
|
+
generate :model, 'post title:string:uniq body:text author:references'
|
5
|
+
|
6
|
+
#Add validation
|
7
|
+
inject_into_file "app/models/author.rb", " validates_presence_of :name\n validates_uniqueness_of :last_name\n", after: "Base\n"
|
8
|
+
inject_into_file "app/models/post.rb", " validates_presence_of :author\n", after: ":author\n"
|
9
|
+
|
10
|
+
# Configure default_url_options in test environment
|
11
|
+
inject_into_file "config/environments/test.rb", " config.action_mailer.default_url_options = { :host => 'example.com' }\n", after: "config.cache_classes = true\n"
|
12
|
+
|
13
|
+
# Add our local Active Admin to the load path
|
14
|
+
inject_into_file "config/environment.rb",
|
15
|
+
"\n$LOAD_PATH.unshift('#{File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))}')\nrequire \"active_admin\"\n",
|
16
|
+
after: "require File.expand_path('../application', __FILE__)"
|
17
|
+
|
18
|
+
run "rm Gemfile"
|
19
|
+
|
20
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
21
|
+
|
22
|
+
generate :'active_admin:install --skip-users'
|
23
|
+
generate :'formtastic:install'
|
24
|
+
|
25
|
+
# Initialize plugin
|
26
|
+
inject_into_file "config/initializers/active_admin.rb",
|
27
|
+
" config.before_action do\n left_sidebar!(collapsed: true) if respond_to?(:left_sidebar!)\n end\n\n",
|
28
|
+
after: "ActiveAdmin.setup do |config|\n"
|
29
|
+
|
30
|
+
inject_into_file "app/assets/stylesheets/active_admin.scss",
|
31
|
+
"@import \"active_admin_sidebar\";\n",
|
32
|
+
after: "@import \"active_admin/base\";\n"
|
33
|
+
|
34
|
+
if File.file?("app/assets/javascripts/active_admin.js")
|
35
|
+
inject_into_file "app/assets/javascripts/active_admin.js",
|
36
|
+
"//= require active_admin_sidebar\n",
|
37
|
+
after: "//= require active_admin/base\n"
|
38
|
+
else
|
39
|
+
inject_into_file "app/assets/javascripts/active_admin.js.coffee",
|
40
|
+
"#= require active_admin_sidebar\n",
|
41
|
+
after: "#= require active_admin/base\n"
|
42
|
+
end
|
43
|
+
|
44
|
+
run "rm -r test"
|
45
|
+
run "rm -r spec"
|
46
|
+
|
47
|
+
route "root :to => 'admin/dashboard#index'"
|
48
|
+
|
49
|
+
rake "db:migrate"
|
data/tasks/test.rake
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
desc "Creates a test rails app for the specs to run against"
|
2
|
+
task :setup do
|
3
|
+
require 'rails/version'
|
4
|
+
system("mkdir spec/rails") unless File.exists?("spec/rails")
|
5
|
+
|
6
|
+
rails_new_opts = %w(
|
7
|
+
--skip-turbolinks
|
8
|
+
--skip-spring
|
9
|
+
--skip-bootsnap
|
10
|
+
--skip-webpack-install
|
11
|
+
-m
|
12
|
+
spec/support/rails_template.rb
|
13
|
+
)
|
14
|
+
system "bundle exec rails new spec/rails/rails-#{Rails::VERSION::STRING} #{rails_new_opts.join(' ')}"
|
15
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_admin_sidebar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeadmin
|
@@ -31,20 +31,30 @@ executables: []
|
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
|
+
- ".travis.yml"
|
34
35
|
- Gemfile
|
35
36
|
- LICENSE
|
36
|
-
- README.
|
37
|
+
- README.md
|
37
38
|
- Rakefile
|
38
39
|
- active_admin_sidebar.gemspec
|
39
|
-
- app/assets/
|
40
|
+
- app/assets/javascripts/active_admin_sidebar.js
|
41
|
+
- app/assets/stylesheets/active_admin_sidebar.scss
|
42
|
+
- app/assets/stylesheets/active_admin_sidebar_pure_icons.scss
|
40
43
|
- lib/active_admin_sidebar.rb
|
41
44
|
- lib/active_admin_sidebar/activeadmin_views_pages_base.rb
|
42
45
|
- lib/active_admin_sidebar/positions.rb
|
43
46
|
- lib/active_admin_sidebar/version.rb
|
47
|
+
- screen/sidebar.jpg
|
48
|
+
- spec/sidebars_spec.rb
|
49
|
+
- spec/spec_helper.rb
|
50
|
+
- spec/support/admin.rb
|
51
|
+
- spec/support/capybara.rb
|
52
|
+
- spec/support/rails_template.rb
|
53
|
+
- tasks/test.rake
|
44
54
|
homepage: https://github.com/Fivell/active_admin_sidebar
|
45
55
|
licenses: []
|
46
56
|
metadata: {}
|
47
|
-
post_install_message:
|
57
|
+
post_install_message:
|
48
58
|
rdoc_options: []
|
49
59
|
require_paths:
|
50
60
|
- lib
|
@@ -55,13 +65,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
55
65
|
version: '0'
|
56
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
67
|
requirements:
|
58
|
-
- - "
|
68
|
+
- - ">="
|
59
69
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
70
|
+
version: '0'
|
61
71
|
requirements: []
|
62
|
-
rubyforge_project:
|
63
|
-
rubygems_version: 2.
|
64
|
-
signing_key:
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 2.7.6.2
|
74
|
+
signing_key:
|
65
75
|
specification_version: 4
|
66
76
|
summary: active_admin_sidebar gem
|
67
|
-
test_files:
|
77
|
+
test_files:
|
78
|
+
- spec/sidebars_spec.rb
|
79
|
+
- spec/spec_helper.rb
|
80
|
+
- spec/support/admin.rb
|
81
|
+
- spec/support/capybara.rb
|
82
|
+
- spec/support/rails_template.rb
|
data/README.rdoc
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
active_admin_sidebar
|
2
|
-
====================
|
3
|
-
|
4
|
-
easy change sidebar position with activeadmin (tested with activeadmin ~> 1.0.0.pre)
|
5
|
-
|
6
|
-
|
7
|
-
Add including of css file
|
8
|
-
|
9
|
-
@import "active_admin_sidebar";
|
10
|
-
|
11
|
-
to the app/assets/stylesheets/active_admin.css.scss
|
12
|
-
|
13
|
-
|
14
|
-
Changing sidebar position dynamically with before_filter
|
15
|
-
|
16
|
-
# app/admin/posts.rb
|
17
|
-
ActiveAdmin.register Post do
|
18
|
-
before_filter :left_sidebar!, only: [:show]
|
19
|
-
end
|
20
|
-
|
21
|
-
# app/admin/comments.rb
|
22
|
-
ActiveAdmin.register Comment do
|
23
|
-
before_filter :right_sidebar!
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
Moving sidebar to the left within all resource (config/initializers/active_admin.rb)
|
29
|
-
|
30
|
-
|
31
|
-
# == Controller Filters
|
32
|
-
#
|
33
|
-
# You can add before, after and around filters to all of your
|
34
|
-
# Active Admin resources from here.
|
35
|
-
#
|
36
|
-
config.before_filter do
|
37
|
-
left_sidebar!
|
38
|
-
end
|
39
|
-
|
40
|
-
Disabling using sidebar layout on dashboards (if you setup sidebar position with initializer)
|
41
|
-
|
42
|
-
ActiveAdmin.register_page "Dashboard" do
|
43
|
-
controller {skip_before_filter :left_sidebar!}
|
44
|
-
#.....
|
45
|
-
end
|
46
|
-
|
47
|
-
Example
|
48
|
-
|
49
|
-
http://oi45.tinypic.com/1zx1a3r.png
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
@@ -1,42 +0,0 @@
|
|
1
|
-
body.active_admin #active_admin_content.left_sidebar {
|
2
|
-
|
3
|
-
#sidebar{
|
4
|
-
margin-left:0;
|
5
|
-
}
|
6
|
-
|
7
|
-
.paginated_collection_contents{
|
8
|
-
clear: none;
|
9
|
-
float: left;
|
10
|
-
width: 100%;
|
11
|
-
}
|
12
|
-
|
13
|
-
.blank_slate_container{
|
14
|
-
clear:none;
|
15
|
-
}
|
16
|
-
|
17
|
-
.columns {
|
18
|
-
clear: none;
|
19
|
-
}
|
20
|
-
|
21
|
-
#main_content_wrapper{
|
22
|
-
float:inherit;
|
23
|
-
width:auto;
|
24
|
-
margin-left: 298px;
|
25
|
-
#main_content{
|
26
|
-
margin:0;
|
27
|
-
float: inherit;
|
28
|
-
.tabs .comments {
|
29
|
-
.active_admin_comment {
|
30
|
-
clear: none;
|
31
|
-
}
|
32
|
-
}
|
33
|
-
}
|
34
|
-
|
35
|
-
}
|
36
|
-
|
37
|
-
.table_tools:after {
|
38
|
-
clear: none;
|
39
|
-
padding-bottom: 16px;
|
40
|
-
}
|
41
|
-
}
|
42
|
-
|