Permalink
Browse files

Add remove button to assigned voice number on campaign details page

  • Loading branch information...
1 parent e785f4c commit 32699db7a34e9e08fce7354bacbefdc49473b934 Willa committed Nov 5, 2012
Showing with 17 additions and 3 deletions.
  1. +0 −1 lib/crowdring/ask.rb
  2. +12 −1 lib/crowdring/crowdring.rb
  3. +1 −1 lib/views/campaign.haml
  4. +4 −0 lib/views/voice_numbers.haml
View
@@ -106,7 +106,6 @@ class VoicemailAsk < Ask
has n, :voicemails, through: Resource, constraint: :destroy
-
def handle?(type, ringer)
type == :voice && super(type, ringer)
end
View
@@ -224,6 +224,17 @@ def process_request(service_name, request, response_type)
haml :tag_new
end
+ post '/campaign/:id/update' do
+ params.delete(params[:splat])
+ params.delete(params[:captures])
+ campaign = Campaign.get(params[:id])
+ if params[:voice_number_id]
+ campaign.voice_numbers.get(params[:voice_number_id]).destroy
+ flash[:notice] = "Voice number has been removed"
+ end
+ redirect to("/campaigns##{campaign.id}")
+ end
+
post '/tags/create' do
tag = Tag.from_str(params[:type] + ':' + params[:value])
if tag.saved?
@@ -245,7 +256,7 @@ def process_request(service_name, request, response_type)
voicemail = Voicemail.get(params[:id])
voicemail.update(filename: params[:RecordUrl])
end
-
+
not_found do
haml :not_found
end
View
@@ -26,7 +26,7 @@
#campaign-details
%h2= "Title: #{@campaign.title}"
#voice-number
- =haml :voice_numbers, locals:{voice_numbers: @campaign.voice_numbers}
+ =haml :voice_numbers, locals:{campaign: @campaign}
%a{href: "/campaign/#{@campaign.id}/assign_voice_number"} Assign another
%h2 SMS Number
%h3
@@ -1,7 +1,11 @@
#voice-numbers
%h2 Voice Numbers
+ -voice_numbers = campaign.voice_numbers
-if voice_numbers.empty?
%h3 No voice number selected
-else
-voice_numbers.each do |voice_number|
%h4= "Phone Number: #{voice_number.pretty_phone_number}, Description: #{voice_number.description}"
+ %form{action: "/campaign/#{campaign.id}/update", method: 'post'}
+ %input{type: 'hidden', name: 'voice_number_id', value: "#{voice_number.id}"}
+ %button{type: 'submit'} Remove

0 comments on commit 32699db

Please sign in to comment.