inline_forms 3.0.34 → 3.0.35

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NWE0ZTA0YTYxM2RhMmMzNzM4M2I2OWViNTBkZWM1MTc1NDFmYTlhNA==
4
+ ZTE0NTA5NjRkMGQ3Y2YzYTViYTJkM2YxMjQ1ZDdhZGJmZTNlZDg3OA==
5
5
  data.tar.gz: !binary |-
6
- OGQ4OTNhODJiNmJlNDJhZDkyOGUwZjA3YjUwZTA5ZDczNjE5ZjQ1Yg==
6
+ NWRhNDBhYmY0NGQ1YzZmYTVhZjQ1YTNmMDE1YjI0NzdmNmFmMjE3Nw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZWM2NmQ2NDNmMzkzMzIyMWE4NjM5NWQ1MTI5NjY2ZWJlOTc0NzA3YjlhYmE5
10
- ZjZmNzc1MTEyOTY4OGYyOTc5YWM1N2E3YjU1OTgwZjg0ZGVlYzVlMDZlYjM3
11
- N2U3OThhMDk3YjM1ZjMzYTliNzJiY2FjOTQyZmJhYWQ3OGU5Mjk=
9
+ MThmNTE3NzE1OTY1NDliNjkyZTcxYjBmMzRmOTE4NmU4NDA2MjZjMzBkNGE2
10
+ NDJjOWU3ZTdkYWMwOTRlYTg0OGVmMWNkOWEyZDU0YmZmNDkxMDkxMDc3ZThh
11
+ NWU4NzFjM2YzNTYwNDIzOTg4ZjhkMjM0MWMwY2I2YjQ4YjM4NDM=
12
12
  data.tar.gz: !binary |-
13
- YjRmMGNhNjk5NjViMzhkMmM0NmUwZGVhMWJjMGNmNjJmNGU0NDViM2MxOWM1
14
- ZDM4ZjFlOWZmOTdlZjkyOTQyNTJjMmExNzg5ZTNjMzhlMjU3ZjM4NmJjZDY4
15
- NmNjNTdhOGFlY2VkZjkzYjVkNmY1ZjE3MDEwYTJmM2M4YmJmMDI=
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
- attribute_value = object.send(attribute)._presentation rescue "<i class='fi-plus'></i>".html_safe
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
- o = object.send(attribute).class.name.constantize
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 = o.accessible_by(current_ability).order(o.order_by_clause)
20
+ values = klass.accessible_by(current_ability)
15
21
  else
16
- values = o.order(o.order_by_clause)
22
+ values = klass.all
17
23
  end
18
- values.each do |v|
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', 'name', :selected => object.send(attribute).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)
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module InlineForms
3
- VERSION = "3.0.34"
3
+ VERSION = "3.0.35"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inline_forms
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.34
4
+ version: 3.0.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ace Suares