inline_forms 1.3.40 → 1.3.41
Sign up to get free protection for your applications and to get access to all the features.
@@ -42,8 +42,7 @@ class InlineFormsController < ApplicationController
|
|
42
42
|
|
43
43
|
helper_method :cancan_disabled?, :cancan_enabled?
|
44
44
|
|
45
|
-
load_and_authorize_resource if cancan_enabled?
|
46
|
-
|
45
|
+
load_and_authorize_resource :except => :revert if cancan_enabled?
|
47
46
|
# :index shows a list of all objects from class @Klass, using will_paginate,
|
48
47
|
# including a link to 'new', that allows you to create a new record.
|
49
48
|
def index
|
@@ -57,7 +56,8 @@ class InlineFormsController < ApplicationController
|
|
57
56
|
if @parent_class.nil?
|
58
57
|
conditions = [ @Klass.order_by_clause.to_s + " like ?", "%#{params[:search]}%" ]
|
59
58
|
else
|
60
|
-
|
59
|
+
foreign_key = @Klass.first.association(@parent_class.underscore.to_sym).reflection.options[:foreign_key] || @parent_class.foreign_key
|
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?
|
@@ -120,11 +120,10 @@ class InlineFormsController < ApplicationController
|
|
120
120
|
@parent_id = params[:parent_id]
|
121
121
|
@PER_PAGE = 5 unless @parent_class.nil?
|
122
122
|
# for the logic behind the :conditions see the #index method.
|
123
|
-
|
124
|
-
|
125
|
-
|
123
|
+
foreign_key = object.association(@parent_class.underscore.to_sym).reflection.options[:foreign_key] || @parent_class.foreign_key
|
124
|
+
@parent_class.nil? ? conditions = [ @Klass.order_by_clause.to_s + " like ?", "%#{params[:search]}%" ] : conditions = [ "#{foreign_key} = ?", @parent_id ]
|
125
|
+
object[foreign_key] = @parent_id unless @parent_class.nil?
|
126
126
|
if object.save
|
127
|
-
puts "AFTER SAVE IF #{object.id} #{object.name}"
|
128
127
|
flash.now[:success] = t('success', :message => object.class.model_name.human)
|
129
128
|
if cancan_enabled?
|
130
129
|
@objects = @Klass.accessible_by(current_ability).order(@Klass.order_by_clause).paginate :page => params[:page], :per_page => @PER_PAGE || 12, :conditions => conditions
|
@@ -134,7 +133,6 @@ class InlineFormsController < ApplicationController
|
|
134
133
|
respond_to do |format|
|
135
134
|
format.js { render :list}
|
136
135
|
end
|
137
|
-
puts "*)*)*)#{object.id} #{object.name}"
|
138
136
|
else
|
139
137
|
flash.now[:header] = ["Kan #{object.class.to_s.underscore} niet aanmaken."]
|
140
138
|
flash.now[:error] = object.errors.to_a
|
@@ -209,6 +207,7 @@ class InlineFormsController < ApplicationController
|
|
209
207
|
@version = Version.find(params[:id])
|
210
208
|
@version.reify.save!
|
211
209
|
@object = @Klass.find(@version.item_id)
|
210
|
+
authorize!(:revert, @object)
|
212
211
|
respond_to do |format|
|
213
212
|
format.js { render :close }
|
214
213
|
end
|
@@ -15,8 +15,12 @@ def dropdown_edit(object, attribute)
|
|
15
15
|
else
|
16
16
|
values = o.order(o.order_by_clause)
|
17
17
|
end
|
18
|
+
values.each do |v|
|
19
|
+
v.name = v._presentation
|
20
|
+
end
|
21
|
+
values.sort_by! &:name
|
18
22
|
# 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!
|
19
|
-
collection_select( ('_' + object.class.to_s.underscore).to_sym, attribute.to_s.foreign_key.to_sym, values, 'id', '
|
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)
|
20
24
|
end
|
21
25
|
|
22
26
|
def dropdown_update(object, attribute)
|
@@ -2,7 +2,7 @@
|
|
2
2
|
InlineForms::SPECIAL_COLUMN_TYPES[:image_field]=:string
|
3
3
|
|
4
4
|
def image_field_show(object, attribute)
|
5
|
-
link_to_inline_edit object, attribute, image_tag(
|
5
|
+
link_to_inline_edit object, attribute, image_tag(object.send(attribute).send(:palm).send(:url))
|
6
6
|
end
|
7
7
|
|
8
8
|
def image_field_edit(object, attribute)
|
@@ -38,7 +38,9 @@ they are @object. We need this magic here to rewrite all the @variables to varia
|
|
38
38
|
<% # here we come from _show %>
|
39
39
|
<% update_span = "#{parent_class.to_s.underscore}_#{parent_id}_#{attribute}_list" -%>
|
40
40
|
<% path_to_new='new_' + attribute.to_s.singularize + '_path' %>
|
41
|
-
<%
|
41
|
+
<% foreign_key = parent_class.first.association(attribute.to_sym).reflection.options[:foreign_key] || parent_class.name.foreign_key -%>
|
42
|
+
|
43
|
+
<% conditions = [ "#{foreign_key} = ?", parent_id ] %>
|
42
44
|
<% model = attribute.to_s.singularize.camelcase.constantize %>
|
43
45
|
|
44
46
|
<% if cancan_enabled? %>
|
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.3.
|
4
|
+
version: 1.3.41
|
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-06-
|
12
|
+
date: 2012-06-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rvm
|