inline_forms 1.6.63 → 1.6.64

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NmE0ZmJlNWEyNjc5ODY0YTdkYjhmNWY1MmFhYjk0OTUzNzhkMjQzYQ==
4
+ NGYzMTU4NmM5NGQyMGQxMmFmNmQ1YTVhODBmMjQyZmE3OGZhYmZmMA==
5
5
  data.tar.gz: !binary |-
6
- YjViZGMyYTVkNTIwNTc0NGMxNzYxNjM1NTBmZTRhMzlkM2QxM2IwNQ==
6
+ ZjQzMzA4OTQxMDQ2ZDUxNmFjODc5MWJmMmQ5NWRhOWM5OTJmMjMxOA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZTg4YWNlMzhlMDFmNzg2OGIwZDBhMjAwNmY3OThjMzY0MWE2NmZhYTA4ZDg1
10
- ZTQyN2RkZGFjNWIxMmUyY2NhMmZkZDM4MjQ2OGZmODY3YzJiOTViOWQyMDIx
11
- MDI1YTAwNjZhNjhkZjdlMzk3OWI4N2Y0YWU2MTdjNWQxOWY1YjA=
9
+ YjdkNzA1ZTM5MWZiNjNlMGE2YzNhMzE0MGFlNmNmZWFkZWM0ODM2ZmM2YTkw
10
+ NGYzZTlhZDEyMTdlZWE1ZWZkZGUwOGM5MDkwMzE2OTU5OWFjZWIwOTEyODUw
11
+ NGRlNTllNTVjODZjYWQyYzhkNjc0MjI5ZGI1YjZhOWRkNDBhMzM=
12
12
  data.tar.gz: !binary |-
13
- NjQyMTdkZDE3YWIzNWQ1ODM3NmFjMDE4N2NjNjU1ZDE2Yzc2Yjc2NDE4MjBh
14
- M2QyN2QwMjA0M2Y2MjA5NjFjMmFiNmE4ZTYwNDVkMTU3NDY4MTgxYjYwNjUy
15
- M2IzMzkyNjA5ZWM0ZTU0MzdhNDhjNDhmODg3N2Q1ZmE1OWQ1M2Y=
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
- foreign_key = object.class.reflect_on_association(attribute.to_sym).options[:foreign_key] || attribute.to_s.foreign_key.to_sym
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.to_s + '_other']
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
- foreign_key = object.class.reflect_on_association(attribute.to_sym).options[:foreign_key] || attribute.to_s.foreign_key.to_sym
19
- # object.send('build_' + attribute.to_s) unless object.send(attribute)
20
- o = attribute.capitalize.constantize
21
- if cancan_enabled?
22
- values = o.accessible_by(current_ability).order(o.order_by_clause)
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.to_s + '_other'], 0] unless object[attribute.to_s + '_other'].nil? || object[attribute.to_s + '_other'].empty?
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], prompt: 'maake een keuze'}, {id: '_' + object.class.to_s.underscore + '_' + object.id.to_s + '_' + foreign_key.to_s})
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.to_s + '_other]'
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.to_s.foreign_key.to_s
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
- foreign_key = object.class.reflect_on_association(attribute.to_sym).options[:foreign_key] || attribute.to_s.foreign_key.to_sym
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.to_s + "_other").to_sym]
142
+ other = params[('_' + object.class.to_s.underscore).to_sym][(attribute + "_other").to_sym]
144
143
  # see if it matches anything
145
- match = attribute.capitalize.constantize.where(name: other).first # problem if there are dupes!
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.to_s + '_other'] = other : object[attribute.to_s + '_other'] = nil
146
+ match.nil? ? object[attribute + '_other'] = other : object[attribute + '_other'] = nil
148
147
  end
149
148
 
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module InlineForms
3
- VERSION = "1.6.63"
3
+ VERSION = "1.6.64"
4
4
  end
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.63
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-22 00:00:00.000000000 Z
11
+ date: 2014-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rvm