Implements targets and campaigns for conference

This commit is contained in:
Chrisbr 2014-06-26 09:08:26 +02:00
parent 678fe38a25
commit 857ac43e74
40 changed files with 1086 additions and 44 deletions

View file

@ -0,0 +1,12 @@
= f.inputs do
= f.input :name
= f.inputs name: 'UTM Parameters' do
= f.input :utm_campaign, label: 'Campaign', hint: 'Groups all of the content form one campaign. E.g. 20percentpromocode'
= f.input :utm_source, label: 'Source', hint: 'Which website is sending you traffic. E.g. Facebook, google+, blog'
= f.input :utm_medium, label: 'Medium', hint: 'The type of marketing medium that the link is featured in. E.g. Facebook wallpost or facebook advertisement'
= f.input :utm_term, label: 'Term', hint: 'Campaign keywords. E.g. marketing+conference+opensource'
= f.input :utm_content, label: 'Content', hint: 'Used to track the different types of content that point to the same URL (A/B Test).'
= f.inputs name: 'Targets' do
= f.input :targets
= f.actions do
= f.action :submit, button_html: { class: 'btn btn-primary' }

View file

@ -0,0 +1,2 @@
= semantic_form_for(@campaign, url: admin_conference_campaign_path(@conference.short_title, @campaign)) do |f|
= render partial: 'form', locals: {f: f}

View file

@ -0,0 +1,41 @@
%h1
Campaigns
.row
.col-md-12
.table-responsive
%table.table
%thead
%tr
%th #
%th Name
%th Visits
%th Registrations
%th Submissions
%th Link
%th Edit
%th Delete
%tbody
- @campaigns.each_with_index do |campaign, index|
%tr
%td
= index + 1
%td{'id'=> "name_#{index}"}
= campaign.name
%td{'id'=> "visits_#{index}"}
= campaign.visits_count
%td{'id'=> "registrations_#{index}"}
= campaign.registrations_count
%td{'id'=> "submissions_#{ + index}"}
= campaign.submissions_count
%td
%a.copyLink{'href'=> '#', 'data-url'=>root_path + campaign.url_parameters}
Copy link
%td
= link_to 'Edit',
edit_admin_conference_campaign_path(@conference.short_title, campaign.id)
%td
= link_to 'Delete',
admin_conference_campaign_path(@conference.short_title, campaign.id), method: :delete
.row
.col-md-12
%b= link_to 'New Campaign', new_admin_conference_campaign_path, class: 'btn btn-success'

View file

@ -0,0 +1,2 @@
= semantic_form_for(@campaign, url: admin_conference_campaigns_path(@conference.short_title)) do |f|
= render partial: 'form', locals: {f: f}

View file

@ -0,0 +1,40 @@
- if campaigns && !campaigns.empty?
.row
.col-md-12
%p
Your target "#{campaigns.values[0]['target_name']}" from campaign "#{campaigns.values[0]['campaign_name']}" has generated
%strong
#{pluralize(campaigns.values[0]['value'], campaigns.values[0]['unit'])}
since #{campaigns.values[0]['created_at']}.
%p
That is
%strong{'style'=>"color: #{target_progress_color(campaigns.values[0]['progress'])};"}
#{campaigns.values[0]['progress']} %
of your target, there are
%strong{'style'=>"color: #{days_left_color(campaigns.values[0]['days_left'])};"}
#{pluralize(campaigns.values[0]['days_left'], 'day')} left.
.row
.col-md-12
%div{'style'=>'display: none;', 'id'=>"#{name}"}
- campaigns.drop(1).each do |(key, value)|
%div
%p
Your target "#{value['target_name']}" from campaign "#{value['campaign_name']}" has generated
%strong
#{pluralize(value['value'], value['unit'])}
since #{value['created_at']}.
%p
That is
%strong{'style'=>"color: #{target_progress_color(value['progress'])};"}
#{value['progress']} %
of your target, there are
%strong{'style'=>"color: #{days_left_color(value['days_left'])};"}
#{pluralize(value['days_left'], 'day')} left.
.row
.col-md-12
- if campaigns.length > 1
%a.show_targets{'href'=>'#', 'data-name'=>"#{name}"}
more
- else
%h5.text-warning.text-center
No Campaigns!

View file

@ -0,0 +1,32 @@
- if targets && !targets.empty?
.row
.col-md-8.col-md-offset-2
.row
.col-md-10
%h6.text-muted.pull-left
Target 1
.row
.col-md-10
.progress{'title'=>"#{targets.keys[0]}"}
.progress-bar{ 'role'=>'progressbar', 'aria-valuenow'=>"#{targets.values[0]}", 'aria-valuemin'=>'0',
'aria-valuemax'=>'100', 'style'=>"width: #{targets.values[0]}%;"}
= "#{targets.values[0]} %"
.row
.col-md-8.col-md-offset-2
%div{'style'=>'display: none;', 'id'=>"#{name}"}
- targets.drop(1).each_with_index do |(key, value), index|
.row
.col-md-10
%h6.text-muted.pull-left
= "Target #{index + 2}"
.row
.col-md-10
.progress{'title'=>"#{key}"}
.progress-bar{ 'role'=>'progressbar', 'aria-valuenow'=>"#{value}", 'aria-valuemin'=>'0',
'aria-valuemax'=>'100', 'style'=>"width: #{value}%;" }
= "#{value} %"
.row
.col-md-2.col-md-offset-2
- if targets.length > 1
%a.show_targets{'href'=>'#', 'data-name'=>"#{name}"}
more

View file

@ -10,6 +10,8 @@
.text
%label.text-muted total registrations: #{@total_reg}
%label.text-muted new registrations: #{@new_reg}
.row
= render partial: 'targets', locals: { targets: @registration_targets, name: 'registrations' }
.col-sm-4
.dashbox.text-center
.icon
@ -17,13 +19,17 @@
.text
%label.text-muted total submissions: #{@total_submissions}
%label.text-muted new submissions: #{@new_submissions}
.row
= render partial: 'targets', locals: { targets: @submission_targets, name: 'submissions' }
.col-sm-4
.dashbox.text-center
.icon
%i.glyphicon.glyphicon-user
.text
%label.text-muted programm hours: #{@program_length} h
%label.text-muted new programm hours: #{@new_program_length} h
%label.text-muted programm: #{@program_length} min
%label.text-muted new programm: #{@new_program_length} min
.row
= render partial: 'targets', locals: { targets: @program_minutes_targets, name: 'program_hours' }
.row
.col-md-12
.row
@ -97,6 +103,13 @@
= render partial: 'recent_submissions', locals: {recent_events: @recent_events}
.col-md-4
= render partial: 'top_submitter', locals: {top_submitter: @top_submitter}
.row
.col-md-12
%h3
%span
%i.glyphicon.glyphicon-flag
Campaigns
= render partial: 'campaigns', locals: {campaigns: @campaigns, name: 'campaigns'}
:javascript
$('#recentTable a').click(function (e) {

View file

@ -0,0 +1,6 @@
.nested-fields
= f.inputs do
= f.input :due_date, as: :string, input_html: { class: 'target-due-date-datepicker', readonly: 'readonly' }
= f.input :target_count
= f.input :unit, as: :select, label: 'Unit', class: 'form-control', collection: Target.units.values, include_blank: false
= remove_association_link :target, f

View file

@ -0,0 +1,5 @@
.row
.col-md-8
= semantic_form_for(@conference, url: admin_conference_target_path(@conference.short_title, @conference.targets)) do |f|
= dynamic_association :targets, 'Targets', f
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }