inline_forms 1.6.63 → 1.6.64
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 +8 -8
- data/lib/app/helpers/form_elements/dropdown_with_other.rb +19 -20
- data/lib/inline_forms/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NGYzMTU4NmM5NGQyMGQxMmFmNmQ1YTVhODBmMjQyZmE3OGZhYmZmMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZjQzMzA4OTQxMDQ2ZDUxNmFjODc5MWJmMmQ5NWRhOWM5OTJmMjMxOA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YjdkNzA1ZTM5MWZiNjNlMGE2YzNhMzE0MGFlNmNmZWFkZWM0ODM2ZmM2YTkw
|
10
|
+
NGYzZTlhZDEyMTdlZWE1ZWZkZGUwOGM5MDkwMzE2OTU5OWFjZWIwOTEyODUw
|
11
|
+
NGRlNTllNTVjODZjYWQyYzhkNjc0MjI5ZGI1YjZhOWRkNDBhMzM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDk4YzM4NzY5ZTNjNDcxZTUwODVmM2JlODM3ZjgwZmViNDFmNmQzMjVkNmE1
|
14
|
+
MWRlOTgyMTQ0NjRjMzg0ZjgxNzk1MWQyNDEwZjY2Mjk2MTc1NTlkMjQxZGZh
|
15
|
+
ZTA2ZjdjOTcxODAxNDFhMzZhZjMxZTExNTM4NWM4ZjBhZjllZmQ=
|
@@ -3,10 +3,11 @@ InlineForms::SPECIAL_COLUMN_TYPES[:dropdown_with_other]=:belongs_to
|
|
3
3
|
|
4
4
|
# dropdown
|
5
5
|
def dropdown_with_other_show(object, attribute)
|
6
|
-
|
6
|
+
attribute = attribute.to_s
|
7
|
+
foreign_key = object.class.reflect_on_association(attribute.to_sym).options[:foreign_key] || attribute.foreign_key.to_sym
|
7
8
|
id = object[foreign_key]
|
8
9
|
if id == 0
|
9
|
-
attribute_value = object[attribute
|
10
|
+
attribute_value = object[attribute + '_other']
|
10
11
|
attribute_value = "<i class='fi-plus'></i>".html_safe if attribute_value.nil? || attribute_value.empty?
|
11
12
|
else
|
12
13
|
attribute_value = object.send(attribute)._presentation rescue "<i class='fi-plus'></i>".html_safe
|
@@ -15,23 +16,20 @@ def dropdown_with_other_show(object, attribute)
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def dropdown_with_other_edit(object, attribute)
|
18
|
-
|
19
|
-
|
20
|
-
o = attribute.
|
21
|
-
|
22
|
-
|
23
|
-
else
|
24
|
-
values = o.order(o.order_by_clause)
|
25
|
-
end
|
19
|
+
attribute = attribute.to_s
|
20
|
+
foreign_key = object.class.reflect_on_association(attribute.to_sym).options[:foreign_key] || attribute.foreign_key.to_sym
|
21
|
+
o = attribute.camelcase.constantize
|
22
|
+
values = o.all
|
23
|
+
values = o.accessible_by(current_ability) if cancan_enabled?
|
26
24
|
values.each do |v|
|
27
25
|
v.name = v._presentation
|
28
26
|
end
|
29
|
-
values.sort_by! &:name
|
27
|
+
# values.sort_by! &:name
|
28
|
+
|
30
29
|
collection = values.map {|v|[v.name, v.id]}
|
31
|
-
collection << [object[attribute
|
30
|
+
collection << [object[attribute + '_other'], 0] unless object[attribute + '_other'].nil? || object[attribute + '_other'].empty?
|
32
31
|
out = '<div class="ui-widget">'
|
33
|
-
out << select('_' + object.class.to_s.underscore, foreign_key.to_sym, collection, {selected: object[foreign_key.to_sym]
|
34
|
-
# collection_select( ('_' + object.class.to_s.underscore).to_sym, attribute.to_s.foreign_key.to_sym, values, 'id', 'name', :selected => object.send(attribute).id)
|
32
|
+
out << select('_' + object.class.to_s.underscore, foreign_key.to_sym, collection, {selected: object[foreign_key.to_sym]}, {id: '_' + object.class.to_s.underscore + '_' + object.id.to_s + '_' + foreign_key.to_s})
|
35
33
|
out << '</div>
|
36
34
|
<script>
|
37
35
|
(function( $ ) {
|
@@ -52,7 +50,7 @@ def dropdown_with_other_edit(object, attribute)
|
|
52
50
|
|
53
51
|
this.input = $( "<input name=\''
|
54
52
|
|
55
|
-
out << '_' + object.class.to_s.underscore + '[' + attribute
|
53
|
+
out << '_' + object.class.to_s.underscore + '[' + attribute + '_other]'
|
56
54
|
|
57
55
|
out << '\'>" )
|
58
56
|
.appendTo( this.wrapper )
|
@@ -128,7 +126,7 @@ def dropdown_with_other_edit(object, attribute)
|
|
128
126
|
|
129
127
|
$(function() {
|
130
128
|
$( "'
|
131
|
-
out << '#_' + object.class.to_s.underscore + '_' + object.id.to_s + '_' + attribute.
|
129
|
+
out << '#_' + object.class.to_s.underscore + '_' + object.id.to_s + '_' + attribute.foreign_key.to_s
|
132
130
|
out << '" ).combobox();
|
133
131
|
});
|
134
132
|
</script>'
|
@@ -138,12 +136,13 @@ def dropdown_with_other_edit(object, attribute)
|
|
138
136
|
end
|
139
137
|
|
140
138
|
def dropdown_with_other_update(object, attribute)
|
141
|
-
|
139
|
+
attribute = attribute.to_s
|
140
|
+
foreign_key = object.class.reflect_on_association(attribute.to_sym).options[:foreign_key] || attribute.foreign_key.to_sym
|
142
141
|
# if there is an attribute attr, then there must be an attribute attr_other
|
143
|
-
other = params[('_' + object.class.to_s.underscore).to_sym][(attribute
|
142
|
+
other = params[('_' + object.class.to_s.underscore).to_sym][(attribute + "_other").to_sym]
|
144
143
|
# see if it matches anything
|
145
|
-
match = attribute.
|
144
|
+
match = attribute.camelcase.constantize.where(name: other).first # problem if there are dupes!
|
146
145
|
match.nil? ? object[foreign_key] = 0 : object[foreign_key] = match.id # problem if there is a record with id: 0 !
|
147
|
-
match.nil? ? object[attribute
|
146
|
+
match.nil? ? object[attribute + '_other'] = other : object[attribute + '_other'] = nil
|
148
147
|
end
|
149
148
|
|
data/lib/inline_forms/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inline_forms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.64
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ace Suares
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rvm
|