active_admin_sidebar 2.0.0 → 3.0.1

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: cf32ccf4b0aa40e39121ac1fd4b207fbc5b169cc1f3b7ea8b9ea8412ed8ab58e
4
- data.tar.gz: d2d59d557d0849aec9546c0ecd14f4c2d4bbf4845e462d7cfd6c64f73c245736
3
+ metadata.gz: b52cbe9432e50cb28e3f8fc445b052c11e6b22dcadc4240ad8f0854e2cbd9130
4
+ data.tar.gz: 77d9509198ab37d17ee738f5a8eefd4315100c851024e4289477578fa78a9280
5
5
  SHA512:
6
- metadata.gz: 4a74c0276007f4b2f77a70186bd588780e19283af299397b457e7b78363b7cdff70bbd24ef8d51936395521748b04f610eec774a76d0990ec8b489874af95438
7
- data.tar.gz: 4f217901c2e5a781b433315ac9eb735347daea5a5611aa550bbfbb7048f4fb0b2989be0ed8e7debad0ee5d15c0762e626ecf01bb5936449343368018eea42bd5
6
+ metadata.gz: f723c8696ef07ec5543593691e472b87b7325459eb2378d01f0aed447cf9c979a8d55380956194f53c2dad8cbb4f648f49bcfab5d25899b56f9eea51072a120e
7
+ data.tar.gz: 3e50493992f98a08864ff9db07f5b634bf4de3f9fc3e1eecdf84db634cc77e874ca702a07f40e7fb26387d36897e29750c0ca3d860f9e6ae4f3d8ec30f542710
data/README.md CHANGED
@@ -1,81 +1,98 @@
1
+ [![Gem Version](https://badge.fury.io/rb/active_admin_sidebar.svg)](https://badge.fury.io/rb/active_admin_sidebar)
2
+ [![NPM Version](https://badge.fury.io/js/@activeadmin-plugins%2Factive_admin_sidebar.svg)](https://badge.fury.io/js/@activeadmin-plugins%2Factive_admin_sidebar)
3
+ ![npm](https://img.shields.io/npm/dm/@activeadmin-plugins/active_admin_sidebar)
4
+ ![Coverage](https://img.shields.io/endpoint?url=https://activeadmin-plugins.github.io/active_admin_sidebar/badge.json)
5
+
1
6
  # ActiveAdmin Sidebar
2
7
 
3
- Provides ability to manipulate sidebar position for ActiveAdmin (tested with ActiveAdmin ~> 1.0.0)
8
+ Manipulate sidebar position and add collapsible sidebar support for ActiveAdmin 3.x.
4
9
 
5
10
  ## Install
6
11
 
7
- Add following line to the `Gemfile`
12
+ Add to your `Gemfile`:
8
13
 
9
14
  ```ruby
10
15
  gem 'active_admin_sidebar'
11
16
  ```
12
17
 
13
- Add following line to the `app/assets/stylesheets/active_admin.css.scss`
18
+ ### Using assets via Sprockets
19
+
20
+ Add to `app/assets/stylesheets/active_admin.scss`:
14
21
 
15
22
  ```scss
16
- @import "active_admin_sidebar";
23
+ @import "active_admin_sidebar";
24
+ ```
25
+
26
+ Add to `app/assets/javascripts/active_admin.js`:
27
+
28
+ ```javascript
29
+ //= require active_admin_sidebar
17
30
  ```
18
31
 
19
- If you want to use collapsing feature, add following line
32
+ ### Using assets via NPM
33
+
34
+ $ npm i @activeadmin-plugins/active_admin_sidebar
35
+
36
+ Or
37
+
38
+ $ yarn add @activeadmin-plugins/active_admin_sidebar
20
39
 
21
- ```javascripts
22
- //= require active_admin_sidebar
40
+ Add to `app/assets/javascripts/active_admin.js`:
41
+
42
+ ```javascript
43
+ import '@activeadmin-plugins/active_admin_sidebar';
23
44
  ```
24
45
 
25
- to the `app/assets/javascripts/active_admin.js`
46
+ Add to `app/assets/stylesheets/active_admin.scss`:
47
+
48
+ ```scss
49
+ @import '@activeadmin-plugins/active_admin_sidebar';
50
+ ```
26
51
 
27
- # Configuration per resource
52
+ ## Configuration per resource
28
53
 
29
- Changing sidebar position dynamically with before_action
54
+ Change sidebar position with `before_action`:
30
55
 
31
56
  ```ruby
32
- # app/admin/posts.rb
33
- ActiveAdmin.register Post do
34
- before_action :left_sidebar!, only: [:show]
57
+ # app/admin/posts.rb
58
+ ActiveAdmin.register Post do
59
+ before_action only: [:index] do
60
+ left_sidebar!
35
61
  end
62
+ end
36
63
 
37
- # app/admin/comments.rb
38
- ActiveAdmin.register Comment do
39
- before_action :right_sidebar!
64
+ # app/admin/comments.rb
65
+ ActiveAdmin.register Comment do
66
+ before_action do
67
+ right_sidebar!
40
68
  end
69
+ end
41
70
  ```
42
71
 
43
72
  ## Global configuration
44
73
 
45
- Moving sidebar to the left within all resource. Set configuration in `config/initializers/active_admin.rb`
74
+ Move sidebar to the left for all resources in `config/initializers/active_admin.rb`:
46
75
 
47
76
  ```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
77
+ ActiveAdmin.setup do |config|
78
+ config.before_action do
79
+ left_sidebar! if respond_to?(:left_sidebar!)
55
80
  end
81
+ end
56
82
  ```
57
83
 
58
- ## Collapsing sidebar
84
+ ## Collapsible sidebar
59
85
 
60
- You can use sidebar collapsing.
61
- It will add "hide/show" button. Shown/Hidden state is persisted across all pages.
86
+ Add a toggle button to collapse/expand the sidebar. State is persisted per-resource across page navigations.
62
87
 
63
88
  ```ruby
64
- left_sidebar!(collapsed: true)
65
- ```
66
-
67
- You can override button color according to your color theme. For example:
89
+ # Collapsible sidebar (starts expanded)
90
+ left_sidebar!(collapsible: true)
91
+ right_sidebar!(collapsible: true)
68
92
 
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
- }
93
+ # Collapsible sidebar (starts collapsed)
94
+ left_sidebar!(collapsible: true, start_collapsed: true)
95
+ right_sidebar!(collapsible: true, start_collapsed: true)
77
96
  ```
78
97
 
79
- Example
80
-
81
- ![Alt text](https://raw.githubusercontent.com/activeadmin-plugins/active_admin_sidebar/master/screen/sidebar.jpg "Example")
98
+ ![Demo](https://activeadmin-plugins.github.io/active_admin_sidebar/demo.gif "Collapsible sidebar demo")
@@ -1,29 +1,29 @@
1
1
  (function() {
2
2
  $(document).ready(function() {
3
- var $aa_content, set_collapsed_sidebar;
4
3
  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) {
4
+ var $aa_content = $('#active_admin_content');
5
+ var $sidebar = $aa_content.find('#sidebar');
6
+
7
+ var $toggleBtn = $('<span class="sidebar_toggle_btn" title="Toggle sidebar"><span class="chevron"></span></span>');
8
+ $sidebar.prepend($toggleBtn);
9
+
10
+ var set_collapsed_sidebar = function(value) {
9
11
  return $.getJSON(this.href, {
10
12
  collapsed_sidebar: value
11
13
  });
12
14
  };
13
- return $aa_content.on('click', '.collapse_btn, .uncollapse_btn', function(e) {
15
+
16
+ $toggleBtn.on('click', function(e) {
14
17
  if (!$aa_content.hasClass('collapsed_sidebar')) {
15
18
  set_collapsed_sidebar(true);
16
- $aa_content.removeClass('left_sidebar');
17
19
  $aa_content.addClass('collapsed_sidebar');
18
- return $aa_content.trigger('collapsible_sidebar:collapsed');
20
+ $aa_content.trigger('collapsible_sidebar:collapsed');
19
21
  } else {
20
22
  set_collapsed_sidebar(false);
21
23
  $aa_content.removeClass('collapsed_sidebar');
22
- $aa_content.addClass('left_sidebar');
23
- return $aa_content.trigger('collapsible_sidebar:uncollapsed');
24
+ $aa_content.trigger('collapsible_sidebar:uncollapsed');
24
25
  }
25
26
  });
26
27
  }
27
28
  });
28
-
29
29
  }).call(this);
@@ -1,7 +1,11 @@
1
- @import "active_admin_sidebar_pure_icons";
1
+ $toggle-btn-width: 12px;
2
+ $toggle-btn-height: 48px;
2
3
 
4
+ // === Left sidebar layout ===
5
+ // Moves sidebar before main content in the DOM, so we need to
6
+ // reverse the default AA float layout.
3
7
  body.active_admin {
4
- #active_admin_content.left_sidebar, #active_admin_content.collapsed_sidebar {
8
+ #active_admin_content.left_sidebar {
5
9
  #sidebar {
6
10
  display: block;
7
11
  margin-left: 0;
@@ -25,67 +29,119 @@ body.active_admin {
25
29
  float: inherit;
26
30
  margin-left: 298px;
27
31
  width: auto;
32
+
28
33
  #main_content {
29
34
  float: inherit;
30
35
  margin: 0;
31
- .tabs .comments {
32
- .active_admin_comment {
33
- clear: none;
34
- }
36
+
37
+ .tabs .comments .active_admin_comment {
38
+ clear: none;
35
39
  }
36
40
  }
37
-
38
41
  }
39
42
 
40
43
  .table_tools:after {
41
44
  clear: none;
42
45
  padding-bottom: 16px;
43
46
  }
47
+ }
48
+ }
44
49
 
45
- .collapse_btn, .uncollapse_btn {
46
- background-color: #767270;
47
- border-radius: 5px;
48
- color: #ffffff;
49
- cursor: pointer;
50
- }
50
+ // === Collapsible sidebar: toggle button ===
51
+ body.active_admin #active_admin_content.collapsible_sidebar {
52
+ #sidebar {
53
+ position: relative;
54
+ }
51
55
 
52
- .collapse_btn {
53
- clear: both;
54
- display: block;
55
- float: right;
56
+ .sidebar_toggle_btn {
57
+ width: $toggle-btn-width;
58
+ height: $toggle-btn-height;
59
+ background-color: #767270;
60
+ border-radius: 3px;
61
+ cursor: pointer;
62
+ z-index: 10;
63
+ position: absolute;
64
+ top: 12px;
65
+ display: flex;
66
+ align-items: center;
67
+ justify-content: center;
68
+
69
+ &:hover {
70
+ background-color: #5a5857;
56
71
  }
57
72
 
58
- .uncollapse_btn {
59
- display: none;
60
- margin-top: 5px;
61
- position: absolute;
73
+ .chevron {
74
+ width: 0;
75
+ height: 0;
76
+ border-top: 4px solid transparent;
77
+ border-bottom: 4px solid transparent;
62
78
  }
79
+ }
80
+
81
+ // Left sidebar expanded: button on right edge, chevron points left (collapse)
82
+ &.left_sidebar .sidebar_toggle_btn {
83
+ right: -$toggle-btn-width;
84
+ .chevron { border-right: 5px solid #fff; border-left: none; }
85
+ }
86
+
87
+ // Left sidebar collapsed: chevron points right (expand)
88
+ &.left_sidebar.collapsed_sidebar .sidebar_toggle_btn {
89
+ .chevron { border-left: 5px solid #fff; border-right: none; }
90
+ }
91
+
92
+ // Right sidebar expanded: button on left edge, chevron points right (collapse)
93
+ &:not(.left_sidebar) .sidebar_toggle_btn {
94
+ left: -$toggle-btn-width;
95
+ .chevron { border-left: 5px solid #fff; border-right: none; }
96
+ }
63
97
 
98
+ // Right sidebar collapsed: chevron points left (expand)
99
+ &:not(.left_sidebar).collapsed_sidebar .sidebar_toggle_btn {
100
+ .chevron { border-right: 5px solid #fff; border-left: none; }
64
101
  }
65
102
  }
66
103
 
67
- body.active_admin #active_admin_content.collapsed_sidebar {
104
+ // === Collapsed state: left sidebar ===
105
+ body.active_admin #active_admin_content.collapsible_sidebar.collapsed_sidebar.left_sidebar {
106
+ #sidebar {
107
+ width: 0;
108
+ overflow: visible;
109
+
110
+ .sidebar_section {
111
+ display: none;
112
+ }
113
+ }
68
114
 
69
115
  #main_content_wrapper {
70
- margin-left: 30px;
116
+ margin-left: $toggle-btn-width + 8px;
71
117
  }
118
+ }
72
119
 
120
+ // === Collapsed state: right sidebar (default AA position) ===
121
+ body.active_admin #active_admin_content.collapsible_sidebar.collapsed_sidebar:not(.left_sidebar) {
73
122
  #sidebar {
74
- display: none;
75
- }
123
+ width: 0;
124
+ margin-left: 0;
125
+ overflow: visible;
76
126
 
77
- .uncollapse_btn {
78
- display: block;
127
+ .sidebar_section {
128
+ display: none;
129
+ }
79
130
  }
80
131
 
132
+ #main_content_wrapper #main_content {
133
+ margin-right: $toggle-btn-width + 8px;
134
+ }
81
135
  }
82
136
 
83
- body.active_admin.index #active_admin_content.with_sidebar.collapsible_sidebar {
137
+ // === Left sidebar expanded + collapsible: fix margin ===
138
+ body.active_admin.index #active_admin_content.with_sidebar.left_sidebar.collapsible_sidebar {
84
139
  #main_content_wrapper #main_content {
85
140
  margin-right: 0;
86
141
  }
87
142
  }
88
143
 
144
+ // === Comments overflow fix ===
89
145
  .with_sidebar .comments .active_admin_comment {
90
146
  overflow: auto;
91
147
  }
@@ -1,6 +1,9 @@
1
1
  module ActiveAdminSidebar::ActiveAdminViewsPagesBase
2
2
 
3
3
  def build_page_content
4
+ # When no sidebar options are set, fall back to vanilla ActiveAdmin behavior
5
+ return super unless sidebar_options_present?
6
+
4
7
  build_flash_messages
5
8
  div id: "active_admin_content", class: main_content_classes do
6
9
  build_sidebar unless skip_sidebar? || right_sidebar?
@@ -17,12 +20,16 @@ module ActiveAdminSidebar::ActiveAdminViewsPagesBase
17
20
  end
18
21
  end
19
22
 
23
+ def sidebar_options_present?
24
+ assigns[:sidebar_options].present?
25
+ end
26
+
20
27
  def left_sidebar?
21
28
  assigns[:sidebar_options].try!(:[], :position) == :left
22
29
  end
23
30
 
24
31
  def collapsible_sidebar?
25
- left_sidebar? && !!assigns[:sidebar_options].try!(:[], :collapsed)
32
+ !!assigns[:sidebar_options].try!(:[], :collapsible)
26
33
  end
27
34
 
28
35
  def sidebar_is_collapsed?
@@ -40,6 +47,7 @@ module ActiveAdminSidebar::ActiveAdminViewsPagesBase
40
47
  else
41
48
  classes << "with_sidebar"
42
49
  classes << "left_sidebar" if left_sidebar?
50
+ classes << "right_sidebar" if right_sidebar?
43
51
  if collapsible_sidebar?
44
52
  classes << "collapsible_sidebar"
45
53
  classes << "collapsed_sidebar" if sidebar_is_collapsed?
@@ -2,26 +2,56 @@ module ActiveAdminSidebar
2
2
  module Positions
3
3
  def left_sidebar!(options = {})
4
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
+
6
+ validate_sidebar_options!(options)
7
+
8
+ collapsible = options.fetch(:collapsible, false)
9
+ start_collapsed = options.fetch(:start_collapsed, false)
10
+
11
+ apply_collapsible_options(start_collapsed) if collapsible
12
12
  end
13
13
 
14
- def right_sidebar!
14
+ def right_sidebar!(options = {})
15
15
  @sidebar_options = { position: :right }
16
+
17
+ validate_sidebar_options!(options)
18
+
19
+ collapsible = options.fetch(:collapsible, false)
20
+ start_collapsed = options.fetch(:start_collapsed, false)
21
+
22
+ apply_collapsible_options(start_collapsed) if collapsible
23
+ end
24
+
25
+ private
26
+
27
+ def validate_sidebar_options!(options)
28
+ if options.key?(:collapsed)
29
+ raise ArgumentError,
30
+ "The :collapsed option has been removed in v3. " \
31
+ "Use `collapsible: true, start_collapsed: true` instead."
32
+ end
33
+ end
34
+
35
+ def apply_collapsible_options(start_collapsed)
36
+ handle_sidebar_toggle_request
37
+ toggled = (session[:aas_toggled] || []).include?(controller_name)
38
+ is_collapsed = toggled ? !start_collapsed : start_collapsed
39
+ @sidebar_options.merge!(
40
+ collapsible: true,
41
+ is_collapsed: is_collapsed
42
+ )
16
43
  end
17
44
 
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
45
+ def handle_sidebar_toggle_request
46
+ if request.xhr? && params[:collapsed_sidebar].present?
47
+ toggled = session[:aas_toggled] || []
48
+ if toggled.include?(controller_name)
49
+ toggled -= [controller_name]
50
+ else
51
+ toggled += [controller_name]
24
52
  end
53
+ session[:aas_toggled] = toggled
54
+ render json: { collapsed_sidebar: params[:collapsed_sidebar] } and return
25
55
  end
26
56
  end
27
57
 
@@ -1,3 +1,3 @@
1
1
  module ActiveAdminSidebar
2
- VERSION = '2.0.0'.freeze
2
+ VERSION = '3.0.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_admin_sidebar
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2020-10-30 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activeadmin
@@ -16,14 +15,20 @@ dependencies:
16
15
  requirements:
17
16
  - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: '0'
18
+ version: '3.0'
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: '4.0'
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
23
25
  requirements:
24
26
  - - ">="
25
27
  - !ruby/object:Gem::Version
26
- version: '0'
28
+ version: '3.0'
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: '4.0'
27
32
  description: extension for activeadmin gem to manage sidebar
28
33
  email:
29
34
  - fedoronchuk@gmail.com
@@ -31,30 +36,18 @@ executables: []
31
36
  extensions: []
32
37
  extra_rdoc_files: []
33
38
  files:
34
- - ".travis.yml"
35
- - Gemfile
36
39
  - LICENSE
37
40
  - README.md
38
- - Rakefile
39
- - active_admin_sidebar.gemspec
40
41
  - app/assets/javascripts/active_admin_sidebar.js
41
42
  - app/assets/stylesheets/active_admin_sidebar.scss
42
- - app/assets/stylesheets/active_admin_sidebar_pure_icons.scss
43
43
  - lib/active_admin_sidebar.rb
44
44
  - lib/active_admin_sidebar/activeadmin_views_pages_base.rb
45
45
  - lib/active_admin_sidebar/positions.rb
46
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
54
- homepage: https://github.com/Fivell/active_admin_sidebar
55
- licenses: []
47
+ homepage: https://github.com/activeadmin-plugins/active_admin_sidebar
48
+ licenses:
49
+ - MIT
56
50
  metadata: {}
57
- post_install_message:
58
51
  rdoc_options: []
59
52
  require_paths:
60
53
  - lib
@@ -62,21 +55,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
62
55
  requirements:
63
56
  - - ">="
64
57
  - !ruby/object:Gem::Version
65
- version: '0'
58
+ version: '3.3'
66
59
  required_rubygems_version: !ruby/object:Gem::Requirement
67
60
  requirements:
68
61
  - - ">="
69
62
  - !ruby/object:Gem::Version
70
63
  version: '0'
71
64
  requirements: []
72
- rubyforge_project:
73
- rubygems_version: 2.7.6.2
74
- signing_key:
65
+ rubygems_version: 3.6.9
75
66
  specification_version: 4
76
67
  summary: active_admin_sidebar gem
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
68
+ test_files: []
data/.travis.yml DELETED
@@ -1,23 +0,0 @@
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 DELETED
@@ -1,18 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in activeadmin_scoped_collection_actions.gemspec
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/Rakefile DELETED
@@ -1,7 +0,0 @@
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 }
@@ -1,21 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "active_admin_sidebar/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = "active_admin_sidebar"
7
- s.version = ActiveAdminSidebar::VERSION
8
- s.authors = ["Igor"]
9
- s.email = ["fedoronchuk@gmail.com"]
10
- s.homepage = "https://github.com/Fivell/active_admin_sidebar"
11
- s.summary = %q{active_admin_sidebar gem}
12
- s.description = %q{extension for activeadmin gem to manage sidebar}
13
-
14
- s.add_dependency "activeadmin"
15
-
16
- s.files = `git ls-files`.split("\n")
17
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
- s.require_paths = ["lib"]
20
-
21
- end
@@ -1,66 +0,0 @@
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/screen/sidebar.jpg DELETED
Binary file
@@ -1,53 +0,0 @@
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 DELETED
@@ -1,50 +0,0 @@
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
@@ -1,21 +0,0 @@
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
@@ -1,13 +0,0 @@
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
@@ -1,49 +0,0 @@
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 DELETED
@@ -1,15 +0,0 @@
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