Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

remove broadcast tab from campaign page, add launch button to danglin…

…g ask. need to fix the broadcast route.
  • Loading branch information...
commit 76772a1d0267af9c780360e715ba588708834717 1 parent e71e660
Willa authored
Showing with 19 additions and 20 deletions.
  1. +8 −3 lib/crowdring/crowdring.rb
  2. +11 −17 lib/views/campaign.haml
View
11 lib/crowdring/crowdring.rb
@@ -304,7 +304,9 @@ def process_request(service_name, request, response_type)
message = params[:campaign][:message]
ask = Ask.create(type: ask_name, message: message)
- campaign.asks.last.triggered_ask = ask
+ if trigger_by == 'previous'
+ campaign.asks.last.triggered_ask = ask
+ end
campaign.asks << ask
if campaign.save
flash[:notice] = "New Ask Add"
@@ -387,12 +389,15 @@ def process_request(service_name, request, response_type)
campaign = Campaign.get(params[:id])
from = params[:from] || campaign.sms_number.raw_number
message = params[:message]
+ unless message
+ flash[:errors] = "Ask needs a prompt to launch"
+ redirect to("/campaigns##{campaign.id}")
+ end
+
rings = Filter.create(params[:filter]).filter(Campaign.get(params[:id]).rings)
to = rings.map(&:ringer).map(&:phone_number)
Server.service_handler.broadcast(from, message, to)
- campaign.most_recent_broadcast = DateTime.now
- campaign.save
flash[:notice] = "Message broadcast"
redirect to("/campaigns##{campaign.id}")
View
28 lib/views/campaign.haml
@@ -14,8 +14,8 @@
%a{href: "#campaign-overview"}
%span Campaign Details
%li
- %a{href: "#broadcast"}
- %span BroadCast
+ %a{href: "#basic-chart"}
+ %span Statistic Analysis
%li
%a{href: "#export"}
%span Export To CSV
@@ -49,23 +49,15 @@
#asks
%h2= "ASKS"
-@campaign.asks.each do |ask|
+ -if @campaign.asks.select{|n| n.triggered_ask && n.triggered_ask == ask}.empty?
+ %form{action: "/campaign/#{@campaign.id}/broadcast", method: "post"}
+ %input{type: 'hidden', name: 'message', value: "#{ask.message}"}
+ %button{type:'submit'} Launch the Ask
+
=haml :ask, locals: {ask: ask, type: ask.class.typesym}
- %form{action: "/campaign/#{@campaign.id}/add_new_ask", method: 'get'}
+ %form{action: "/campaign/#{@campaign.id}/add_new_ask", method: 'get'}
%button Add new ask
- #broadcast.form-box
- %h3 Broadcast
- %form{name: 'broadcast', action: "/campaign/#{@campaign.id}/broadcast", method: 'post'}
- #filter-container
- #broadcast-filter.filter-buttons
- %input#all1{type: 'radio', name: 'filter', value: 'all', checked: 'checked'}
- %label.all-label{for: 'all1'}= "All #{@ringer_count}"
- %input#country1{type: 'radio', name: 'filter', value: 'country:'}
- %label{for: 'country1'} Country
- #filter-options{style: 'display:none'}
- %textarea#broadcast-text-area.msg-text-area{name: 'message', placeholder: 'Hello ringers...'}
- %button#broadcastbutton{disabled: 'disabled'} Broadcast
-
#export.form-box
%h3 Export to CSV
%form{name: 'export', action: "/campaign/#{@campaign.id}/csv", method: 'get'}
@@ -80,7 +72,9 @@
%input{type: 'checkbox', name: "fields[#{field.id}]", value: 'yes', checked:field.default? && 'checked'}= field.display_name
%button#exportbutton Export
-#basic-chart= high_chart("basic-chart", @basic_chart)
+ #basic-chart
+ %h3 Statistic Analysis
+ = high_chart("basic-chart", @basic_chart)
#country-options{style: 'display:none'}
%form
Please sign in to comment.
Something went wrong with that request. Please try again.