inline_forms 1.4.6 → 1.4.7
Sign up to get free protection for your applications and to get access to all the features.
@@ -53,10 +53,10 @@ class InlineFormsController < ApplicationController
|
|
53
53
|
@PER_PAGE = 5 unless @parent_class.nil?
|
54
54
|
# if the parent_class is not nill, we are in associated list and we don't search there.
|
55
55
|
# also, make sure the Model that you want to do a search on has a :name attribute. TODO
|
56
|
-
if @parent_class.nil?
|
56
|
+
if @parent_class.nil? || @Klass.reflect_on_association(@parent_class.underscore.to_sym).nil?
|
57
57
|
conditions = [ @Klass.to_s.tableize + "." + @Klass.order_by_clause + " like ?", "%#{params[:search]}%" ]
|
58
58
|
else
|
59
|
-
foreign_key = @Klass.
|
59
|
+
foreign_key = @Klass.reflect_on_association(@parent_class.underscore.to_sym).options[:foreign_key] || @parent_class.foreign_key
|
60
60
|
conditions = [ "#{foreign_key} = ?", @parent_id ]
|
61
61
|
end
|
62
62
|
# if we are using cancan, then make sure to select only accessible records
|
@@ -84,10 +84,12 @@ class InlineFormsController < ApplicationController
|
|
84
84
|
@object = @Klass.new
|
85
85
|
@update_span = params[:update]
|
86
86
|
@parent_class = params[:parent_class]
|
87
|
-
|
87
|
+
begin
|
88
88
|
@parent_id = params[:parent_id]
|
89
|
-
@
|
90
|
-
|
89
|
+
foreign_key = @Klass.reflect_on_association(@parent_class.underscore.to_sym).options[:foreign_key] || @parent_class.foreign_key
|
90
|
+
@object[foreign_key] = @parent_id
|
91
|
+
end unless @parent_class.nil? || @Klass.reflect_on_association(@parent_class.underscore.to_sym).nil?
|
92
|
+
|
91
93
|
@object.inline_forms_attribute_list = @inline_forms_attribute_list if @inline_forms_attribute_list
|
92
94
|
respond_to do |format|
|
93
95
|
format.js { }
|
@@ -120,10 +122,10 @@ class InlineFormsController < ApplicationController
|
|
120
122
|
@parent_id = params[:parent_id]
|
121
123
|
@PER_PAGE = 5 unless @parent_class.nil?
|
122
124
|
# for the logic behind the :conditions see the #index method.
|
123
|
-
if @parent_class.nil?
|
125
|
+
if @parent_class.nil? || @Klass.reflect_on_association(@parent_class.underscore.to_sym).nil?
|
124
126
|
conditions = [ @Klass.to_s.tableize + "." + @Klass.order_by_clause + " like ?", "%#{params[:search]}%" ]
|
125
127
|
else
|
126
|
-
foreign_key =
|
128
|
+
foreign_key = @Klass.reflect_on_association(@parent_class.underscore.to_sym).options[:foreign_key] || @parent_class.foreign_key
|
127
129
|
conditions = [ "#{foreign_key} = ?", @parent_id ]
|
128
130
|
object[foreign_key] = @parent_id
|
129
131
|
end
|
@@ -24,7 +24,7 @@ def dropdown_edit(object, attribute)
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def dropdown_update(object, attribute)
|
27
|
-
foreign_key = object.
|
27
|
+
foreign_key = object.class.reflect_on_association(attribute.to_sym).options[:foreign_key] || attribute.to_s.foreign_key.to_sym
|
28
28
|
object[foreign_key] = params[('_' + object.class.to_s.underscore).to_sym][attribute.to_s.foreign_key.to_sym]
|
29
29
|
end
|
30
30
|
|
data/lib/inline_forms/version.rb
CHANGED
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: 1.4.
|
4
|
+
version: 1.4.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -202,7 +202,6 @@ files:
|
|
202
202
|
- lib/app/helpers/form_elements/geo_code_curacao.rb
|
203
203
|
- lib/app/helpers/form_elements/image_field.rb
|
204
204
|
- lib/app/helpers/form_elements/info.rb
|
205
|
-
- lib/app/helpers/form_elements/infoadmin.rb
|
206
205
|
- lib/app/helpers/form_elements/plain_text_area.rb
|
207
206
|
- lib/app/helpers/form_elements/question_list.rb
|
208
207
|
- lib/app/helpers/form_elements/radio_button.rb
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
# FIXME not needed here, since this is only used in the views InlineForms::SPECIAL_COLUMN_TYPES[:info]=:string
|
3
|
-
|
4
|
-
def infoadmin_show(object, attribute)
|
5
|
-
object.send(attribute)._presentation rescue ''
|
6
|
-
end
|
7
|
-
|
8
|
-
def infoadmin_edit(object, attribute)
|
9
|
-
object.send('build_' + attribute.to_s) unless object.send(attribute)
|
10
|
-
o = object.send(attribute).class.name.constantize
|
11
|
-
if cancan_enabled?
|
12
|
-
values = o.accessible_by(current_ability).order(o.order_by_clause)
|
13
|
-
else
|
14
|
-
values = o.order(o.order_by_clause)
|
15
|
-
end
|
16
|
-
# 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!
|
17
|
-
collection_select( ('_' + object.class.to_s.underscore).to_sym, attribute.to_s.foreign_key.to_sym, values, 'id', '_presentation', :selected => object.send(attribute).id)
|
18
|
-
end
|
19
|
-
|
20
|
-
def infoadmin_update(object, attribute)
|
21
|
-
object[attribute.to_s.foreign_key.to_sym] = params[('_' + object.class.to_s.underscore).to_sym][attribute.to_s.foreign_key.to_sym]
|
22
|
-
end
|
23
|
-
|