inline_forms 1.0.13 → 1.0.14
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/app/controllers/inline_forms_controller.rb +19 -22
- data/app/helpers/inline_forms_helper.rb +14 -12
- data/app/views/inline_forms/_list.html.erb +1 -0
- data/app/views/inline_forms/_show_undo.html.erb +1 -0
- data/app/views/inline_forms/show_undo.js.erb +1 -0
- data/lib/inline_forms/version.rb +1 -1
- metadata +5 -3
@@ -143,19 +143,19 @@ class InlineFormsController < ApplicationController
|
|
143
143
|
#
|
144
144
|
# PUT /examples/1
|
145
145
|
#
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
end
|
146
|
+
def update
|
147
|
+
@object = @Klass.find(params[:id])
|
148
|
+
@attribute = params[:attribute]
|
149
|
+
@form_element = params[:form_element]
|
150
|
+
@sub_id = params[:sub_id]
|
151
|
+
@update_span = params[:update]
|
152
|
+
send("#{@form_element.to_s}_update", @object, @attribute)
|
153
|
+
@object.save
|
154
|
+
#puts "Requested #{request.format}"
|
155
|
+
respond_to do |format|
|
156
|
+
format.js { }
|
158
157
|
end
|
158
|
+
end
|
159
159
|
|
160
160
|
# :show shows one attribute (attribute) from a record (object). It inludes the link to 'edit'
|
161
161
|
#
|
@@ -191,16 +191,13 @@ class InlineFormsController < ApplicationController
|
|
191
191
|
end
|
192
192
|
end
|
193
193
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
# # @@Klass.constantize.destroy
|
202
|
-
# redirect_to(@Klass.constantizes_url)
|
203
|
-
# end
|
194
|
+
def destroy
|
195
|
+
@object = @Klass.find(params[:id])
|
196
|
+
@object.destroy
|
197
|
+
respond_to do |format|
|
198
|
+
format.js { render :show_undo }
|
199
|
+
end
|
200
|
+
end
|
204
201
|
|
205
202
|
|
206
203
|
private
|
@@ -21,6 +21,20 @@ module InlineFormsHelper
|
|
21
21
|
:remote => true
|
22
22
|
end
|
23
23
|
|
24
|
+
# destroy link
|
25
|
+
def link_to_destroy( msg, object, update_span )
|
26
|
+
if cancan_disabled? || ( can? :destroy, object )
|
27
|
+
link_to image_tag( 'trash.png',
|
28
|
+
:class => "trash_icon",
|
29
|
+
:title => 'trash' ),
|
30
|
+
send( object.class.to_s.underscore + '_path',
|
31
|
+
object,
|
32
|
+
:update => update_span ),
|
33
|
+
:method => :delete,
|
34
|
+
:remote => true
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
24
38
|
# link_to_inline_edit
|
25
39
|
def link_to_inline_edit(object, attribute, attribute_value='')
|
26
40
|
attribute_value = h(attribute_value)
|
@@ -40,18 +54,6 @@ module InlineFormsHelper
|
|
40
54
|
end
|
41
55
|
end
|
42
56
|
|
43
|
-
# link to inline image edit
|
44
|
-
# def link_to_inline_image_edit(object, attribute)
|
45
|
-
# text= image_tag object.send(attribute).send('url', :thumb)
|
46
|
-
# link_to text,
|
47
|
-
# send('edit_' + @Klass.to_s.underscore + '_path',
|
48
|
-
# object,
|
49
|
-
# :attribute => attribute.to_s,
|
50
|
-
# :form_element => calling_method.sub(/_[a-z]+$/,''),
|
51
|
-
# :update => "attribute_#{attribute}_#{object.id}" ),
|
52
|
-
# :remote => true
|
53
|
-
# end
|
54
|
-
|
55
57
|
def link_to_new_record(text, model, path_to_new, update_span, parent_class, parent_id)
|
56
58
|
out = ""
|
57
59
|
out << "<li class='new_record_link'>"
|
@@ -68,6 +68,7 @@ they are @object. We need this magic here to rewrite all the @variables to varia
|
|
68
68
|
<% path_to_object = attribute.to_s.singularize.underscore + "_path" %>
|
69
69
|
<% end %>
|
70
70
|
<li id="<%= css_class_id -%>" class="<%= cycle('odd', 'even') -%>" >
|
71
|
+
<%= link_to_destroy('del',object, css_class_id) -%>
|
71
72
|
<%= link_to h(object._presentation),
|
72
73
|
send( path_to_object, object, :update => css_class_id),
|
73
74
|
:remote => true -%>
|
@@ -0,0 +1 @@
|
|
1
|
+
undo
|
@@ -0,0 +1 @@
|
|
1
|
+
$('#<%= @update_span %>').html('<%= escape_javascript(render(:partial => 'inline_forms/show_undo' ))%>')
|
data/lib/inline_forms/version.rb
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: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 14
|
10
|
+
version: 1.0.14
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ace Suares
|
@@ -165,12 +165,14 @@ files:
|
|
165
165
|
- app/views/inline_forms/_list.html.erb
|
166
166
|
- app/views/inline_forms/_new.html.erb
|
167
167
|
- app/views/inline_forms/_show.html.erb
|
168
|
+
- app/views/inline_forms/_show_undo.html.erb
|
168
169
|
- app/views/inline_forms/close.js.erb
|
169
170
|
- app/views/inline_forms/edit.js.erb
|
170
171
|
- app/views/inline_forms/list.js.erb
|
171
172
|
- app/views/inline_forms/new.js.erb
|
172
173
|
- app/views/inline_forms/show.js.erb
|
173
174
|
- app/views/inline_forms/show_element.js.erb
|
175
|
+
- app/views/inline_forms/show_undo.js.erb
|
174
176
|
- app/views/inline_forms/update.js.erb
|
175
177
|
- app/views/layouts/inline_forms.html.erb
|
176
178
|
- inline_forms.gemspec
|