Adding ability to add multiple videolistings while editing a campaign

This commit is contained in:
Tyrel Souza 2014-04-23 20:33:59 -04:00
parent 6b5f096c57
commit daa16765ca
9 changed files with 57 additions and 39 deletions

View File

@ -22,6 +22,7 @@ gem 'bootstrap-sass', '<3.1'
gem 'devise'
gem 'jbuilder'
gem 'bootstrap-tagsinput-rails'
gem 'cocoon', :git => 'git://github.com/nathanvda/cocoon'
group :development do

View File

@ -1,3 +1,9 @@
GIT
remote: git://github.com/nathanvda/cocoon
revision: 3735fecd19199e8331f14ef2056b92de3509ad12
specs:
cocoon (1.2.6)
GIT
remote: git@github.com:plataformatec/simple_form.git
revision: 6b685618cb011389e7a4b0430f59a88fa1e14027
@ -233,6 +239,7 @@ DEPENDENCIES
bootstrap-sass (< 3.1)
bootstrap-tagsinput-rails
capybara-webkit (>= 1.0.0)
cocoon!
coffee-rails
database_cleaner
delayed_job_active_record (>= 4.0.0)

View File

@ -13,4 +13,5 @@
//= require jquery
//= require jquery_ujs
//= require bootstrap-tagsinput
//= require cocoon
//= require_tree .

View File

@ -9,7 +9,7 @@ $medgray: #3A9AC9;
border: 2px inset;
}
.odd {
.nested-fields:nth-of-type(odd){
background-color: #395C84;
padding: 10px;
.help-block{
@ -17,7 +17,7 @@ $medgray: #3A9AC9;
}
}
.even {
.nested-fields:nth-of-type(even) {
background-color: lighten(#456A92, 10);
padding: 10px;
}
@ -80,3 +80,12 @@ $medgray: #3A9AC9;
width: 100%;
}
}
#error_explanation ul{
display: none;
}
span.help-inline {
color: #f00;
}

View File

@ -70,7 +70,7 @@ class CampaignsController < ApplicationController
:listingcode, :productsandservices, :state, :targetaudience, :tollfreephone,
:vpa, :websiteurl, :zip,
videolistings_attributes: [:id, :asseturls, :clientprovidedscript, :focus,
videolistings_attributes: [:_destroy, :id, :asseturls, :clientprovidedscript, :focus,
:keywords, :musicselection, :notes, :producttypeid,
:videocode, :voiceoverselection,
])

View File

@ -1,6 +1,6 @@
class Campaign < ActiveRecord::Base
has_many :videolistings, :dependent => :delete_all
accepts_nested_attributes_for :videolistings
accepts_nested_attributes_for :videolistings,:reject_if => :all_blank, :allow_destroy => true
validates :clientid, presence: true, uniqueness: true
validates :billingcode, uniqueness: true
validates :listingcode, presence: true, uniqueness: true

View File

@ -96,42 +96,12 @@
<div class="col-md-3">
<div class="videolisting">
<%= frm.simple_fields_for(:videolistings, html: {class: 'form-horizontal'}) do |vidlist| %>
<div class="<%= cycle('odd','even') %>">
<%= vidlist.input :videocode,
label: 'Video Code',
hint: "Unique identifier for every video." %>
<%= vidlist.input :producttypeid,
label: "Product Type",
collection: producttypeid_list,
hint: "What type of content to create for this video. The types available are dependant on the pre-defined list of products." %>
<%= vidlist.input :voiceoverselection,
label: 'Voiceover Selection',
collection: voiceoverselection_list,
hint: "What type of voiceover talent to use." %>
<%= vidlist.input :musicselection,
label: 'Music Selection',
collection: musicselection_list,
hint: "What type of music to use in the video." %>
<%= vidlist.input :clientprovidedscript,
label: 'Client Provided Script',
as: 'text',
hint: "If the customer has provided a script for BetterVideo to use. Formatting is text only." %>
<%= vidlist.input :keywords,
label: 'Keywords',
hint: "Keywords for use in VSEO campaigns or indexing such as Google or YouTube." %>
<%= vidlist.input :focus,
label: 'Focus',
hint: "Information used to guide BetterVideo in creating the video." %>
<%= vidlist.input :notes,
label: 'Production Notes',
hint: "Notes and/or instructions sent in this field are used by the editors to aid in production of the video." %>
<%= vidlist.input :asseturls,
label: 'Asset Urls',
hint: "A list of all file assets. Comma Separated, (press backspace or click the x to remove)",
input_html: {data: {role: "tagsinput" }, value: ""} %>
</div>
<%= frm.simple_fields_for(:videolistings, html: {class: 'form-horizontal'}) do |videolisting| %>
<%= render 'videolisting_fields', :f => videolisting %>
<% end %>
<div class="links">
[<%= link_to_add_association 'Add Videolisting', frm, :videolistings %>]
</div>
</div>
</div>

View File

@ -0,0 +1,29 @@
<div class="nested-fields">
<%= f.input :videocode,
label: 'Video Code',
hint: "Unique identifier for every video." %>
<%= f.input :producttypeid,
label: "Product Type",
collection: producttypeid_list,
hint: "What type of content to create for this video. The types available are dependant on the pre-defined list of products." %>
<%= f.input :voiceoverselection,
label: 'Voiceover Selection',
collection: voiceoverselection_list,
hint: "What type of voiceover talent to use." %>
<%= f.input :musicselection,
label: 'Music Selection',
collection: musicselection_list,
hint: "What type of music to use in the video." %>
<%= f.input :clientprovidedscript,
label: 'Client Provided Script',
as: 'text',
hint: "If the customer has provided a script for BetterVideo to use. Formatting is text only." %>
<%= f.input :notes,
label: 'Production Notes',
hint: "Notes and/or instructions sent in this field are used by the editors to aid in production of the video." %>
<%= f.input :asseturls,
label: 'Asset Urls',
hint: "A list of all file assets. Comma Separated, (press backspace or click the x to remove)",
input_html: {data: {role: "tagsinput" }, value: ""} %>
{<%= link_to_remove_association "Remove Videolisting", f %>}
</div>

View File

@ -5,6 +5,7 @@
<meta name="ROBOTS" content="NOODP" />
<title><%= title %></title>
<%= stylesheet_link_tag :application, :media => 'all' %>
<%= csrf_meta_tags %>
</head>
<body class="<%= body_class %>">