inline_forms 0.6.3 → 0.6.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/app/controllers/inline_forms_controller.rb +18 -20
- data/app/helpers/form_elements/associated.rb +2 -2
- data/app/helpers/form_elements/dropdown.rb +2 -2
- data/app/helpers/form_elements/geo_code_curacao.rb +1 -1
- data/app/helpers/inline_forms_helper.rb +21 -35
- data/inline_forms.gemspec +1 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.4
|
@@ -122,10 +122,19 @@ class InlineFormsController < ApplicationController
|
|
122
122
|
end
|
123
123
|
end
|
124
124
|
@update_span = params[:update]
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
125
|
+
if @field.nil?
|
126
|
+
respond_to do |format|
|
127
|
+
@attributes = @object.respond_to?(:inline_forms_field_list) ? @object.inline_forms_field_list : [ :name, 'name', 'text_field' ]
|
128
|
+
# found this here: http://www.ruby-forum.com/topic/211467
|
129
|
+
format.js { render(:update) {|page| page.replace_html @update_span, :inline => '<%= send( "inline_forms_show_record", @object, @attributes) %>' }
|
130
|
+
}
|
131
|
+
end
|
132
|
+
else
|
133
|
+
respond_to do |format|
|
134
|
+
# found this here: http://www.ruby-forum.com/topic/211467
|
135
|
+
format.js { render(:update) {|page| page.replace_html @update_span, :inline => '<%= send("#{@form_element}_show", @object, @field, @values) %>' }
|
136
|
+
}
|
137
|
+
end
|
129
138
|
end
|
130
139
|
end
|
131
140
|
|
@@ -134,27 +143,16 @@ class InlineFormsController < ApplicationController
|
|
134
143
|
#
|
135
144
|
# DELETE /examples/1
|
136
145
|
#
|
137
|
-
# def destroy
|
138
|
-
# # @@Klass.constantize = @Klass.constantize.find(params[:id])
|
139
|
-
# # @@Klass.constantize.destroy
|
140
|
-
# redirect_to(@Klass.constantizes_url)
|
141
|
-
# end
|
146
|
+
# def destroy
|
147
|
+
# # @@Klass.constantize = @Klass.constantize.find(params[:id])
|
148
|
+
# # @@Klass.constantize.destroy
|
149
|
+
# redirect_to(@Klass.constantizes_url)
|
150
|
+
# end
|
142
151
|
|
143
152
|
private
|
144
|
-
# If it's not an XhttpRequest, redirect to the index page for this controller.
|
145
|
-
#
|
146
|
-
# Used in before_filter as a way to limit access to all actions (except :index)
|
147
|
-
# def must_be_xhr_request #:doc:
|
148
|
-
# redirect_to "/#{@Klass_pluralized}" if not request.xhr?
|
149
|
-
# end
|
150
|
-
|
151
153
|
# Get the class
|
152
154
|
# Used in before_filter
|
153
155
|
def getKlass #:doc:
|
154
156
|
@Klass = self.controller_name.classify.constantize
|
155
|
-
#request.request_uri.split(/[\/?]/)[1].classify
|
156
|
-
#@Klass_constantized = @Klass.constantize
|
157
|
-
#@Klass_underscored = @Klass.underscore
|
158
|
-
#@Klass_pluralized = @Klass_underscored.pluralize
|
159
157
|
end
|
160
158
|
end
|
@@ -7,7 +7,7 @@ module InlineFormsHelper
|
|
7
7
|
if @sub_id && @sub_id.to_i > 0
|
8
8
|
# if it's not a new record (sub_id > 0) then just update the list-element
|
9
9
|
out << '<li>'
|
10
|
-
out << link_to( @associated_record.
|
10
|
+
out << link_to( @associated_record._presentation,
|
11
11
|
send('edit_' + @Klass.to_s.underscore + '_path', object,
|
12
12
|
:field => attribute,
|
13
13
|
:sub_id => @sub_id,
|
@@ -36,7 +36,7 @@ module InlineFormsHelper
|
|
36
36
|
object.send(attribute.to_s.pluralize).each do |m|
|
37
37
|
out << "<span id='field_#{attribute.to_s.singularize}_#{m.id.to_s}'>"
|
38
38
|
out << '<li>'
|
39
|
-
out << link_to( m.
|
39
|
+
out << link_to( m._presentation, send('edit_' + @Klass.to_s.underscore + '_path',
|
40
40
|
object,
|
41
41
|
:field => attribute,
|
42
42
|
:sub_id => m.id,
|
@@ -2,14 +2,14 @@ module InlineFormsHelper
|
|
2
2
|
InlineForms::SPECIAL_MIGRATION_TYPES[:dropdown]=:integer
|
3
3
|
# dropdown
|
4
4
|
def dropdown_show(object, attribute, values)
|
5
|
-
attribute_value = object.send(attribute).
|
5
|
+
attribute_value = object.send(attribute)._presentation rescue nil
|
6
6
|
link_to_inline_edit object, attribute, attribute_value, nil
|
7
7
|
end
|
8
8
|
def dropdown_edit(object, attribute, values)
|
9
9
|
object.send('build_' + attribute.to_s) unless object.send(attribute)
|
10
10
|
values = object.send(attribute).class.name.constantize.find(:all) # TODO bring order!
|
11
11
|
# 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!
|
12
|
-
collection_select( ('_' + object.class.to_s.downcase).to_sym, attribute.to_s.foreign_key.to_sym, values, 'id', '
|
12
|
+
collection_select( ('_' + object.class.to_s.downcase).to_sym, attribute.to_s.foreign_key.to_sym, values, 'id', '_presentation', :selected => object.send(attribute).id)
|
13
13
|
end
|
14
14
|
def dropdown_update(object, attribute, values)
|
15
15
|
object[attribute.to_s.foreign_key.to_sym] = params[('_' + object.class.to_s.downcase).to_sym][attribute.to_s.foreign_key.to_sym]
|
@@ -2,7 +2,7 @@ module InlineFormsHelper
|
|
2
2
|
InlineForms::SPECIAL_MIGRATION_TYPES[:geo_code_curacao]=:string
|
3
3
|
# geo_code_curacao
|
4
4
|
def geo_code_curacao_show(object, attribute, values)
|
5
|
-
attribute_value = object.send(attribute).
|
5
|
+
attribute_value = object.send(attribute)._presentation rescue nil
|
6
6
|
link_to_inline_edit object, attribute, attribute_value, nil
|
7
7
|
end
|
8
8
|
def geo_code_curacao_edit(object, attribute, values)
|
@@ -5,44 +5,28 @@ Dir[INLINE_FORMS_PATH + "*.rb"].each do |form_element|
|
|
5
5
|
end
|
6
6
|
|
7
7
|
module InlineFormsHelper
|
8
|
-
def
|
8
|
+
def inline_forms_show_record(object, attributes)
|
9
9
|
attributes = [ attributes ] if not attributes[0].is_a?(Array) # make sure we have an array of arrays
|
10
|
-
out = String.new
|
11
|
-
|
12
|
-
#
|
13
|
-
|
14
|
-
|
15
|
-
#
|
16
|
-
|
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
|
26
|
-
out << h(object._presentation)
|
27
|
-
attributes.each do | attribute, name, form_element, values |
|
28
|
-
#css_class_id = form_element == :associated ? "subform_#{attribute.to_s}_#{object.id}" : "field_#{attribute.to_s}_#{object.id}"
|
29
|
-
css_class_id = "field_#{attribute.to_s}_#{object.id}"
|
30
|
-
name_cell = content_tag :td, :valign=>'top' do
|
31
|
-
content_tag :div, :class=> "field_name field_#{attribute.to_s} form_element_#{form_element.to_s}" do
|
32
|
-
h(name)
|
33
|
-
end
|
10
|
+
out = String.new
|
11
|
+
attributes.each do | attribute, name, form_element, values |
|
12
|
+
#css_class_id = form_element == :associated ? "subform_#{attribute.to_s}_#{object.id}" : "field_#{attribute.to_s}_#{object.id}"
|
13
|
+
css_class_id = "field_#{attribute.to_s}_#{object.id}"
|
14
|
+
name_cell = content_tag :td, :valign=>'top' do
|
15
|
+
content_tag :div, :class=> "field_name field_#{attribute.to_s} form_element_#{form_element.to_s}" do
|
16
|
+
h(name)
|
34
17
|
end
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
18
|
+
end
|
19
|
+
value_cell = content_tag :td, :valign=>'top' do
|
20
|
+
content_tag :div, :class=> "field_value field_#{attribute.to_s} form_element_#{form_element.to_s}" do
|
21
|
+
content_tag :span, :id => css_class_id do
|
22
|
+
send("#{form_element.to_s}_show", object, attribute, values)
|
40
23
|
end
|
41
24
|
end
|
42
|
-
out += content_tag :tr, name_cell + value_cell
|
43
|
-
out += "\n"
|
44
25
|
end
|
45
|
-
|
26
|
+
out += content_tag :tr, name_cell + value_cell
|
27
|
+
out += "\n"
|
28
|
+
end
|
29
|
+
# end
|
46
30
|
return content_tag :table, raw(out), :cellspacing => 0, :cellpadding => 0
|
47
31
|
end
|
48
32
|
|
@@ -74,8 +58,10 @@ out << h(object._presentation)
|
|
74
58
|
def inline_form_display_list(objects, tag=:li)
|
75
59
|
t = ''
|
76
60
|
objects.each do |object|
|
77
|
-
|
78
|
-
|
61
|
+
css_class_id = @Klass.to_s.underscore + '_' + object.id.to_s
|
62
|
+
t += content_tag tag, :id => css_class_id do
|
63
|
+
#inline_forms_show_record object, object.respond_to?(:inline_forms_field_list) ? object.inline_forms_field_list : [ :name, 'name', 'text_field' ]
|
64
|
+
link_to( h( object._presentation ), send( @Klass.to_s.underscore + '_path', object, :update => css_class_id), :remote => true )
|
79
65
|
end
|
80
66
|
end
|
81
67
|
return raw(t)
|
data/inline_forms.gemspec
CHANGED
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: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 4
|
10
|
+
version: 0.6.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ace Suares
|