active_admin_sidebar 0.1.0.rc3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f5c5c51fa6d1bbcd8febffeb2249ae313ff93eea
4
- data.tar.gz: 1c3c5cfe4e565da150e8cddb6ca2703f6249142d
2
+ SHA256:
3
+ metadata.gz: b58bcf234d2f317dcd23d5a57dd77795136ffb7f2758de981514d82163077d90
4
+ data.tar.gz: 895b88d334f9306b5caeffaed1bb9440478d25e9c1873c75d498d70365088847
5
5
  SHA512:
6
- metadata.gz: 8d3b5c8f5720733dc53cd7e5f79e1564c2027d6f5437a2f06a99ec840ed432299484dab06c71863482c1e7366dd6655088a645ed6d188f9c9546a3f09f1f7419
7
- data.tar.gz: 1c25cff3122cdd24d2837f56abd060e4aa9d78c60775aef5ae38b470b4bab6df50cc2895a6cb2eb04dd3cd21b5cb27be2bdf5f22bffd5dde814b10bc5d711f00
6
+ metadata.gz: d0d6dbc10f05fa74875dd6b07174f812ce5598aec325e37b4d4b45494a5d79a4341b4117b1736849418d1f6be5c677d83da223180a8f35b89002c390e0b923a8
7
+ data.tar.gz: 1c4a3c24433bdbcd00bd83afe25a4e01db120059f32ad532cde52aea31d522d239b34457f83e3193c9f005b445442bfe8e970baba37afcb347b535014aa229e1
data/Gemfile CHANGED
@@ -1,4 +1,19 @@
1
- source "http://rubygems.org"
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 'sprockets-rails', '3.2.0'
8
+ gem 'rails', '5.1.1'
9
+ gem 'turbolinks'
10
+ gem 'rspec-rails'
11
+ gem 'activeadmin', '1.0.0'
12
+ gem 'sass-rails'
13
+ gem 'sqlite3'
14
+ gem 'launchy'
15
+ gem 'database_cleaner'
16
+ gem 'capybara'
17
+ gem 'selenium-webdriver'
18
+ gem 'poltergeist'
19
+ end
data/README.md CHANGED
@@ -1,63 +1,81 @@
1
- # ActiveAdminSidebar
1
+ # ActiveAdmin Sidebar
2
2
 
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)
4
4
 
5
+ ## Install
5
6
 
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
7
14
 
8
15
  ```scss
9
- @import "active_admin_sidebar";
16
+ @import "active_admin_sidebar";
10
17
  ```
11
18
 
12
19
  to the
13
- ```
14
- app/assets/stylesheets/active_admin.css.scss
20
+ ```
21
+ app/assets/stylesheets/active_admin.css.scss
15
22
  ```
16
23
 
17
24
  And including of coffee file (optional, need only for collapsed sidebar)
18
25
 
19
- ```js
20
- //= require active_admin_sidebar
26
+ ```coffeescript
27
+ #= require active_admin_sidebar
21
28
  ```
22
29
 
23
30
  to the
24
- ```
31
+
32
+ ```scss
25
33
  app/assets/javascripts/active_admin.js
26
34
  ```
27
35
 
28
- Changing sidebar position dynamically with before_filter
36
+ # Configuration per resource
37
+
38
+ Changing sidebar position dynamically with before_action
39
+
29
40
  ```ruby
30
41
  # app/admin/posts.rb
31
42
  ActiveAdmin.register Post do
32
- before_filter :left_sidebar!, only: [:show]
43
+ before_action :left_sidebar!, only: [:show]
33
44
  end
34
45
 
35
46
  # app/admin/comments.rb
36
47
  ActiveAdmin.register Comment do
37
- before_filter :right_sidebar!
48
+ before_action :right_sidebar!
38
49
  end
39
50
  ```
40
51
 
52
+ ## Global configuration
41
53
 
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`
43
55
 
44
56
  ```ruby
45
- # == Controller Filters
57
+ # == Controller before-actions
46
58
  #
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
53
65
  ```
