rails_admin_sort_embedded 0.1.1 → 0.1.2

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
2
  SHA1:
3
- metadata.gz: 7a3a89123a545d6635558c8dc335b46ea31fae6f
4
- data.tar.gz: 9ec43c84610451802feb8753a9b48151941ea98b
3
+ metadata.gz: 296262c268c40b46857a44119568e179bd021116
4
+ data.tar.gz: 01e19afc1ec69e02bc1dee0e34a8097bd5b006a0
5
5
  SHA512:
6
- metadata.gz: 917a7a92b8cf96a99f032d9918041da9fcfac9baae563cbb5baedac7b84380b4282ab49f14a271ab44184060404d594c99f3cba29bcec12ccdfd1a87ed514593
7
- data.tar.gz: 13859eee5e3652d9899e83ece40815b0a2a03cc7517250b65da70aab9a57cb9d57cb6db684565267e4721c42b1887268e55c81fbf162909b704bdaf5bafb00fa
6
+ metadata.gz: 84a89bfbce46518730bec065ed47e613d177c7e67a38a2d931f0878cd3516042b6375994d1e9ec73835a24b22b067221056b9375680c0b347a964b6c18447ad8
7
+ data.tar.gz: 57fa4dc82449e1f575d1e1d39d7dd7586fba69f4418fa43c0bad820a5ee9f622a9f382e4fe2fdca02e22ffe3534bef58ff979e54a2c049d9dcaf42901af74728
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.2.0
1
+ 2.2.2
data/README.md CHANGED
@@ -55,6 +55,7 @@ In parent model:
55
55
  rails_admin do ...
