inline_forms 1.6.0 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/app/assets/stylesheets/inline_forms.css +10 -0
- data/lib/app/controllers/inline_forms_controller.rb +12 -12
- data/lib/app/helpers/form_elements/header.rb +17 -0
- data/lib/app/helpers/form_elements/info.rb +7 -4
- data/lib/app/helpers/inline_forms_helper.rb +1 -1
- data/lib/app/views/inline_forms/_show.html.erb +31 -21
- data/lib/inline_forms/version.rb +1 -1
- metadata +3 -2
@@ -124,6 +124,16 @@ a {
|
|
124
124
|
-webkit-border-radius: 5px;
|
125
125
|
}
|
126
126
|
|
127
|
+
.header {
|
128
|
+
border-bottom: 1px solid #EFCA4B;
|
129
|
+
}
|
130
|
+
|
131
|
+
.form_element_header {
|
132
|
+
padding-top: 7px;
|
133
|
+
font-size: 120%;
|
134
|
+
font-weight: bolder;
|
135
|
+
}
|
136
|
+
|
127
137
|
.input_text_field {
|
128
138
|
width: 600px;
|
129
139
|
height: 1.5em;
|
@@ -61,8 +61,8 @@ class InlineFormsController < ApplicationController
|
|
61
61
|
conditions = [ "#{foreign_key} = ?", @parent_id ]
|
62
62
|
end
|
63
63
|
# if we are using cancan, then make sure to select only accessible records
|
64
|
-
@objects
|
65
|
-
@objects
|
64
|
+
@objects ||= @Klass.accessible_by(current_ability) if cancan_enabled?
|
65
|
+
@objects ||= @Klass
|
66
66
|
@objects = @objects.order(@Klass.table_name + "." + @Klass.order_by_clause) if @Klass.respond_to?(:order_by_clause) && ! @Klass.order_by_clause.nil?
|
67
67
|
@objects = @objects.paginate(
|
68
68
|
:page => params[:page],
|
@@ -78,7 +78,7 @@ class InlineFormsController < ApplicationController
|
|
78
78
|
# an empty form. After pressing OK or Cancel, the list of objects is retrieved
|
79
79
|
# in the same way as :index
|
80
80
|
def new
|
81
|
-
@object
|
81
|
+
@object ||= @Klass.new
|
82
82
|
@update_span = params[:update]
|
83
83
|
@parent_class = params[:parent_class]
|
84
84
|
begin
|
@@ -109,11 +109,11 @@ class InlineFormsController < ApplicationController
|
|
109
109
|
# :create creates the object made with :new.
|
110
110
|
# It then presents the list of objects.
|
111
111
|
def create
|
112
|
-
object
|
112
|
+
@object ||= @Klass.new
|
113
113
|
@update_span = params[:update]
|
114
|
-
attributes = @inline_forms_attribute_list || object.inline_forms_attribute_list
|
114
|
+
attributes = @inline_forms_attribute_list || @object.inline_forms_attribute_list
|
115
115
|
attributes.each do | attribute, name, form_element |
|
116
|
-
send("#{form_element.to_s}_update", object, attribute) unless form_element == :associated
|
116
|
+
send("#{form_element.to_s}_update", @object, attribute) unless form_element == :associated
|
117
117
|
end
|
118
118
|
@parent_class = params[:parent_class]
|
119
119
|
@parent_id = params[:parent_id]
|
@@ -125,22 +125,22 @@ class InlineFormsController < ApplicationController
|
|
125
125
|
else
|
126
126
|
foreign_key = @Klass.reflect_on_association(@parent_class.underscore.to_sym).options[:foreign_key] || @parent_class.foreign_key
|
127
127
|
conditions = [ "#{foreign_key} = ?", @parent_id ]
|
128
|
-
object[foreign_key] = @parent_id
|
128
|
+
@object[foreign_key] = @parent_id
|
129
129
|
end
|
130
|
-
if object.save
|
131
|
-
flash.now[:success] = t('success', :message => object.class.model_name.human)
|
130
|
+
if @object.save
|
131
|
+
flash.now[:success] = t('success', :message => @object.class.model_name.human)
|
132
132
|
@objects = @Klass
|
133
133
|
@objects = @Klass.accessible_by(current_ability) if cancan_enabled?
|
134
134
|
@objects = @objects.order(@Klass.table_name + "." + @Klass.order_by_clause) if @Klass.respond_to?(:order_by_clause) && ! @Klass.order_by_clause.nil?
|
135
135
|
@objects = @objects.paginate :page => params[:page], :per_page => @PER_PAGE || 12, :conditions => conditions
|
136
|
+
@object = nil
|
136
137
|
respond_to do |format|
|
137
138
|
format.js { render :list}
|
138
139
|
end
|
139
140
|
else
|
140
|
-
flash.now[:header] = ["Kan #{object.class.to_s.underscore} niet aanmaken."]
|
141
|
-
flash.now[:error] = object.errors.to_a
|
141
|
+
flash.now[:header] = ["Kan #{@object.class.to_s.underscore} niet aanmaken."]
|
142
|
+
flash.now[:error] = @object.errors.to_a
|
142
143
|
respond_to do |format|
|
143
|
-
@object = object
|
144
144
|
@object.inline_forms_attribute_list = attributes
|
145
145
|
format.js { render :new}
|
146
146
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
# not needed here, since this is only used in the views InlineForms::SPECIAL_COLUMN_TYPES[:header]=:string
|
3
|
+
|
4
|
+
def header_show(object, attribute)
|
5
|
+
# show the header which is the translated fake attribute
|
6
|
+
attribute
|
7
|
+
end
|
8
|
+
|
9
|
+
def header_edit(object, attribute)
|
10
|
+
# just show the header
|
11
|
+
attribute
|
12
|
+
end
|
13
|
+
|
14
|
+
def header_update(object, attribute)
|
15
|
+
# do absolutely nothing
|
16
|
+
end
|
17
|
+
|
@@ -2,15 +2,18 @@
|
|
2
2
|
# not needed here, since this is only used in the views InlineForms::SPECIAL_COLUMN_TYPES[:info]=:string
|
3
3
|
|
4
4
|
def info_show(object, attribute)
|
5
|
-
# show the attribute
|
6
|
-
o = object
|
5
|
+
# show the attribute. if it's a date/time, make it nicer. If it has a _presentation, show that instead
|
6
|
+
o = object.send(attribute)
|
7
7
|
o = o.to_s + " (" + distance_of_time_in_words_to_now(o) + " ago )" if o.is_a?(Time)
|
8
|
+
o = o._presentation if o.respond_to?(:_presentation)
|
8
9
|
o
|
9
10
|
end
|
10
11
|
|
11
12
|
def info_edit(object, attribute)
|
12
|
-
|
13
|
-
|
13
|
+
o = object.send(attribute)
|
14
|
+
o = o.to_s + " (" + distance_of_time_in_words_to_now(o) + " ago )" if o.is_a?(Time)
|
15
|
+
o = o._presentation if o.respond_to?(:_presentation)
|
16
|
+
o
|
14
17
|
end
|
15
18
|
|
16
19
|
def info_update(object, attribute)
|
@@ -84,7 +84,7 @@ module InlineFormsHelper
|
|
84
84
|
if parent_class.nil?
|
85
85
|
raw out
|
86
86
|
else
|
87
|
-
raw out if can? :update, parent_class.find(parent_id)
|
87
|
+
raw out if can? :update, parent_class.find(parent_id) # can update this specific parent object???
|
88
88
|
end
|
89
89
|
end
|
90
90
|
else
|
@@ -15,27 +15,37 @@
|
|
15
15
|
<% attributes.each do | attribute, name, form_element | -%>
|
16
16
|
<% if cancan_disabled? || can?(:read, @object, attribute) %>
|
17
17
|
<% css_class_id = "#{@object.class.name.underscore}_#{@object.id}_#{attribute}" -%>
|
18
|
-
|
19
|
-
<
|
20
|
-
<
|
21
|
-
<%=
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
18
|
+
<% if form_element == :header %>
|
19
|
+
<tr>
|
20
|
+
<td valign="top" class="header" colspan="2">
|
21
|
+
<div class='<%= "attribute_name attribute_#{attribute} form_element_#{form_element}" -%>' >
|
22
|
+
<%= @object.class.human_attribute_name(attribute) -%>
|
23
|
+
</div>
|
24
|
+
</td>
|
25
|
+
</tr>
|
26
|
+
<% else %>
|
27
|
+
<tr>
|
28
|
+
<td valign="top" class="<%= 'has_validations ' if @object.has_validations_for?(attribute) -%>" validation-hint="<%= validation_hints_as_list_for(@object, attribute) -%>">
|
29
|
+
<div class='<%= "attribute_name attribute_#{attribute} form_element_#{form_element}" -%>' >
|
30
|
+
<%= @object.class.human_attribute_name(attribute) -%>
|
31
|
+
</div>
|
32
|
+
</td>
|
33
|
+
<td valign="top">
|
34
|
+
<div class='<%= "attribute_value attribute_#{attribute} form_element_#{form_element}" -%>' >
|
35
|
+
<span id="<%= css_class_id -%>" >
|
36
|
+
<% if form_element == :associated -%>
|
37
|
+
<%= render :partial => "inline_forms/list",
|
38
|
+
:locals => { :parent_class => @object.class,
|
39
|
+
:parent_id => @object.id,
|
40
|
+
:attribute => attribute } %>
|
41
|
+
<% else -%>
|
42
|
+
<%= send("#{form_element}_show", @object, attribute) -%>
|
43
|
+
<% end -%>
|
44
|
+
</span>
|
45
|
+
</div>
|
46
|
+
</td>
|
47
|
+
</tr>
|
48
|
+
<% end -%>
|
39
49
|
<% end -%>
|
40
50
|
<% end -%>
|
41
51
|
</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.6.
|
4
|
+
version: 1.6.1
|
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-10-
|
12
|
+
date: 2012-10-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rvm
|
@@ -232,6 +232,7 @@ files:
|
|
232
232
|
- lib/app/helpers/form_elements/dropdown_with_values.rb
|
233
233
|
- lib/app/helpers/form_elements/file_field.rb
|
234
234
|
- lib/app/helpers/form_elements/geo_code_curacao.rb
|
235
|
+
- lib/app/helpers/form_elements/header.rb
|
235
236
|
- lib/app/helpers/form_elements/image_field.rb
|
236
237
|
- lib/app/helpers/form_elements/info.rb
|
237
238
|
- lib/app/helpers/form_elements/plain_text_area.rb
|