Skip to content

Commit 03aff3f

Browse files
committed
[Fix browsermedia#723] Deleting Form Entries works
1 parent e1009d5 commit 03aff3f

File tree

7 files changed

+26
-15
lines changed

7 files changed

+26
-15
lines changed

.ruby-gemset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
rails_4.0
1+
browsercms

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ end
1919

2020
group :development do
2121
gem 'rake'
22-
gem 'debugger'
22+
# gem 'debugger'
2323
gem 'quiet_assets'
2424
end
2525
group :test, :development do

Gemfile.lock

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ GEM
7878
activesupport (>= 3.0)
7979
cocaine (0.5.3)
8080
climate_control (>= 0.0.3, < 1.0)
81-
columnize (0.3.6)
8281
compass (0.12.2)
8382
chunky_png (~> 1.2)
8483
fssm (>= 0.2.7)
@@ -97,12 +96,6 @@ GEM
9796
nokogiri (>= 1.5.0)
9897
daemons (1.1.9)
9998
database_cleaner (1.2.0)
100-
debugger (1.6.2)
101-
columnize (>= 0.3.1)
102-
debugger-linecache (~> 1.2.0)
103-
debugger-ruby_core_source (~> 1.2.3)
104-
debugger-linecache (1.2.0)
105-
debugger-ruby_core_source (1.2.3)
10699
devise (3.2.2)
107100
bcrypt-ruby (~> 3.0)
108101
orm_adapter (~> 0.1)
@@ -259,7 +252,6 @@ DEPENDENCIES
259252
cucumber
260253
cucumber-rails
261254
database_cleaner
262-
debugger
263255
factory_girl_rails (= 3.3.0)
264256
launchy
265257
m (~> 1.2)

app/controllers/cms/form_entries_controller.rb

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,31 @@ def submit
3232
end
3333
end
3434

35+
def bulk_update
36+
# Duplicates ContentBlockController#bulk_update
37+
ids = params[:content_id] || []
38+
models = ids.collect do |id|
39+
FormEntry.find(id.to_i)
40+
end
41+
42+
if params[:commit] == 'Delete'
43+
deleted = models.select do |m|
44+
m.destroy
45+
end
46+
flash[:notice] = "Deleted #{deleted.size} records."
47+
end
48+
49+
redirect_to entries_path(params[:form_id])
50+
end
51+
3552
# Same behavior as ContentBlockController#index
3653
def index
37-
form = Cms::Form.where(id: params[:id]).first
54+
@form = Cms::Form.where(id: params[:id]).first
3855
@blocks = Cms::FormEntry.where(form_id: params[:id]).paginate({page: params[:page], order: params[:order]})
39-
@entry = Cms::FormEntry.for(form)
56+
@entry = Cms::FormEntry.for(@form)
4057

4158
# Allows us to use the content_block/index view
42-
@content_type = FauxContentType.new(form)
59+
@content_type = FauxContentType.new(@form)
4360
@search_filter = SearchFilter.build(params[:search_filter], Cms::FormEntry)
4461
@total_number_of_items = @blocks.size
4562
end
@@ -115,5 +132,6 @@ def columns_for_index
115132
def content_type
116133
@content_type
117134
end
135+
118136
end
119137
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<% content_for :bulk_actions do %>
22
<%= render 'buttons' %>
3+
<%= hidden_field_tag :form_id, @form.id %>
34
<% end %>
45
<%= render file: 'cms/content_block/index' %>

config/routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
post :submit
9595
end
9696
end
97-
97+
put "/form_entries" => "form_entries#bulk_update"
9898
# Faux nested resource for forms (not sure if #content_blocks allows for it.)
9999
get 'forms/:id/entries' => 'form_entries#index', as: 'entries'
100100

features/content_blocks/forms.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Feature: Forms
22

33
Editors should be able to create and manage forms to collect information from site visitors. They should be able
4-
to build these forms dyamically through the UI.
4+
to build these forms dynamically through the UI.
55

66
Background:
77
Given I am logged in as a Content Editor

0 commit comments

Comments
 (0)