inline_forms 0.9.7 → 0.9.8
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.
data/README.rdoc
CHANGED
@@ -7,7 +7,7 @@ Ever tired of setting up forms to manage your data? Inline Forms aims at quick a
|
|
7
7
|
Look in the generator files for a hint about usage. In short:
|
8
8
|
rails g inline_forms Person first_name:string last_name:string age:dropdown_with_integers
|
9
9
|
will create a model, a migration an a controller. In the model you would only have to add
|
10
|
-
values for the dropdown,
|
10
|
+
values for the dropdown, for instance 12..45.
|
11
11
|
In going to /persons you would see a nice form to add and edit persons.
|
12
12
|
|
13
13
|
It's work in progress.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.8
|
@@ -53,11 +53,12 @@ class InlineFormsController < ApplicationController
|
|
53
53
|
update_span = params[:update]
|
54
54
|
@parent_class = params[:parent_class]
|
55
55
|
@parent_id = params[:parent_id]
|
56
|
+
@ul_needed = params[:ul_needed]
|
56
57
|
@parent_class.nil? ? conditions = [] : conditions = [ "#{@parent_class.foreign_key} = ?", @parent_id ]
|
57
58
|
if cancan_enabled?
|
58
|
-
@objects = @Klass.accessible_by(current_ability).paginate :page => params[:page], :
|
59
|
+
@objects = @Klass.accessible_by(current_ability).order(@Klass.order_by_clause).paginate :page => params[:page], :conditions => conditions
|
59
60
|
else
|
60
|
-
@objects = @Klass.paginate :page => params[:page], :
|
61
|
+
@objects = @Klass.order(@Klass.order_by_clause).paginate :page => params[:page], :conditions => conditions
|
61
62
|
end
|
62
63
|
|
63
64
|
respond_to do |format|
|
@@ -124,9 +125,9 @@ class InlineFormsController < ApplicationController
|
|
124
125
|
@parent_id = params[:parent_id]
|
125
126
|
@parent_class.nil? ? conditions = [] : conditions = [ "#{@parent_class.foreign_key} = ?", @parent_id ]
|
126
127
|
if cancan_enabled?
|
127
|
-
@objects = @Klass.accessible_by(current_ability).paginate :page => params[:page], :
|
128
|
+
@objects = @Klass.accessible_by(current_ability).order(@Klass.order_by_clause).paginate :page => params[:page], :conditions => conditions
|
128
129
|
else
|
129
|
-
@objects = @Klass.paginate :page => params[:page], :
|
130
|
+
@objects = @Klass.order(@Klass.order_by_clause).paginate :page => params[:page], :conditions => conditions
|
130
131
|
end
|
131
132
|
|
132
133
|
respond_to do |format|
|
@@ -16,9 +16,9 @@ end
|
|
16
16
|
def check_list_edit(object, attribute)
|
17
17
|
object.send(attribute).build if object.send(attribute).empty?
|
18
18
|
if cancan_enabled?
|
19
|
-
values = object.send(attribute).first.class.name.constantize.accessible_by(current_ability)
|
19
|
+
values = object.send(attribute).first.class.name.constantize.accessible_by(current_ability).order(@Klass.order_by_clause)
|
20
20
|
else
|
21
|
-
values = object.send(attribute).first.class.name.constantize.
|
21
|
+
values = object.send(attribute).first.class.name.constantize.order(@Klass.order_by_clause)
|
22
22
|
end
|
23
23
|
out = '<div class="edit_form_checklist">'
|
24
24
|
out << '<ul>'
|
@@ -9,9 +9,9 @@ end
|
|
9
9
|
def dropdown_edit(object, attribute)
|
10
10
|
object.send('build_' + attribute.to_s) unless object.send(attribute)
|
11
11
|
if cancan_enabled?
|
12
|
-
values = object.send(attribute).class.name.constantize.accessible_by(current_ability)
|
12
|
+
values = object.send(attribute).class.name.constantize.accessible_by(current_ability).order(@Klass.order_by_clause)
|
13
13
|
else
|
14
|
-
values = object.send(attribute).class.name.constantize.
|
14
|
+
values = object.send(attribute).class.name.constantize.order(@Klass.order_by_clause)
|
15
15
|
end
|
16
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
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)
|
@@ -29,14 +29,21 @@ they are @object. We need this magic here to rewrite all the @variables to varia
|
|
29
29
|
<% parent_class=@parent_class %>
|
30
30
|
<% parent_id=@parent_id %>
|
31
31
|
<% objects = @objects %>
|
32
|
-
<% ul_needed = false %>
|
32
|
+
<% ul_needed = false unless @ul_needed %>
|
33
33
|
<% end %>
|
34
34
|
<% else %>
|
35
35
|
<% # here we come from _show %>
|
36
36
|
<% update_span = "#{parent_class.to_s.underscore}_#{parent_id}_#{attribute}_list" -%>
|
37
37
|
<% human_readable_class = attribute.to_s.singularize.humanize.downcase %>
|
38
38
|
<% path_to_new='new_' + attribute.to_s.singularize + '_path' %>
|
39
|
-
<%
|
39
|
+
<% conditions = [ "#{parent_class.name.foreign_key} = ?", parent_id ] %>
|
40
|
+
|
41
|
+
<% if cancan_enabled? %>
|
42
|
+
<% objects = parent_class.find(parent_id).send(attribute).accessible_by(current_ability).order(@Klass.order_by_clause).paginate :page => params[:page], :conditions => conditions %>
|
43
|
+
<% else %>
|
44
|
+
<% objects = parent_class.find(parent_id).send(attribute).order(@Klass.order_by_clause).paginate :page => params[:page], :conditions => conditions %>
|
45
|
+
<% end %>
|
46
|
+
|
40
47
|
<% end %>
|
41
48
|
|
42
49
|
<% if ul_needed %>
|
@@ -59,6 +66,11 @@ they are @object. We need this magic here to rewrite all the @variables to varia
|
|
59
66
|
:remote => true -%>
|
60
67
|
</li>
|
61
68
|
<% end -%>
|
69
|
+
<% if parent_id.nil? -%>
|
70
|
+
<%= will_paginate objects -%>
|
71
|
+
<% else %>
|
72
|
+
<%= will_paginate objects, :ajax => true, :params => {:controller => attribute, :action => :index, :id => nil, :parent_class => parent_class, :parent_id => parent_id, :update => "#{parent_class.to_s.underscore}_#{parent_id}_#{attribute}", :ul_needed => true } -%>
|
73
|
+
<% end %>
|
62
74
|
<% if ul_needed %>
|
63
75
|
</ul>
|
64
76
|
<% end %>
|
data/inline_forms.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{inline_forms}
|
8
|
-
s.version = "0.9.
|
8
|
+
s.version = "0.9.8"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ace Suares"]
|
12
|
-
s.date = %q{2011-05-
|
12
|
+
s.date = %q{2011-05-29}
|
13
13
|
s.description = %q{Inline Forms aims to ease the setup of forms that provide inline editing. The field list can be specified in the model.}
|
14
14
|
s.email = %q{ace@suares.an}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inline_forms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 43
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 8
|
10
|
+
version: 0.9.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ace Suares
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-05-
|
18
|
+
date: 2011-05-29 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|