inline_forms 3.0.34 → 3.0.35
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/app/helpers/form_elements/dropdown.rb +13 -10
- data/lib/inline_forms/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZTE0NTA5NjRkMGQ3Y2YzYTViYTJkM2YxMjQ1ZDdhZGJmZTNlZDg3OA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NWRhNDBhYmY0NGQ1YzZmYTVhZjQ1YTNmMDE1YjI0NzdmNmFmMjE3Nw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MThmNTE3NzE1OTY1NDliNjkyZTcxYjBmMzRmOTE4NmU4NDA2MjZjMzBkNGE2
|
10
|
+
NDJjOWU3ZTdkYWMwOTRlYTg0OGVmMWNkOWEyZDU0YmZmNDkxMDkxMDc3ZThh
|
11
|
+
NWU4NzFjM2YzNTYwNDIzOTg4ZjhkMjM0MWMwY2I2YjQ4YjM4NDM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDhmMmIxZGUwNmVhYzFjMjQxMGMxOTU4NDk5MzA3MmQ2NmFlZmYzNDNlMTFl
|
14
|
+
YjVhZjU2N2RhYmMwNTNjZDNhOTNhOGIyNTJmMTYzMzQ3ZjNhMTUyYzUzZGI3
|
15
|
+
YWUyZjJhYTI1ZjVhODhjYzc5YjFlODdmYWU3YzE5MjdmNDk0Zjg=
|
@@ -3,24 +3,27 @@ InlineForms::SPECIAL_COLUMN_TYPES[:dropdown]=:belongs_to
|
|
3
3
|
|
4
4
|
# dropdown
|
5
5
|
def dropdown_show(object, attribute)
|
6
|
-
|
6
|
+
attr = object.send attribute
|
7
|
+
presentation = "_presentation"
|
8
|
+
presentation = "_dropdown_presentation" if attr.respond_to? "_dropdown_presentation"
|
9
|
+
attribute_value = object.send(attribute).send(presentation) rescue "<i class='fi-plus'></i>".html_safe
|
7
10
|
link_to_inline_edit object, attribute, attribute_value
|
8
11
|
end
|
9
12
|
|
10
13
|
def dropdown_edit(object, attribute)
|
11
|
-
object.send('build_' + attribute.to_s) unless object.send(attribute)
|
12
|
-
|
14
|
+
#object.send('build_' + attribute.to_s) unless object.send(attribute)
|
15
|
+
attr = object.send attribute
|
16
|
+
presentation = "_presentation"
|
17
|
+
presentation = "_dropdown_presentation" if attr.respond_to? "_dropdown_presentation"
|
18
|
+
klass = attribute.to_s.singularize.camelcase.constantize
|
13
19
|
if cancan_enabled?
|
14
|
-
values =
|
20
|
+
values = klass.accessible_by(current_ability)
|
15
21
|
else
|
16
|
-
values =
|
22
|
+
values = klass.all
|
17
23
|
end
|
18
|
-
values.
|
19
|
-
v.name = v._presentation
|
20
|
-
end
|
21
|
-
values.sort_by! &:name
|
24
|
+
values.sort_by! {|v|v.send presentation}
|
22
25
|
# the leading underscore is to avoid name conflicts, like 'email' and 'email_type' will result in 'email' and 'email[email_type_id]' in the form!
|
23
|
-
collection_select( ('_' + object.class.to_s.underscore).to_sym, attribute.to_s.foreign_key.to_sym, values, 'id',
|
26
|
+
collection_select( ('_' + object.class.to_s.underscore).to_sym, attribute.to_s.foreign_key.to_sym, values, 'id', presentation, :selected => (object.send(attribute).id rescue nil) )
|
24
27
|
end
|
25
28
|
|
26
29
|
def dropdown_update(object, attribute)
|
data/lib/inline_forms/version.rb
CHANGED