rails_admin_nestable 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NzMwY2MyYjAwMzczNzk3ZDU0MWVkZjI3OTQ1YzJlODc2ODM1OWUxNQ==
5
+ data.tar.gz: !binary |-
6
+ ZjQ4YWIwYjJkMjkyZTE5ZDNkZTJjYmM1MWZmNDA1YTI2M2VlNjY1ZA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ZGNlM2U4OWUzYjhmNTZlYzRlYzJmOGYyMjNjYjUzNWZhZGVkNjU2ODUwOGM4
10
+ M2FiMzJkYTE3NmQ0MGE3ZjhiOWIzMzdjNjA5NDgxNjMyZDI3ZDZiMTQxNjkw
11
+ ODI3YTNiNGIzZjUyMGZjOWVlNTNlMWM5ZGI0ZmI0MjM5MzUxMTg=
12
+ data.tar.gz: !binary |-
13
+ ZDQ3MDY0YzU2YWJhYTVkZDA1MTQ3NGI2OTc5NDFkMjY5ZWRkMDQzMzhjNzdl
14
+ ZmM5YjY0Y2Q0YjFiZGRhMDY4OGQwNjBhN2Y3NzcxYzM4MDQxN2IzYjQzNmE2
15
+ YTVhMGM0Y2FkMjAxNzEzNjg3ZjI2OGY2NDIxYzJiMGI3ZjRkYzM=
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Reorganise model data with a drag and drop tree/list structure.
4
4
 
5
+ Sample demo available at: https://github.com/dalpo/rails_admin_nestable_demo
6
+
5
7
 
6
8
  ## Installation
7
9
 
@@ -30,12 +32,8 @@ RailsAdmin.config do |config|
30
32
  history_show
31
33
  show_in_app
32
34
 
33
- # Add the nestable action for each model
34
- nestable do
35
- visible do
36
- %w(NavNode Product).include? bindings[:abstract_model].model_name
37
- end
38
- end
35
+ # Add the nestable action for configured models
36
+ nestable
39
37
  end
40
38
  end
41
39
  ```
@@ -89,6 +87,35 @@ RailsAdmin.config do |config|
89
87
  end
90
88
  ```
91
89
 
90
+ ## Authorization with [CanCan](https://github.com/ryanb/cancan)
91
+
92
+ Sample ability:
93
+ ```ruby
94
+ class Ability
95
+ include CanCan::Ability
96
+
97
+ def initialize(user)
98
+ user ||= User.new
99
+
100
+ if user.admin?
101
+ can :access, :rails_admin
102
+ can :dashboard
103
+
104
+ if user.role? :superadmin
105
+ can :manage, :all
106
+ end
107
+
108
+ if user.role? :editor
109
+ can :edit, :all
110
+ can :nestable, :all
111
+ end
112
+ end
113
+ end
114
+ end
115
+
116
+ ```
117
+
118
+
92
119
  ## Screenshot
93
120
 
94
121
  ![Nestable view](https://github.com/dalpo/rails_admin_nestable/raw/master/screenshots/nestable_tree.jpg "nestable view")
@@ -4,7 +4,10 @@ module RailsAdmin
4
4
  class Nestable < Base
5
5
  RailsAdmin::Config::Actions.register(self)
6
6
 
7
- # Is the action acting on the root level (Example: /admin/contact)
7
+ register_instance_option :pjax? do
8
+ false
9
+ end
10
+
8
11
  register_instance_option :root? do
9
12
  false
10
13
  end
@@ -13,7 +16,6 @@ module RailsAdmin
13
16
  true
14
17
  end
15
18
 
16
- # Is the action on an object scope (Example: /admin/team/1/edit)
17
19
  register_instance_option :member? do
18
20
  false
19
21
  end
@@ -70,11 +72,11 @@ module RailsAdmin
70
72
  render text: message
71
73
  else
72
74
  if @nestable_conf.tree?
73
- @tree_nodes = @abstract_model.model.arrange(order: @nestable_conf.options[:position_field])
75
+ @tree_nodes = list_entries(@model_config, :nestable, nil, nil).arrange(order: @nestable_conf.options[:position_field])
74
76
  end
75
77
 
76
78
  if @nestable_conf.list?
77
- @tree_nodes = @abstract_model.model.order(@nestable_conf.options[:position_field])
79
+ @tree_nodes = list_entries(@model_config, :nestable, nil, nil).order(@nestable_conf.options[:position_field])
78
80
  end
79
81
 
80
82
  render action: @action.template_name
@@ -89,6 +91,11 @@ module RailsAdmin
89
91
  register_instance_option :http_methods do
90
92
  [:get, :post]
91
93
  end
94
+
95
+ register_instance_option :visible? do
96
+ current_model = ::RailsAdmin::Config.model(bindings[:abstract_model])
97
+ authorized? && (current_model.nestable_tree || current_model.nestable_list)
98
+ end
92
99
  end
93
100
  end
94
101
  end
@@ -1,3 +1,3 @@
1
1
  module RailsAdminNestable
2
- VERSION = "0.0.9"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,36 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_admin_nestable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
5
- prerelease:
4
+ version: 0.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Andrea Dal Ponte
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-01 00:00:00.000000000 Z
11
+ date: 2013-03-20 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - ! '>='
20
18
  - !ruby/object:Gem::Version
21
- version: '3.2'
19
+ version: '3.1'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - ! '>='
28
25
  - !ruby/object:Gem::Version
29
- version: '3.2'
26
+ version: '3.1'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rails_admin
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ! '>='
36
32
  - !ruby/object:Gem::Version
@@ -38,12 +34,54 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ! '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
- description: Organise Ancestry model into a drag and drop tree structure
41
+ - !ruby/object:Gem::Dependency
42
+ name: haml-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: coffee-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sass-rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Rails Admin plugin to organise Tree/List models with a simple drag and
84
+ drop custom action
47
85
  email:
48
86
  - info@andreadalponte.com
49
87
  executables: []
@@ -69,26 +107,26 @@ files:
69
107
  - README.md
70
108
  homepage: https://github.com/dalpo/rails_admin_nestable
71
109
  licenses: []
110
+ metadata: {}
72
111
  post_install_message:
73
112
  rdoc_options: []
74
113
  require_paths:
75
114
  - lib
76
115
  required_ruby_version: !ruby/object:Gem::Requirement
77
- none: false
78
116
  requirements:
79
117
  - - ! '>='
80
118
  - !ruby/object:Gem::Version
81
119
  version: '0'
82
120
  required_rubygems_version: !ruby/object:Gem::Requirement
83
- none: false
84
121
  requirements:
85
122
  - - ! '>='
86
123
  - !ruby/object:Gem::Version
87
124
  version: '0'
88
125
  requirements: []
89
126
  rubyforge_project:
90
- rubygems_version: 1.8.24
127
+ rubygems_version: 2.0.3
91
128
  signing_key:
92
- specification_version: 3
93
- summary: Organise Ancestry model into a drag and drop tree structure
129
+ specification_version: 4
130
+ summary: Rails Admin plugin to organise Tree/List models with a simple drag and drop
131
+ custom action
94
132
  test_files: []