inline_forms 0.5.2 → 0.5.3
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/LICENSE.txt
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.3
|
@@ -1,16 +1,28 @@
|
|
1
1
|
INLINE_FORMS_PATH = File.dirname(__FILE__) + "/form_elements/"
|
2
2
|
|
3
3
|
Dir[INLINE_FORMS_PATH + "*.rb"].each do |form_element|
|
4
|
-
|
4
|
+
require form_element
|
5
5
|
end
|
6
6
|
|
7
7
|
module InlineFormsHelper
|
8
|
-
|
9
|
-
def inline_form_display(object, attributes, action=:show)
|
8
|
+
def inline_form(object, attributes) #, collapsed=true)
|
10
9
|
attributes = [ attributes ] if not attributes[0].is_a?(Array) # make sure we have an array of arrays
|
11
10
|
out = String.new #ugly as hell but that's how content_tag works...
|
12
|
-
|
13
|
-
|
11
|
+
# if collapsed
|
12
|
+
# then
|
13
|
+
# name_cell = content_tag :td, :valign=>'top' do
|
14
|
+
# content_tag :div, :class=> "field_name" do
|
15
|
+
# h(object.presentation)
|
16
|
+
# end
|
17
|
+
# end
|
18
|
+
# value_cell = content_tag :td, :valign=>'top' do
|
19
|
+
# content_tag :div, :class=> "field_value" do
|
20
|
+
# link_to 'edit', send( @Klass.to_s.underscore + '_path', object, :update => 'inline_form_list'), :remote => true
|
21
|
+
# end
|
22
|
+
# end
|
23
|
+
# out += content_tag :tr, name_cell + value_cell
|
24
|
+
# out += "\n"
|
25
|
+
# else
|
14
26
|
attributes.each do | attribute, name, form_element, values |
|
15
27
|
#css_class_id = form_element == :associated ? "subform_#{attribute.to_s}_#{object.id}" : "field_#{attribute.to_s}_#{object.id}"
|
16
28
|
css_class_id = "field_#{attribute.to_s}_#{object.id}"
|
@@ -22,33 +34,37 @@ module InlineFormsHelper
|
|
22
34
|
value_cell = content_tag :td, :valign=>'top' do
|
23
35
|
content_tag :div, :class=> "field_value field_#{attribute.to_s} form_element_#{form_element.to_s}" do
|
24
36
|
content_tag :span, :id => css_class_id do
|
25
|
-
send("#{form_element.to_s}
|
37
|
+
send("#{form_element.to_s}_show", object, attribute, values)
|
26
38
|
end
|
27
39
|
end
|
28
40
|
end
|
29
41
|
out += content_tag :tr, name_cell + value_cell
|
30
42
|
out += "\n"
|
31
43
|
end
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
44
|
+
# end
|
45
|
+
return content_tag :table, raw(out), :cellspacing => 0, :cellpadding => 0
|
46
|
+
end
|
47
|
+
|
48
|
+
def inline_form_display_new(object, attributes)
|
49
|
+
attributes = [ attributes ] if not attributes[0].is_a?(Array) # make sure we have an array of arrays
|
50
|
+
out = String.new #ugly as hell but that's how content_tag works...
|
51
|
+
attributes.each do | attribute, name, form_element, values |
|
52
|
+
#css_class_id = form_element == :associated ? "subform_#{attribute.to_s}_#{object.id}" : "field_#{attribute.to_s}_#{object.id}"
|
53
|
+
if not form_element.to_sym == :associated
|
54
|
+
css_class_id = "field_#{attribute.to_s}_#{object.id}"
|
55
|
+
name_cell = content_tag :td, :valign=>'top' do
|
56
|
+
content_tag :div, :class=> "field_name field_#{attribute.to_s} form_element_#{form_element.to_s}" do
|
57
|
+
h(name)
|
42
58
|
end
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
59
|
+
end
|
60
|
+
value_cell = content_tag :td, :valign=>'top' do
|
61
|
+
content_tag :div, :class=> "field_value field_#{attribute.to_s} form_element_#{form_element.to_s}" do
|
62
|
+
content_tag :span, :id => css_class_id do
|
63
|
+
send("#{form_element.to_s}_edit", object, attribute, values)
|
48
64
|
end
|
49
65
|
end
|
50
|
-
out += content_tag :tr, name_cell + value_cell
|
51
66
|
end
|
67
|
+
out += content_tag :tr, name_cell + value_cell
|
52
68
|
end
|
53
69
|
end
|
54
70
|
return content_tag :table, raw(out), :cellspacing => 0, :cellpadding => 0
|
@@ -58,7 +74,7 @@ module InlineFormsHelper
|
|
58
74
|
t = ''
|
59
75
|
objects.each do |object|
|
60
76
|
t += content_tag tag do
|
61
|
-
|
77
|
+
inline_form object, object.respond_to?(:inline_forms_field_list) ? object.inline_forms_field_list : [ :name, 'name', 'text' ]
|
62
78
|
end
|
63
79
|
end
|
64
80
|
return raw(t)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<% form_tag send(@Klass.to_s.underscore.pluralize + '_path', :update => @update_span || 'inline_form_list' ),
|
2
2
|
:multipart => true, :remote => true, :class => "edit_form" do -%>
|
3
3
|
<div class="edit_form_field">
|
4
|
-
<%=
|
4
|
+
<%= inline_form_display_new(@object, @object.respond_to?(:inline_forms_field_list) ? @object.inline_forms_field_list : [ :name, 'name', :text ] ) %>
|
5
5
|
</div>
|
6
6
|
<%= link_to( send(@Klass.to_s.underscore.pluralize + '_path',:update => @update_span || 'inline_form_list'), :remote => true,
|
7
7
|
:class => "edit_form_cancel" ) do %>
|
@@ -4,7 +4,7 @@
|
|
4
4
|
<head>
|
5
5
|
<title><%= h(yield(:title) || "xyxyxyx") %></title>
|
6
6
|
<%= csrf_meta_tag %>
|
7
|
-
<%= stylesheet_link_tag '
|
7
|
+
<%= stylesheet_link_tag 'inline_forms/inline_forms' %>
|
8
8
|
<%= javascript_include_tag :defaults %>
|
9
9
|
<%= yield(:head) %>
|
10
10
|
</head>
|
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.5.
|
8
|
+
s.version = "0.5.3"
|
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-02-
|
12
|
+
s.date = %q{2011-02-08}
|
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: 13
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 3
|
10
|
+
version: 0.5.3
|
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-02-
|
18
|
+
date: 2011-02-08 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|