56
56
  sort_embedded({
57
57
  fields: [{model: [:order_field_1, :order_scope_1]}, {model: [:order_field_2, :order_scope_2]}...],
58
+ label_methods: [:name, :label],
58
59
  toggle_fields: [:enabled],
59
60
  thumbnail_fields: [:image, :cover],
60
61
  thumbnail_size: :thumb,
@@ -2,7 +2,7 @@
2
2
 
3
3
  show_flash = (selector, data)->
4
4
  $flash = $('<div>')
5
- .addClass('nestable-flash alert')
5
+ .addClass('sort-embedded-flash alert')
6
6
  .append($('<button>').addClass('close').data('dismiss', 'alert').html('&times;'))
7
7
  .append($('<span>').addClass('body').html(data))
8
8
  $(selector).append($flash)
@@ -2,194 +2,196 @@
2
2
  * jQuery Nestable
3
3
  */
4
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
5
 
16
- .dd-list, .dd-list ol {
17
- display: block;
6
+ .rails_admin_sort_embedded {
7
+
18
8
  position: relative;
19
- margin: 0;
20
- padding: 0;
21
- list-style: none;
22
- }
9
+ margin-bottom: 100px;
23
10
 
24
- .dd-list ol {
25
- padding-left: 30px;
26
- }
11
+ .dd {
12
+ position: relative;
13
+ display: block;
14
+ margin: 0;
15
+ padding: 0;
16
+ /* max-width: 600px; */
17
+ list-style: none;
18
+ font-size: 13px;
19
+ line-height: 20px;
20
+ }
27
21
 
28
- .dd-item, .dd-placeholder {
29
- display: block;
30
- position: relative;
31
- margin: 0;
32
- padding: 0;
33
- min-height: 20px;
34
- font-size: 13px;
35
- line-height: 20px;
36
- }
22
+ .dd-list, .dd-list ol {
23
+ display: block;
24
+ position: relative;
25
+ margin: 0;
26
+ padding: 0;
27
+ list-style: none;
28
+ }
37
29
 
38
- .dd-item .label {
39
- margin-right: 10px;
40
- }
30
+ .dd-list ol {
31
+ padding-left: 30px;
32
+ }
41
33
 
42
- .dd-item img {
43
- display: inline-block;
44
- margin-left: 10px;
45
- }
34
+ .dd-item, .dd-placeholder {
35
+ display: block;
36
+ position: relative;
37
+ margin: 0;
38
+ padding: 0;
39
+ min-height: 20px;
40
+ font-size: 13px;
41
+ line-height: 20px;
42
+ }
46
43
 
47
- .dd-item > div {
48
- // position: relative
49
- }
44
+ .dd-item .label {
45
+ margin-right: 10px;
46
+ }
50
47
 
51
- .dd-handle {
52
- display: block;
53
- position: absolute;
54
- top: 0;
55
- left: 0;
56
- bottom: 0;
57
- width: 30px;
58
- padding: 5px 10px;
59
- color: #333;
60
- text-decoration: none;
61
- font-weight: bold;
62
- border: 1px solid #ccc;
63
- background: #fafafa;
64
- background: -webkit-linear-gradient(top, #fafafa 0%, #eee 100%);
65
- background: -moz-linear-gradient(top, #fafafa 0%, #eee 100%);
66
- background: linear-gradient(top, #fafafa 0%, #eee 100%);
67
- -webkit-border-radius: 3px;
68
- border-radius: 3px;
69
- box-sizing: border-box;
70
- -moz-box-sizing: border-box;
71
- cursor: move;
72
- }
48
+ .dd-item img {
49
+ display: inline-block;
50
+ margin-left: 10px;
51
+ }
73
52
 
74
- .dd-handle:hover {
75
- color: #2ea8e5;
76
- background: #fff;
77
- }
53
+ .dd-item > div {
54
+ // position: relative
55
+ }
78
56
 
79
- .dd-item {
80
- margin-top: 5px
81
- }
57
+ .dd-handle {
58
+ display: block;
59
+ position: absolute;
60
+ top: 0;
61
+ left: 0;
62
+ bottom: 0;
63
+ width: 30px;
64
+ padding: 5px 10px;
65
+ color: #333;
66
+ text-decoration: none;
67
+ font-weight: bold;
68
+ border: 1px solid #ccc;
69
+ background: #fafafa;
70
+ background: -webkit-linear-gradient(top, #fafafa 0%, #eee 100%);
71
+ background: -moz-linear-gradient(top, #fafafa 0%, #eee 100%);
72
+ background: linear-gradient(top, #fafafa 0%, #eee 100%);
73
+ -webkit-border-radius: 3px;
74
+ border-radius: 3px;
75
+ box-sizing: border-box;
76
+ -moz-box-sizing: border-box;
77
+ cursor: move;
78
+ }
82
79
 
83
- .dd-placeholder {
84
- margin: 5px 0;
85
- padding: 0;
86
- min-height: 30px;
87
- background: #f2fbff;
88
- border: 1px dashed #b6bcbf;
89
- &.mjs-nestedSortable-error {
90
- border: 1px solid red;
80
+ .dd-handle:hover {
81
+ color: #2ea8e5;
82
+ background: #fff;
91
83
  }
92
- }
93
84
 
94
- .dd3-content {
95
- display: block;
96
- min-height: 30px;
97
- padding: 5px 10px 5px 40px;
98
- color: #333;
99
- text-decoration: none;
100
- font-weight: bold;
101
- 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;
109
- -moz-box-sizing: border-box;
110
- }
85
+ .dd-item {
86
+ margin-top: 5px
87
+ }
111
88
 
112
- .dd3-content:hover {
113
- color: #2ea8e5;
114
- background: #fff;
115
- }
89
+ .dd-placeholder {
90
+ margin: 5px 0;
91
+ padding: 0;
92
+ min-height: 30px;
93
+ background: #f2fbff;
94
+ border: 1px dashed #b6bcbf;
95
+ &.mjs-nestedSortable-error {
96
+ border: 1px solid red;
97
+ }
98
+ }
116
99
 
117
- .dd-dragel > .dd3-item > .dd3-content {
118
- margin: 0;
119
- }
100
+ .dd3-content {
101
+ display: block;
102
+ min-height: 30px;
103
+ padding: 5px 10px 5px 40px;
104
+ color: #333;
105
+ text-decoration: none;
106
+ font-weight: bold;
107
+ border: 1px solid #ccc;
108
+ background: #fafafa;
109
+ background: -webkit-linear-gradient(top, #fafafa 0%, #eee 100%);
110
+ background: -moz-linear-gradient(top, #fafafa 0%, #eee 100%);
111
+ background: linear-gradient(top, #fafafa 0%, #eee 100%);
112
+ -webkit-border-radius: 3px;
113
+ border-radius: 3px;
114
+ box-sizing: border-box;
115
+ -moz-box-sizing: border-box;
116
+ }
120
117
 
121
- .dd3-item > button {
122
- margin-left: 30px;
123
- }
118
+ .dd3-content:hover {
119
+ color: #2ea8e5;
120
+ background: #fff;
121
+ }
124
122
 
125
- .dd3-handle {
126
- position: absolute;
127
- margin: 0;
128
- left: 0;
129
- top: 0;
130
- cursor: pointer;
131
- width: 30px;
132
- text-indent: 100px;
133
- white-space: nowrap;
134
- overflow: hidden;
135
- border: 1px solid #aaa;
136
- background: #ddd;
137
- background: -webkit-linear-gradient(top, #ddd 0%, #bbb 100%);
138
- background: -moz-linear-gradient(top, #ddd 0%, #bbb 100%);
139
- background: linear-gradient(top, #ddd 0%, #bbb 100%);
140
- border-top-right-radius: 0;
141
- border-bottom-right-radius: 0;
142
- }
123
+ .dd-dragel > .dd3-item > .dd3-content {
124
+ margin: 0;
125
+ }
143
126
 
144
- .dd3-handle:before {
145
- content: '≡';
146
- display: block;
147
- position: absolute;
148
- left: 0;
149
- top: 3px;
150
- width: 100%;
151
- text-align: center;
152
- text-indent: 0;
153
- color: #fff;
154
- font-size: 20px;
155
- font-weight: normal;
156
- }
127
+ .dd3-item > button {
128
+ margin-left: 30px;
129
+ }
157
130
 
158
- .dd3-handle:hover {
159
- background: #ddd;
160
- }
131
+ .dd3-handle {
132
+ position: absolute;
133
+ margin: 0;
134
+ left: 0;
135
+ top: 0;
136
+ cursor: pointer;
137
+ width: 30px;
138
+ text-indent: 100px;
139
+ white-space: nowrap;
140
+ overflow: hidden;
141
+ border: 1px solid #aaa;
142
+ background: #ddd;
143
+ background: -webkit-linear-gradient(top, #ddd 0%, #bbb 100%);
144
+ background: -moz-linear-gradient(top, #ddd 0%, #bbb 100%);
145
+ background: linear-gradient(top, #ddd 0%, #bbb 100%);
146
+ border-top-right-radius: 0;
147
+ border-bottom-right-radius: 0;
148
+ }
161
149
 
162
- .dd3-content .links {
163
- width: auto;
164
- }
150
+ .dd3-handle:before {
151
+ content: '≡';
152
+ display: block;
153
+ position: absolute;
154
+ left: 0;
155
+ top: 3px;
156
+ width: 100%;
157
+ text-align: center;
158
+ text-indent: 0;
159
+ color: #fff;
160
+ font-size: 20px;
161
+ font-weight: normal;
162
+ }
165
163
 
166
- .dd3-content ul.inline.actions {
167
- margin: 0;
168
- padding: 0;
169
- list-style: none;
170
- display: block
171
- }
164
+ .dd3-handle:hover {
165
+ background: #ddd;
166
+ }
172
167
 
173
- .dd3-content ul.inline.actions li {
174
- display: inline-block
175
- }
168
+ .dd3-content .links {
169
+ width: auto;
170
+ }
176
171
 
177
- .dd3-content ul.inline.actions li a {
178
- width: 14px;
179
- height: 16px;
180
- text-decoration: none;
181
- }
172
+ .dd3-content ul.inline.actions {
173
+ margin: 0;
174
+ padding: 0;
175
+ list-style: none;
176
+ display: block
177
+ }
182
178
 
183
- .dd3-content ul.inline.actions li a:hover {
184
- text-decoration: none;
185
- }
179
+ .dd3-content ul.inline.actions li {
180
+ display: inline-block
181
+ }
186
182
 
187
- .rails_admin_nestable {
188
- position: relative;
189
- margin-bottom: 100px;
183
+ .dd3-content ul.inline.actions li a {
184
+ width: 14px;
185
+ height: 16px;
186
+ text-decoration: none;
187
+ }
188
+
189
+ .dd3-content ul.inline.actions li a:hover {
190
+ text-decoration: none;
191
+ }
190
192
  }
191
193
 
192
- .nestable-flash {
194
+ .sort-embedded-flash {
193
195
  position: fixed;
194
196
  top: 80px;
195
197
  width: auto;
@@ -42,11 +42,11 @@
42
42
 
43
43
  .tab-pane{id: "sort_embedded_#{embedded_field}_#{embedded_model_order_field}"}
44
44
  .row-fluid
45
- .span12.rails_admin_nestable{id: "rails_admin_nestable_#{embedded_field}_#{embedded_model_order_field}"}
45
+ .span12.rails_admin_sort_embedded{id: "rails_admin_sort_embedded_#{embedded_field}_#{embedded_model_order_field}"}
46
46
  = rails_admin_sort_embedded @object.send(embedded_field).send(embedded_model_ordered_scope).to_a, {embedded_field: embedded_field, embedded_model_order_field: embedded_model_order_field}
47
47
 
48
48
  - else
49
49
  .tab-pane{id: "sort_embedded_#{f}"}
50
50
  .row-fluid
51
- .span12.rails_admin_nestable{id: "rails_admin_nestable_#{f}_order"}
52
- = rails_admin_sort_embedded @object.send(f).ordered.to_a, {embedded_field: f}
51
+ .span12.rails_admin_sort_embedded{id: "rails_admin_sort_embedded_#{f}_order"}
52
+ = rails_admin_sort_embedded @object.send(f).ordered.to_a, {embedded_field: f}
@@ -8,6 +8,7 @@ module RailsAdminSortEmbedded
8
8
  @options ||= {
9
9
  fields: [{}],
10
10
  thumbnail_fields: [:image, :cover],
11
+ label_methods: [:name, :label],
11
12
  hint_fields: [],
12
13
  thumbnail_size: :thumb,
13
14
  thumbnail_gem: :paperclip,
@@ -38,7 +38,9 @@ module RailsAdminSortEmbedded
38
38
  # end
39
39
  # end
40
40
 
41
- content += content_tag :span, @model_config.with(object: node).object_label
41
+ _title = sort_embedded_label_methods.map { |m| node.send(m) if node.respond_to?(m) }.compact.first
42
+ _title = node.id if _title.blank?
43
+ content += content_tag :span, _title
42
44
 
43
45
  # content += link_to @model_config.with(object: node).object_label, edit_path(@abstract_model, node.id)
44
46
  # content += extra_fields(node)
@@ -110,6 +112,10 @@ module RailsAdminSortEmbedded
110
112
  @sort_conf.options[:fields]
111
113
  end
112
114
 
115
+ def sort_embedded_label_methods
116
+ @sort_conf.options[:label_methods]
117
+ end
118
+
113
119
  # def max_depth
114
120
  # @sort_conf.options[:max_depth] || '0'
115
121
  # end
@@ -1,3 +1,3 @@
1
1
  module RailsAdminSortEmbedded
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_admin_sort_embedded
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Kiseliev
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-25 00:00:00.000000000 Z
12
+ date: 2015-07-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails_admin
@@ -44,7 +44,7 @@ files:
44
44
  - app/assets/javascripts/rails_admin/rails_admin_sort_embedded.js.coffee
45
45
  - app/assets/stylesheets/rails_admin/rails_admin_sort_embedded.css.scss
46
46
  - app/views/rails_admin/main/sort_embedded.html.haml
47
- - config/locales/ru.nested_set.yml
47
+ - config/locales/ru.rails_admin_sort_embedded.yml
48
48
  - lib/rails_admin_sort_embedded.rb
49
49
  - lib/rails_admin_sort_embedded/action.rb
50
50
  - lib/rails_admin_sort_embedded/configuration.rb
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  version: '0'
74
74
  requirements: []
75
75
  rubyforge_project:
76
- rubygems_version: 2.4.5
76
+ rubygems_version: 2.4.7
77
77
  signing_key:
78
78
  specification_version: 4
79
79
  summary: Interface for editing a sorted embedded collections for rails_admin