rails_admin_nestable_sb 0.0.2
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +159 -0
- data/Rakefile +27 -0
- data/app/assets/javascripts/rails_admin/jquery.nestable.js +508 -0
- data/app/assets/javascripts/rails_admin/nestable.js +39 -0
- data/app/assets/javascripts/rails_admin/rails_admin_nestable.js.coffee +46 -0
- data/app/assets/stylesheets/rails_admin/rails_admin_nestable.css.scss +165 -0
- data/app/helpers/rails_admin/nestable_helper.rb +4 -0
- data/app/views/rails_admin/main/nestable.html.haml +22 -0
- data/config/locales/nestable.de.yml +14 -0
- data/config/locales/nestable.en.yml +14 -0
- data/config/locales/nestable.es.yml +15 -0
- data/config/locales/nestable.fr.yml +14 -0
- data/config/locales/nestable.it.yml +14 -0
- data/config/locales/nestable.nl.yml +14 -0
- data/config/locales/nestable.ru.yml +14 -0
- data/config/locales/nestable.sv.yml +14 -0
- data/config/locales/nestable.vi.yml +14 -0
- data/lib/rails_admin_nestable/configuration.rb +46 -0
- data/lib/rails_admin_nestable/engine.rb +13 -0
- data/lib/rails_admin_nestable/helper.rb +66 -0
- data/lib/rails_admin_nestable/model.rb +15 -0
- data/lib/rails_admin_nestable/nestable.rb +110 -0
- data/lib/rails_admin_nestable/version.rb +3 -0
- data/lib/rails_admin_nestable_sb.rb +12 -0
- metadata +128 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f02eadbc90e9360b7ef8a59e7d3cb8f4e93723a055f40239b2d7eb5b4a13f740
|
4
|
+
data.tar.gz: f76d442c7db55807b5633852b3d32f8f4bf948871cb14a9d7aa48124549d4070
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 42543ac29a0c954e301d3768aea7893ab347151e393166c868f61560e203a658722264b0c118a40b1cfd452db6b457fe3314fa9346381fb99a6a04fecfd89f29
|
7
|
+
data.tar.gz: 8539b560c3b6064a8c7e08b97dbc35f09a9b30da3989cc68928fe229ab90f64333c7d9f00961990d5548942fef7e49d4c55c9890378ea9c3547dc8267a3ce583
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2015 Andrea Dal Ponte
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
# Rails Admin Nestable modified for SB Technologies
|
2
|
+
|
3
|
+
This is a modified version of the original gem.
|
4
|
+
Nestable Tree option will no longer work as expected in the original Rails Admin Nestable,
|
5
|
+
but instead it allows a relation between a parent and a child class through a foreign key.
|
6
|
+
|
7
|
+
The dependency for the 'Ancestry' gem has been omitted.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
To enable rails_admin_nestable_sb, add the following to your `Gemfile`:
|
12
|
+
|
13
|
+
Add in your `config/initializers/rails_admin.rb` initializer the configuration:
|
14
|
+
```ruby
|
15
|
+
RailsAdmin.config do |config|
|
16
|
+
config.actions do
|
17
|
+
# root actions
|
18
|
+
dashboard # mandatory
|
19
|
+
# collection actions
|
20
|
+
index # mandatory
|
21
|
+
new
|
22
|
+
export
|
23
|
+
history_index
|
24
|
+
bulk_delete
|
25
|
+
# member actions
|
26
|
+
show
|
27
|
+
edit
|
28
|
+
delete
|
29
|
+
history_show
|
30
|
+
show_in_app
|
31
|
+
|
32
|
+
# Add the nestable action for configured models
|
33
|
+
nestable
|
34
|
+
end
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
38
|
+
## Configuration
|
39
|
+
You could choose between two different configurations for your model:
|
40
|
+
|
41
|
+
### 1. Nestable tree (modified):
|
42
|
+
To use this configuration, you need to define your model under the RailsAdmin.config
|
43
|
+
|
44
|
+
The `nestable_tree` methods supports the following options:
|
45
|
+
* `position_field`: (symbol) default `:position`
|
46
|
+
* `child_model`: (Class) required
|
47
|
+
* `foreign_key`: (symbol) required
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
RailsAdmin.config do |config|
|
51
|
+
config.actions do
|
52
|
+
...
|
53
|
+
end
|
54
|
+
|
55
|
+
config.model MyModel do
|
56
|
+
nestable_tree({
|
57
|
+
position_field: :position,
|
58
|
+
child_model: ChildModel,
|
59
|
+
foreign_key: :parent_id
|
60
|
+
})
|
61
|
+
end
|
62
|
+
end
|
63
|
+
```
|
64
|
+
|
65
|
+
### 2. Nestable list:
|
66
|
+
To use this configuration, you need a position field
|
67
|
+
|
68
|
+
The `nestable_list` methods supports the following options:
|
69
|
+
* `position_field`: (symbol) default `:position`
|
70
|
+
* `enable_callback`: (boolean) default => `false`
|
71
|
+
* `scope`: (symbol | proc) default => `nil`
|
72
|
+
* `live_update`: (boolean | :only) default => true (:only is for live updating only)
|
73
|
+
|
74
|
+
In your `config/initializers/rails_admin.rb` initializer:
|
75
|
+
```ruby
|
76
|
+
RailsAdmin.config do |config|
|
77
|
+
config.actions do
|
78
|
+
...
|
79
|
+
end
|
80
|
+
|
81
|
+
config.model MyModel do
|
82
|
+
nestable_list true
|
83
|
+
end
|
84
|
+
end
|
85
|
+
```
|
86
|
+
|
87
|
+
## Authorization with [CanCan](https://github.com/ryanb/cancan)
|
88
|
+
|
89
|
+
Sample ability:
|
90
|
+
```ruby
|
91
|
+
class Ability
|
92
|
+
include CanCan::Ability
|
93
|
+
|
94
|
+
def initialize(user)
|
95
|
+
user ||= User.new
|
96
|
+
|
97
|
+
if user.admin?
|
98
|
+
can :access, :rails_admin
|
99
|
+
can :dashboard
|
100
|
+
|
101
|
+
if user.role? :superadmin
|
102
|
+
can :manage, :all
|
103
|
+
end
|
104
|
+
|
105
|
+
if user.role? :editor
|
106
|
+
can :edit, :all
|
107
|
+
can :nestable, :all
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
```
|
114
|
+
|
115
|
+
## Contributing
|
116
|
+
Submitting a Pull Request:
|
117
|
+
|
118
|
+
1. [Fork the repository.][fork]
|
119
|
+
2. [Create a topic branch.][branch]
|
120
|
+
3. Implement your feature or bug fix.
|
121
|
+
4. Add, commit, and push your changes.
|
122
|
+
5. [Submit a pull request.][pr]
|
123
|
+
|
124
|
+
[fork]: http://help.github.com/fork-a-repo/
|
125
|
+
[branch]: http://learn.github.com/p/branching.html
|
126
|
+
[pr]: http://help.github.com/send-pull-requests/
|
127
|
+
|
128
|
+
|
129
|
+
## Thanks
|
130
|
+
|
131
|
+
* [Carlo Scortegagna](https://github.com/carloscortegagna)
|
132
|
+
* [Andrea Zaupa](https://github.com/andreazaupa)
|
133
|
+
* [Rails Admin](https://github.com/sferik/rails_admin)
|
134
|
+
* [Nestable](http://dbushell.github.com/Nestable)
|
135
|
+
* [To see the generous people who have contributed code, take a look at the contributors page](https://github.com/dalpo/rails_admin_nestable/graphs/contributors)
|
136
|
+
|
137
|
+
## License
|
138
|
+
**This project rocks and uses MIT-LICENSE.**
|
139
|
+
|
140
|
+
Copyright 2015 Andrea Dal Ponte
|
141
|
+
|
142
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
143
|
+
a copy of this software and associated documentation files (the
|
144
|
+
"Software"), to deal in the Software without restriction, including
|
145
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
146
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
147
|
+
permit persons to whom the Software is furnished to do so, subject to
|
148
|
+
the following conditions:
|
149
|
+
|
150
|
+
The above copyright notice and this permission notice shall be
|
151
|
+
included in all copies or substantial portions of the Software.
|
152
|
+
|
153
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
154
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
155
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
156
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
157
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
158
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
159
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'RailsAdminNestable'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|