54
66
 
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
+
56
72
  ```ruby
57
73
  left_sidebar!(collapsed: true)
58
74
  ```
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
61
79
  body.active_admin {
62
80
  #active_admin_content.left_sidebar, #active_admin_content.collapsed_sidebar {
63
81
  .collapse_btn, .uncollapse_btn {
@@ -69,8 +87,4 @@ You can override button color according to your color theme:
69
87
 
70
88
  Example
71
89
 
72
- http://oi45.tinypic.com/1zx1a3r.png
73
-
74
-
75
-
76
-
90
+ ![Alt text](https://raw.githubusercontent.com/activeadmin-plugins/active_admin_sidebar/master/screen/sidebar.jpg "Example")
data/Rakefile CHANGED
@@ -1 +1,7 @@
1
- require "bundler/gem_tasks"
1
+ require "bundler"
2
+ require 'rake'
3
+ Bundler.setup
4
+ Bundler::GemHelper.install_tasks
5
+
6
+ # Import all our rake tasks
7
+ FileList['tasks/**/*.rake'].each { |task| import task }
@@ -17,7 +17,9 @@ $(document).ready ->
17
17
  set_collapsed_sidebar(true)
18
18
  $aa_content.removeClass('left_sidebar')
19
19
  $aa_content.addClass('collapsed_sidebar')
20
+ $aa_content.trigger('collapsible_sidebar:collapsed')
20
21
  else
21
22
  set_collapsed_sidebar(false)
22
23
  $aa_content.removeClass('collapsed_sidebar')
23
24
  $aa_content.addClass('left_sidebar')
25
+ $aa_content.trigger('collapsible_sidebar:uncollapsed')
@@ -18,7 +18,7 @@ module ActiveAdminSidebar
18
18
  def collapsed_sidebar
19
19
  if request.xhr?
20
20
  if params[:collapsed_sidebar].present?
21
- collapsed = ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include? params[:collapsed_sidebar]
21
+ collapsed = params[:collapsed_sidebar].to_s == 'true'
22
22
  session[:collapsed_sidebar] = collapsed
23
23
  render json: { collapsed_sidebar: collapsed } and return
24
24
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveAdminSidebar
2
- VERSION = "0.1.0.rc3"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -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
@@ -0,0 +1,68 @@
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 'active_model'
19
+ # require ActiveRecord to ensure that Ransack loads correctly
20
+ require 'active_record'
21
+ require 'active_admin'
22
+ ActiveAdmin.application.load_paths = [ENV['RAILS_ROOT'] + "/app/admin"]
23
+ require ENV['RAILS_ROOT'] + '/config/environment.rb'
24
+ # Disabling authentication in specs so that we don't have to worry about
25
+ # it allover the place
26
+ ActiveAdmin.application.authentication_method = false
27
+ ActiveAdmin.application.current_user_method = false
28
+
29
+ require 'rspec/rails'
30
+ require 'support/admin'
31
+ require 'capybara/rails'
32
+ require 'capybara/rspec'
33
+ require 'capybara/poltergeist'
34
+
35
+
36
+ RSpec.configure do |config|
37
+ config.use_transactional_fixtures = false
38
+
39
+ config.before(:suite) do
40
+ DatabaseCleaner.strategy = :truncation
41
+ DatabaseCleaner.clean_with(:truncation)
42
+ end
43
+ config.before(:each) do
44
+ DatabaseCleaner.strategy = :truncation
45
+ DatabaseCleaner.start
46
+ end
47
+ config.after(:each) do
48
+ DatabaseCleaner.clean
49
+ end
50
+
51
+ end
52
+
53
+ # RSpec.configure do |config|
54
+ # config.before(:each, js: true) do
55
+ # page.driver.browser.manage.window.maximize if page.driver.browser.respond_to?(:manage)
56
+ # end
57
+ # end
58
+ # Capybara.javascript_driver = :selenium
59
+
60
+ Capybara.register_driver :poltergeist do |app|
61
+ Capybara::Poltergeist::Driver.new(app, {
62
+ js_errors: true,
63
+ timeout: 80,
64
+ debug: true,
65
+ :phantomjs_options => ['--debug=no', '--load-images=no']
66
+ })
67
+ end
68
+ Capybara.javascript_driver = :poltergeist
@@ -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,43 @@
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
+ inject_into_file "app/assets/javascripts/active_admin.js.coffee",
35
+ "#= require active_admin_sidebar\n",
36
+ after: "#= require active_admin/base\n"
37
+
38
+ run "rm -r test"
39
+ run "rm -r spec"
40
+
41
+ route "root :to => 'admin/dashboard#index'"
42
+
43
+ rake "db:migrate"
@@ -0,0 +1,6 @@
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
+ system "bundle exec rails new spec/rails/rails-#{Rails::VERSION::STRING} -m spec/support/rails_template.rb --skip-spring"
6
+ 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.1.0.rc3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-18 00:00:00.000000000 Z
11
+ date: 2018-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeadmin
@@ -44,6 +44,11 @@ files:
44
44
  - lib/active_admin_sidebar/positions.rb
45
45
  - lib/active_admin_sidebar/version.rb
46
46
  - screen/sidebar.jpg
47
+ - spec/sidebars_spec.rb
48
+ - spec/spec_helper.rb
49
+ - spec/support/admin.rb
50
+ - spec/support/rails_template.rb
51
+ - tasks/test.rake
47
52
  homepage: https://github.com/Fivell/active_admin_sidebar
48
53
  licenses: []
49
54
  metadata: {}
@@ -58,14 +63,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
58
63
  version: '0'
59
64
  required_rubygems_version: !ruby/object:Gem::Requirement
60
65
  requirements:
61
- - - ">"
66
+ - - ">="
62
67
  - !ruby/object:Gem::Version
63
- version: 1.3.1
68
+ version: '0'
64
69
  requirements: []
65
70
  rubyforge_project:
66
- rubygems_version: 2.5.0
71
+ rubygems_version: 2.7.7
67
72
  signing_key:
68
73
  specification_version: 4
69
74
  summary: active_admin_sidebar gem
70
- test_files: []
71
- has_rdoc:
75
+ test_files:
76
+ - spec/sidebars_spec.rb
77
+ - spec/spec_helper.rb
78
+ - spec/support/admin.rb
79
+ - spec/support/rails_template.rb