inline_forms 1.4.4 → 1.4.5
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.
@@ -54,19 +54,19 @@ class InlineFormsController < ApplicationController
|
|
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
56
|
if @parent_class.nil?
|
57
|
-
conditions = [ @Klass.
|
57
|
+
conditions = [ @Klass.to_s.tableize + "." + @Klass.order_by_clause + " like ?", "%#{params[:search]}%" ]
|
58
58
|
else
|
59
59
|
foreign_key = @Klass.first.association(@parent_class.underscore.to_sym).reflection.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
|
63
63
|
if cancan_enabled?
|
64
|
-
@objects = @Klass.accessible_by(current_ability).order(@Klass.order_by_clause).paginate(
|
64
|
+
@objects = @Klass.accessible_by(current_ability).order(@Klass.to_s.tableize + "." + @Klass.order_by_clause).paginate(
|
65
65
|
:page => params[:page],
|
66
66
|
:per_page => @PER_PAGE || 12,
|
67
67
|
:conditions => conditions )
|
68
68
|
else
|
69
|
-
@objects = @Klass.order(@Klass.order_by_clause).paginate(
|
69
|
+
@objects = @Klass.order(@Klass.to_s.tableize + "." + @Klass.order_by_clause).paginate(
|
70
70
|
:page => params[:page],
|
71
71
|
:per_page => @PER_PAGE || 12,
|
72
72
|
:conditions => conditions )
|
@@ -121,7 +121,7 @@ class InlineFormsController < ApplicationController
|
|
121
121
|
@PER_PAGE = 5 unless @parent_class.nil?
|
122
122
|
# for the logic behind the :conditions see the #index method.
|
123
123
|
if @parent_class.nil?
|
124
|
-
conditions = [ @Klass.
|
124
|
+
conditions = [ @Klass.to_s.tableize + "." + @Klass.order_by_clause + " like ?", "%#{params[:search]}%" ]
|
125
125
|
else
|
126
126
|
foreign_key = object.association(@parent_class.underscore.to_sym).reflection.options[:foreign_key] || @parent_class.foreign_key
|
127
127
|
conditions = [ "#{foreign_key} = ?", @parent_id ]
|
@@ -130,9 +130,9 @@ class InlineFormsController < ApplicationController
|
|
130
130
|
if object.save
|
131
131
|
flash.now[:success] = t('success', :message => object.class.model_name.human)
|
132
132
|
if cancan_enabled?
|
133
|
-
@objects = @Klass.accessible_by(current_ability).order(@Klass.order_by_clause).paginate :page => params[:page], :per_page => @PER_PAGE || 12, :conditions => conditions
|
133
|
+
@objects = @Klass.accessible_by(current_ability).order(@Klass.to_s.tableize + "." + @Klass.order_by_clause).paginate :page => params[:page], :per_page => @PER_PAGE || 12, :conditions => conditions
|
134
134
|
else
|
135
|
-
@objects = @Klass.order(@Klass.order_by_clause).paginate :page => params[:page], :per_page => @PER_PAGE || 12, :conditions => conditions
|
135
|
+
@objects = @Klass.order(@Klass.to_s.tableize + "." + @Klass.order_by_clause).paginate :page => params[:page], :per_page => @PER_PAGE || 12, :conditions => conditions
|
136
136
|
end
|
137
137
|
respond_to do |format|
|
138
138
|
format.js { render :list}
|
@@ -157,7 +157,6 @@ class InlineFormsController < ApplicationController
|
|
157
157
|
@update_span = params[:update]
|
158
158
|
send("#{@form_element.to_s}_update", @object, @attribute)
|
159
159
|
@object.save
|
160
|
-
#puts "Requested #{request.format}"
|
161
160
|
respond_to do |format|
|
162
161
|
format.js { }
|
163
162
|
end
|
@@ -54,7 +54,7 @@ module InlineFormsHelper
|
|
54
54
|
spaces = attribute_value.length > 40 ? 0 : 40 - attribute_value.length
|
55
55
|
value = h(attribute_value) + (" " * spaces).html_safe
|
56
56
|
css_class_id = "#{object.class.to_s.underscore}_#{object.id}_#{attribute}"
|
57
|
-
if cancan_disabled? || ( can? :update, object )
|
57
|
+
if cancan_disabled? || ( can? :update, object, attribute )
|
58
58
|
link_to value,
|
59
59
|
send( 'edit_' + object.class.to_s.underscore + '_path',
|
60
60
|
object,
|
@@ -13,27 +13,29 @@
|
|
13
13
|
</tr>
|
14
14
|
<% attributes = @inline_forms_attribute_list || @object.inline_forms_attribute_list -%>
|
15
15
|
<% attributes.each do | attribute, name, form_element | -%>
|
16
|
-
<%
|
17
|
-
|
18
|
-
<
|
19
|
-
<
|
20
|
-
<%=
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
<
|
25
|
-
<
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
16
|
+
<% if cancan_disabled? || can?(:read, @object, attribute) %>
|
17
|
+
<% css_class_id = "#{@object.class.name.underscore}_#{@object.id}_#{attribute}" -%>
|
18
|
+
<tr>
|
19
|
+
<td valign="top" class="<%= 'has_validations ' if @object.has_validations_for?(attribute) -%>" validation-hint="<%= validation_hints_as_list_for(@object, attribute) -%>">
|
20
|
+
<div class='<%= "attribute_name attribute_#{attribute} form_element_#{form_element}" -%>' >
|
21
|
+
<%= @object.class.human_attribute_name(attribute) -%>
|
22
|
+
</div>
|
23
|
+
</td>
|
24
|
+
<td valign="top">
|
25
|
+
<div class='<%= "attribute_value attribute_#{attribute} form_element_#{form_element}" -%>' >
|
26
|
+
<span id="<%= css_class_id -%>" >
|
27
|
+
<% if form_element == :associated -%>
|
28
|
+
<%= render :partial => "inline_forms/list",
|
29
|
+
:locals => { :parent_class => @object.class,
|
30
|
+
:parent_id => @object.id,
|
31
|
+
:attribute => attribute } %>
|
32
|
+
<% else -%>
|
33
|
+
<%= send("#{form_element}_show", @object, attribute) -%>
|
34
|
+
<% end -%>
|
35
|
+
</span>
|
36
|
+
</div>
|
37
|
+
</td>
|
38
|
+
</tr>
|
39
|
+
<% end -%>
|
38
40
|
<% end -%>
|
39
41
|
</table>
|
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.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rvm
|