rails_admin_nestable 0.0.8 → 0.0.9

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.
data/README.md CHANGED
@@ -48,8 +48,9 @@ To use this configuration, you need to organize your tree model with [Ancestry](
48
48
  Otherwise your model have to respond to the `parent`, `arrange` and `children` methods.
49
49
 
50
50
  The `nestable_tree` methods supports the following options:
51
- * `position_field`: (symbol) default `nil`
52
- * `max_depth`: (integer) default `nil`
51
+ * `position_field`: (symbol) default => `nil`
52
+ * `max_depth`: (integer) default => `nil`
53
+ * `enable_callback`: (boolean) default => `false`
53
54
 
54
55
  In your `config/initializers/rails_admin.rb` initializer:
55
56
  ```ruby
@@ -73,6 +74,7 @@ To use this configuration, you need a position field
73
74
 
74
75
  The `nestable_list` methods supports the following options:
75
76
  * `position_field`: (symbol) default `:position`
77
+ * `enable_callback`: (boolean) default => `false`
76
78
 
77
79
  In your `config/initializers/rails_admin.rb` initializer:
78
80
  ```ruby
@@ -0,0 +1,165 @@
1
+ /**
2
+ * jQuery Nestable
3
+ */
4
+
5
+ .dd {
6
+ position: relative;
7
+ display: block;
8
+ margin: 0;
9
+ padding: 0;
10
+ /* max-width: 600px; */
11
+ list-style: none;
12
+ font-size: 13px;
13
+ line-height: 20px;
14
+ }
15
+
16
+ .dd-list {
17
+ display: block;
18
+ position: relative;
19
+ margin: 0;
20
+ padding: 0;
21
+ list-style: none;
22
+ }
23
+ .dd-list .dd-list { padding-left: 30px; }
24
+ .dd-collapsed .dd-list { display: none; }
25
+
26
+ .dd-item,
27
+ .dd-empty,
28
+ .dd-placeholder { display: block; position: relative; margin: 0; padding: 0; min-height: 20px; font-size: 13px; line-height: 20px; }
29
+
30
+ .dd-handle {
31
+ display: block; height: 30px; margin: 5px 0; padding: 5px 10px; color: #333; text-decoration: none; font-weight: bold; border: 1px solid #ccc;
32
+ background: #fafafa;
33
+ background: -webkit-linear-gradient(top, #fafafa 0%, #eee 100%);
34
+ background: -moz-linear-gradient(top, #fafafa 0%, #eee 100%);
35
+ background: linear-gradient(top, #fafafa 0%, #eee 100%);
36
+ -webkit-border-radius: 3px;
37
+ border-radius: 3px;
38
+ box-sizing: border-box; -moz-box-sizing: border-box;
39
+ }
40
+ .dd-handle:hover { color: #2ea8e5; background: #fff; }
41
+
42
+ .dd-item > button { display: block; position: relative; cursor: pointer; float: left; width: 25px; height: 20px; margin: 5px 0; padding: 0; text-indent: 100%; white-space: nowrap; overflow: hidden; border: 0; background: transparent; font-size: 12px; line-height: 1; text-align: center; font-weight: bold; }
43
+ .dd-item > button:before { content: '+'; display: block; position: absolute; width: 100%; text-align: center; text-indent: 0; }
44
+ .dd-item > button[data-action="collapse"]:before { content: '-'; }
45
+
46
+ .dd-placeholder,
47
+ .dd-empty { margin: 5px 0; padding: 0; min-height: 30px; background: #f2fbff; border: 1px dashed #b6bcbf; box-sizing: border-box; -moz-box-sizing: border-box; }
48
+ .dd-empty { border: 1px dashed #bbb; min-height: 100px; background-color: #e5e5e5;
49
+ background-image: -webkit-linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff),
50
+ -webkit-linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff);
51
+ background-image: -moz-linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff),
52
+ -moz-linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff);
53
+ background-image: linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff),
54
+ linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff);
55
+ background-size: 60px 60px;
56
+ background-position: 0 0, 30px 30px;
57
+ }
58
+
59
+ .dd-dragel { position: absolute; pointer-events: none; z-index: 9999; }
60
+ .dd-dragel > .dd-item .dd-handle { margin-top: 0; }
61
+ .dd-dragel .dd-handle {
62
+ -webkit-box-shadow: 2px 4px 6px 0 rgba(0,0,0,.1);
63
+ box-shadow: 2px 4px 6px 0 rgba(0,0,0,.1);
64
+ }
65
+
66
+ /**
67
+ * Nestable Extras
68
+ */
69
+
70
+ .nestable-lists { display: block; clear: both; padding: 30px 0; width: 100%; border: 0; border-top: 2px solid #ddd; border-bottom: 2px solid #ddd; }
71
+
72
+ #nestable-menu { padding: 0; margin: 20px 0; }
73
+
74
+ #nestable-output,
75
+ #nestable2-output { width: 100%; height: 7em; font-size: 0.75em; line-height: 1.333333em; font-family: Consolas, monospace; padding: 5px; box-sizing: border-box; -moz-box-sizing: border-box; }
76
+
77
+ #nestable2 .dd-handle {
78
+ color: #fff;
79
+ border: 1px solid #999;
80
+ background: #bbb;
81
+ background: -webkit-linear-gradient(top, #bbb 0%, #999 100%);
82
+ background: -moz-linear-gradient(top, #bbb 0%, #999 100%);
83
+ background: linear-gradient(top, #bbb 0%, #999 100%);
84
+ }
85
+ #nestable2 .dd-handle:hover { background: #bbb; }
86
+ #nestable2 .dd-item > button:before { color: #fff; }
87
+
88
+ @media only screen and (min-width: 700px) {
89
+
90
+ .dd { float: none; width: auto; }
91
+ .dd + .dd { margin-left: 2%; }
92
+
93
+ }
94
+
95
+ .dd-hover > .dd-handle { background: #2ea8e5 !important; }
96
+
97
+ /**
98
+ * Nestable Draggable Handles
99
+ */
100
+
101
+ .dd3-content { display: block; height: 30px; margin: 5px 0; padding: 5px 10px 5px 40px; color: #333; text-decoration: none; font-weight: bold; border: 1px solid #ccc;
102
+ background: #fafafa;
103
+ background: -webkit-linear-gradient(top, #fafafa 0%, #eee 100%);
104
+ background: -moz-linear-gradient(top, #fafafa 0%, #eee 100%);
105
+ background: linear-gradient(top, #fafafa 0%, #eee 100%);
106
+ -webkit-border-radius: 3px;
107
+ border-radius: 3px;
108
+ box-sizing: border-box; -moz-box-sizing: border-box;
109
+ }
110
+ .dd3-content:hover { color: #2ea8e5; background: #fff; }
111
+
112
+ .dd-dragel > .dd3-item > .dd3-content { margin: 0; }
113
+
114
+ .dd3-item > button { margin-left: 30px; }
115
+
116
+ .dd3-handle {
117
+ position: absolute;
118
+ margin: 0;
119
+ left: 0;
120
+ top: 0;
121
+ cursor: pointer;
122
+ width: 30px;
123
+ text-indent: 100px;
124
+ white-space: nowrap;
125
+ overflow: hidden;
126
+ border: 1px solid #aaa;
127
+ background: #ddd;
128
+ background: -webkit-linear-gradient(top, #ddd 0%, #bbb 100%);
129
+ background: -moz-linear-gradient(top, #ddd 0%, #bbb 100%);
130
+ background: linear-gradient(top, #ddd 0%, #bbb 100%);
131
+ border-top-right-radius: 0;
132
+ border-bottom-right-radius: 0;
133
+ }
134
+ .dd3-handle:before { content: '≡'; display: block; position: absolute; left: 0; top: 3px; width: 100%; text-align: center; text-indent: 0; color: #fff; font-size: 20px; font-weight: normal; }
135
+ .dd3-handle:hover { background: #ddd; }
136
+
137
+ .dd3-content .links {
138
+ width: auto;
139
+ }
140
+ .dd3-content ul.inline.actions {
141
+ margin: 0;
142
+ padding: 0;
143
+ list-style: none;
144
+ display: block
145
+ }
146
+ .dd3-content ul.inline.actions li a {
147
+ width: 14px;
148
+ height: 16px;
149
+ text-decoration: none;
150
+ }
151
+ .dd3-content ul.inline.actions li a:hover {
152
+ text-decoration: none;
153
+ }
154
+
155
+ #rails_admin_nestable {
156
+ position: relative;
157
+ }
158
+ .nestable-flash {
159
+ position: fixed;
160
+ top: 80px;
161
+ width: auto;
162
+ right: 20px;
163
+ display: none;
164
+ min-width: 150px;
165
+ }
@@ -2,8 +2,8 @@ en:
2
2
  admin:
3
3
  actions:
4
4
  nestable:
5
- title: "Sorting"
6
- menu: "Sorting for %{model_label}"
5
+ title: "Sorting for %{model_label}"
6
+ menu: "Sorting"
7
7
  breadcrumb: "Sorting"
8
8
  link: "Sorting"
9
9
  bulk_link: "Sort selected %{model_label_plural}"
@@ -2,8 +2,8 @@ it:
2
2
  admin:
3
3
  actions:
4
4
  nestable:
5
- title: "Ordinamento"
6
- menu: "Ordinamento %{model_label}"
5
+ title: "Ordinamento %{model_label}"
6
+ menu: "Ordinamento"
7
7
  breadcrumb: "Ordinamento"
8
8
  link: "Ordinamento"
9
9
  bulk_link: "Ordinamento %{model_label_plural}"
@@ -15,9 +15,15 @@ module RailsAdminNestable
15
15
 
16
16
  def options
17
17
  if tree?
18
- @nestable_options ||= (tree.class == Hash ? tree : {})
18
+ @nestable_options ||= (tree.class == Hash ? tree : {
19
+ enable_callback: false
20
+ })
19
21
  elsif list?
20
- @nestable_options ||= { position_field: :position, max_depth: 1 }.merge(list.class == Hash ? list : {})
22
+ @nestable_options ||= {
23
+ position_field: :position,
24
+ max_depth: 1,
25
+ enable_callback: false
26
+ }.merge(list.class == Hash ? list : {})
21
27
  end
22
28
 
23
29
  @nestable_options || {}
@@ -35,7 +35,7 @@ module RailsAdmin
35
35
  model.send("#{@nestable_conf.options[:position_field]}=".to_sym, (key.to_i + 1))
36
36
  end
37
37
 
38
- model.save!(validate: false)
38
+ model.save!(validate: @nestable_conf.options[:enable_callback])
39
39
 
40
40
  if value.has_key?('children')
41
41
  update_tree(value['children'], model)
@@ -47,7 +47,7 @@ module RailsAdmin
47
47
  model_list.each do |key, value|
48
48
  model = @abstract_model.model.find(value['id'])
49
49
  model.send("#{@nestable_conf.options[:position_field]}=".to_sym, (key.to_i + 1))
50
- model.save!(validate: false)
50
+ model.save!(validate: @nestable_conf.options[:enable_callback])
51
51
  end
52
52
  end
53
53
 
@@ -69,14 +69,12 @@ module RailsAdmin
69
69
 
70
70
  render text: message
71
71
  else
72
- model_scope = @abstract_model.model.unscoped
73
-
74
72
  if @nestable_conf.tree?
75
- @tree_nodes = model_scope.arrange(order: @nestable_conf.options[:position_field])
73
+ @tree_nodes = @abstract_model.model.arrange(order: @nestable_conf.options[:position_field])
76
74
  end
77
75
 
78
76
  if @nestable_conf.list?
79
- @tree_nodes = model_scope.order(@nestable_conf.options[:position_field])
77
+ @tree_nodes = @abstract_model.model.order(@nestable_conf.options[:position_field])
80
78
  end
81
79
 
82
80
  render action: @action.template_name
@@ -1,3 +1,3 @@
1
1
  module RailsAdminNestable
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_admin_nestable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-03 00:00:00.000000000 Z
12
+ date: 2013-02-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -52,7 +52,7 @@ extra_rdoc_files: []
52
52
  files:
53
53
  - app/assets/javascripts/rails_admin/jquery.nestable.js
54
54
  - app/assets/javascripts/rails_admin/rails_admin_nestable.js.coffee
55
- - app/assets/stylesheets/rails_admin/rails_admin_nestable.css
55
+ - app/assets/stylesheets/rails_admin/rails_admin_nestable.css.scss
56
56
  - app/helpers/rails_admin/nestable_helper.rb
57
57
  - app/views/rails_admin/main/nestable.html.haml
58
58
  - config/locales/nestable.en.yml
@@ -1,158 +0,0 @@
1
- /**
2
- * Nestable
3
- */
4
-
5
- .dd {
6
- position: relative;
7
- display: block;
8
- margin: 0;
9
- padding: 0;
10
- /* max-width: 600px; */
11
- list-style: none;
12
- font-size: 13px;
13
- line-height: 20px; }
14
-
15
- .dd-list {
16
- display: block;
17
- position: relative;
18
- margin: 0;
19
- padding: 0;
20
- list-style: none;
21
- }
22
- .dd-list .dd-list { padding-left: 30px; }
23
- .dd-collapsed .dd-list { display: none; }
24
-
25
- .dd-item,
26
- .dd-empty,
27
- .dd-placeholder { display: block; position: relative; margin: 0; padding: 0; min-height: 20px; font-size: 13px; line-height: 20px; }
28
-
29
- .dd-handle {
30
- display: block; height: 30px; margin: 5px 0; padding: 5px 10px; color: #333; text-decoration: none; font-weight: bold; border: 1px solid #ccc;
31
- background: #fafafa;
32
- background: -webkit-linear-gradient(top, #fafafa 0%, #eee 100%);
33
- background: -moz-linear-gradient(top, #fafafa 0%, #eee 100%);
34
- background: linear-gradient(top, #fafafa 0%, #eee 100%);
35
- -webkit-border-radius: 3px;
36
- border-radius: 3px;
37
- box-sizing: border-box; -moz-box-sizing: border-box;
38
- }
39
- .dd-handle:hover { color: #2ea8e5; background: #fff; }
40
-
41
- .dd-item > button { display: block; position: relative; cursor: pointer; float: left; width: 25px; height: 20px; margin: 5px 0; padding: 0; text-indent: 100%; white-space: nowrap; overflow: hidden; border: 0; background: transparent; font-size: 12px; line-height: 1; text-align: center; font-weight: bold; }
42
- .dd-item > button:before { content: '+'; display: block; position: absolute; width: 100%; text-align: center; text-indent: 0; }
43
- .dd-item > button[data-action="collapse"]:before { content: '-'; }
44
-
45
- .dd-placeholder,
46
- .dd-empty { margin: 5px 0; padding: 0; min-height: 30px; background: #f2fbff; border: 1px dashed #b6bcbf; box-sizing: border-box; -moz-box-sizing: border-box; }
47
- .dd-empty { border: 1px dashed #bbb; min-height: 100px; background-color: #e5e5e5;
48
- background-image: -webkit-linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff),
49
- -webkit-linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff);
50
- background-image: -moz-linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff),
51
- -moz-linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff);
52
- background-image: linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff),
53
- linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff);
54
- background-size: 60px 60px;
55
- background-position: 0 0, 30px 30px;
56
- }
57
-
58
- .dd-dragel { position: absolute; pointer-events: none; z-index: 9999; }
59
- .dd-dragel > .dd-item .dd-handle { margin-top: 0; }
60
- .dd-dragel .dd-handle {
61
- -webkit-box-shadow: 2px 4px 6px 0 rgba(0,0,0,.1);
62
- box-shadow: 2px 4px 6px 0 rgba(0,0,0,.1);
63
- }
64
-
65
- /**
66
- * Nestable Extras
67
- */
68
-
69
- .nestable-lists { display: block; clear: both; padding: 30px 0; width: 100%; border: 0; border-top: 2px solid #ddd; border-bottom: 2px solid #ddd; }
70
-
71
- #nestable-menu { padding: 0; margin: 20px 0; }
72
-
73
- #nestable-output,
74
- #nestable2-output { width: 100%; height: 7em; font-size: 0.75em; line-height: 1.333333em; font-family: Consolas, monospace; padding: 5px; box-sizing: border-box; -moz-box-sizing: border-box; }
75
-
76
- #nestable2 .dd-handle {
77
- color: #fff;
78
- border: 1px solid #999;
79
- background: #bbb;
80
- background: -webkit-linear-gradient(top, #bbb 0%, #999 100%);
81
- background: -moz-linear-gradient(top, #bbb 0%, #999 100%);
82
- background: linear-gradient(top, #bbb 0%, #999 100%);
83
- }
84
- #nestable2 .dd-handle:hover { background: #bbb; }
85
- #nestable2 .dd-item > button:before { color: #fff; }
86
-
87
- @media only screen and (min-width: 700px) {
88
-
89
- .dd { float: none; width: auto; }
90
- .dd + .dd { margin-left: 2%; }
91
-
92
- }
93
-
94
- .dd-hover > .dd-handle { background: #2ea8e5 !important; }
95
-
96
- /**
97
- * Nestable Draggable Handles
98
- */
99
-
100
- .dd3-content { display: block; height: 30px; margin: 5px 0; padding: 5px 10px 5px 40px; color: #333; text-decoration: none; font-weight: bold; border: 1px solid #ccc;
101
- background: #fafafa;
102
- background: -webkit-linear-gradient(top, #fafafa 0%, #eee 100%);
103
- background: -moz-linear-gradient(top, #fafafa 0%, #eee 100%);
104
- background: linear-gradient(top, #fafafa 0%, #eee 100%);
105
- -webkit-border-radius: 3px;
106
- border-radius: 3px;
107
- box-sizing: border-box; -moz-box-sizing: border-box;
108
- }
109
- .dd3-content:hover { color: #2ea8e5; background: #fff; }
110
-
111
- .dd-dragel > .dd3-item > .dd3-content { margin: 0; }
112
-
113
- .dd3-item > button { margin-left: 30px; }
114
-
115
- .dd3-handle { position: absolute; margin: 0; left: 0; top: 0; cursor: pointer; width: 30px; text-indent: 100%; white-space: nowrap; overflow: hidden;
116
- border: 1px solid #aaa;
117
- background: #ddd;
118
- background: -webkit-linear-gradient(top, #ddd 0%, #bbb 100%);
119
- background: -moz-linear-gradient(top, #ddd 0%, #bbb 100%);
120
- background: linear-gradient(top, #ddd 0%, #bbb 100%);
121
- border-top-right-radius: 0;
122
- border-bottom-right-radius: 0;
123
- }
124
- .dd3-handle:before { content: '≡'; display: block; position: absolute; left: 0; top: 3px; width: 100%; text-align: center; text-indent: 0; color: #fff; font-size: 20px; font-weight: normal; }
125
- .dd3-handle:hover { background: #ddd; }
126
-
127
- .dd3-content .links {
128
- width: auto;
129
- }
130
- .dd3-content ul.inline.actions {
131
- margin: 0;
132
- padding: 0;
133
- list-style: none;
134
- display: block
135
- }
136
- .dd3-content ul.inline.actions li {
137
- display: inline;
138
- }
139
- .dd3-content ul.inline.actions li a {
140
- width: 14px;
141
- height: 16px;
142
- text-decoration: none;
143
- }
144
- .dd3-content ul.inline.actions li a:hover {
145
- text-decoration: none;
146
- }
147
-
148
- #rails_admin_nestable {
149
- position: relative;
150
- }
151
- .nestable-flash {
152
- position: fixed;
153
- top: 80px;
154
- width: auto;
155
- right: 20px;
156
- display: none;
157
- min-width: 150px;
158
- }