From 466141adad6f0c67221e58f8a34d25eb53b8f82d Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Tue, 22 Apr 2014 13:44:49 -0400 Subject: [PATCH] Add helpers for convering simple_form collection to a hash and getting it back. clean up styling for show --- app/assets/stylesheets/campaign.css.scss | 11 +++ app/helpers/application_helper.rb | 89 +++++++++++++++++++++- app/views/campaigns/_form.html.erb | 14 ++-- app/views/campaigns/_videolisting.html.erb | 54 ++++++------- app/views/campaigns/edit.html.erb | 6 +- app/views/campaigns/show.html.erb | 88 ++++++++++++++------- 6 files changed, 194 insertions(+), 68 deletions(-) diff --git a/app/assets/stylesheets/campaign.css.scss b/app/assets/stylesheets/campaign.css.scss index 297b30f..6180d84 100644 --- a/app/assets/stylesheets/campaign.css.scss +++ b/app/assets/stylesheets/campaign.css.scss @@ -45,4 +45,15 @@ textarea { select { width:100%; +} + + +.campaign-item, .videolisting-item { + display:block; + strong { + display:block; + } + span { + padding-left: 2em; + } } \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 88543b7..d5cde8e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,21 +1,32 @@ module ApplicationHelper - def producttypeid_list + def producttypeid_list(options={}) producttypeids = [] producttypeids << ["720 - Basic Montage", 720] producttypeids << ["721 - Advanced Montage", 721] producttypeids << ["722 - Basic Video Shoot", 722] producttypeids << ["723 - Repurposed", 723] producttypeids << ["724 - Repurposed Edit", 724] + + if options.empty? + return producttypeids + else + convert_to_hash(producttypeids)[options[:item]] + end end - def voiceoverselection_list + def voiceoverselection_list(options={}) voiceoverselections = [] voiceoverselections << ["1 - Male", 1] voiceoverselections << ["2 - Female", 2] voiceoverselections << ["3 - No Preference", 3] + if options.empty? + return voiceoverselections + else + convert_to_hash(voiceoverselections)[options[:item]] + end end - def musicselection_list + def musicselection_list(options={}) musicselections = [] musicselections << ["0 - No Preference", 0] musicselections << ["1 - Easy", 1] @@ -24,5 +35,77 @@ module ApplicationHelper musicselections << ["4 - New Age", 4] musicselections << ["5 - Positive", 5] musicselections << ["6 - Rock", 6] + if options.empty? + return musicselections + else + convert_to_hash(musicselections)[options[:item]] + end end + + + + def us_states + [ + ['Alabama', 'AL'], + ['Alaska', 'AK'], + ['Arizona', 'AZ'], + ['Arkansas', 'AR'], + ['California', 'CA'], + ['Colorado', 'CO'], + ['Connecticut', 'CT'], + ['Delaware', 'DE'], + ['District of Columbia', 'DC'], + ['Florida', 'FL'], + ['Georgia', 'GA'], + ['Hawaii', 'HI'], + ['Idaho', 'ID'], + ['Illinois', 'IL'], + ['Indiana', 'IN'], + ['Iowa', 'IA'], + ['Kansas', 'KS'], + ['Kentucky', 'KY'], + ['Louisiana', 'LA'], + ['Maine', 'ME'], + ['Maryland', 'MD'], + ['Massachusetts', 'MA'], + ['Michigan', 'MI'], + ['Minnesota', 'MN'], + ['Mississippi', 'MS'], + ['Missouri', 'MO'], + ['Montana', 'MT'], + ['Nebraska', 'NE'], + ['Nevada', 'NV'], + ['New Hampshire', 'NH'], + ['New Jersey', 'NJ'], + ['New Mexico', 'NM'], + ['New York', 'NY'], + ['North Carolina', 'NC'], + ['North Dakota', 'ND'], + ['Ohio', 'OH'], + ['Oklahoma', 'OK'], + ['Oregon', 'OR'], + ['Pennsylvania', 'PA'], + ['Puerto Rico', 'PR'], + ['Rhode Island', 'RI'], + ['South Carolina', 'SC'], + ['South Dakota', 'SD'], + ['Tennessee', 'TN'], + ['Texas', 'TX'], + ['Utah', 'UT'], + ['Vermont', 'VT'], + ['Virginia', 'VA'], + ['Washington', 'WA'], + ['West Virginia', 'WV'], + ['Wisconsin', 'WI'], + ['Wyoming', 'WY'] + ] + end + + + private + def convert_to_hash(list) + list.map!{|x| x= x[1],x[0]} + return Hash[*list.flatten] + end + end diff --git a/app/views/campaigns/_form.html.erb b/app/views/campaigns/_form.html.erb index d24e01c..09c3c2f 100644 --- a/app/views/campaigns/_form.html.erb +++ b/app/views/campaigns/_form.html.erb @@ -26,9 +26,11 @@
- + <%= frm.input :advertisername, + label: 'Advertiser Name', + hint: "The name of the company." %> <%= frm.input :clientid, - label: 'Client ID', + label: 'Client ID', hint: 'An identifier provided by BetterVideo.' %> <%= frm.input :listingcode, label: 'Listing Code', @@ -36,9 +38,7 @@ <%= frm.input :websiteurl, label: 'Website URL', hint: "Used for script research and may be used in the video if they are including websites in the video graphics." %> - <%= frm.input :advertisername, - label: 'Advertiser Name', - hint: "The name of the company." %> + <%= frm.input :vpa, label: 'Client Service Rep', hint: "This is the full name of the client services representative, as entered in the BetteVideo system associated with this order. This feature is designed for sales reps that are well known to the system. This feature is typically used for automated communication." %> @@ -61,7 +61,8 @@ <%= frm.input :city, label: 'City' %> <%= frm.input :state, - label: 'State' %> + label: 'State', + collection: us_states%> <%= frm.input :zip, label: 'ZIP' %> @@ -80,6 +81,7 @@ placeholder: "ex: red, white, blue" %> <%= frm.input :description, label: 'Description', + as: 'text', hint: "Used for script research." %> <%= frm.input :facebookurl, label: 'Facebook URL', diff --git a/app/views/campaigns/_videolisting.html.erb b/app/views/campaigns/_videolisting.html.erb index ee59b16..0389fe8 100644 --- a/app/views/campaigns/_videolisting.html.erb +++ b/app/views/campaigns/_videolisting.html.erb @@ -1,38 +1,38 @@
  • -

    + videocode - <%= videolisting.videocode %> -

    -

    + <%= videolisting.videocode %> + + producttypeid - <%= videolisting.producttypeid %> -

    -

    + <%= producttypeid_list item:videolisting.producttypeid %> + + voiceoverselection - <%= videolisting.voiceoverselection %> -

    -

    + <%= voiceoverselection_list item:videolisting.voiceoverselection %> + + musicselection - <%= videolisting.musicselection %> -

    -

    + <%= musicselection_list item:videolisting.musicselection %> + + clientprovidedscript - <%= videolisting.clientprovidedscript %> -

    -

    + <%= videolisting.clientprovidedscript %> + + keywords - <%= videolisting.keywords %> -

    -

    + <%= videolisting.keywords %> + + focus - <%= videolisting.focus %> -

    -

    + <%= videolisting.focus %> + + notes - <%= videolisting.notes %> -

    -

    + <%= videolisting.notes %> + + asseturls - <%= videolisting.asseturls %> -

    + <%= videolisting.asseturls %> +
  • \ No newline at end of file diff --git a/app/views/campaigns/edit.html.erb b/app/views/campaigns/edit.html.erb index 256a1f9..8be9899 100644 --- a/app/views/campaigns/edit.html.erb +++ b/app/views/campaigns/edit.html.erb @@ -1,6 +1,6 @@ -<%= link_to 'Show', @campaign %> | +<%= link_to 'Show', campaign_path(@campaign.listingcode) %> | <%= link_to 'Back', campaigns_path %> -

    Editing campaign

    +

    Editing <%= @campaign.advertisername %>

    -<%= render 'form' %> +<%= render 'form' %> \ No newline at end of file diff --git a/app/views/campaigns/show.html.erb b/app/views/campaigns/show.html.erb index ae95b5f..8ab800b 100644 --- a/app/views/campaigns/show.html.erb +++ b/app/views/campaigns/show.html.erb @@ -12,48 +12,78 @@
    - Clientid: - <%= @campaign.clientid %> + + Clientid + <%= @campaign.clientid %> + - Listingcode: - <%= @campaign.listingcode %> + + Listingcode + <%= @campaign.listingcode %> + - Billingcode: - <%= @campaign.billingcode %> + + Billingcode + <%= @campaign.billingcode %> + - Address1: - <%= @campaign.address %> + + Address1 + <%= @campaign.address %> + - City: - <%= @campaign.city %> + + City + <%= @campaign.city %> + - State: - <%= @campaign.state %> + + State + <%= @campaign.state %> + - Zip: - <%= @campaign.zip %> + + Zip + <%= @campaign.zip %> + - Email Address: - <%= @campaign.emailaddress %> + + Email Address + <%= @campaign.emailaddress %> + - Customer First Name: - <%= @campaign.customerfirstname %> + + Customer First Name + <%= @campaign.customerfirstname %> + - Customer Last Name: - <%= @campaign.customerlastname %> + + Customer Last Name + <%= @campaign.customerlastname %> + - Businessphone: - <%= @campaign.businessphone %> + + Businessphone + <%= @campaign.businessphone %> + - Description: - <%= @campaign.description %> - Contactphone: - <%= @campaign.contactphone %> + + Description + <%= @campaign.description %> + - Websiteurl: - <%= @campaign.websiteurl %> -
    + + Contactphone + <%= @campaign.contactphone %> + + + + Websiteurl + <%= @campaign.websiteurl %> + + +
      <% @campaign.videolistings.each do |videolisting| %>