diff --git a/Gemfile b/Gemfile
index dff67e7..6de30ef 100644
--- a/Gemfile
+++ b/Gemfile
@@ -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
diff --git a/Gemfile.lock b/Gemfile.lock
index 9189a31..cef1039 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -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)
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index c9ad444..c048aef 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -13,4 +13,5 @@
//= require jquery
//= require jquery_ujs
//= require bootstrap-tagsinput
+//= require cocoon
//= require_tree .
diff --git a/app/assets/stylesheets/campaign.css.scss b/app/assets/stylesheets/campaign.css.scss
index 03a4390..0009ae7 100644
--- a/app/assets/stylesheets/campaign.css.scss
+++ b/app/assets/stylesheets/campaign.css.scss
@@ -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;
+}
diff --git a/app/controllers/campaigns_controller.rb b/app/controllers/campaigns_controller.rb
index 693a02c..f5a2dd7 100644
--- a/app/controllers/campaigns_controller.rb
+++ b/app/controllers/campaigns_controller.rb
@@ -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,
])
diff --git a/app/models/campaign.rb b/app/models/campaign.rb
index 127fb19..568b333 100644
--- a/app/models/campaign.rb
+++ b/app/models/campaign.rb
@@ -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
diff --git a/app/views/campaigns/_form.html.erb b/app/views/campaigns/_form.html.erb
index 2d21a6a..f0a2ef2 100644
--- a/app/views/campaigns/_form.html.erb
+++ b/app/views/campaigns/_form.html.erb
@@ -96,42 +96,12 @@
- <%= frm.simple_fields_for(:videolistings, html: {class: 'form-horizontal'}) do |vidlist| %>
-
- <%= 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: ""} %>
-
+ <%= frm.simple_fields_for(:videolistings, html: {class: 'form-horizontal'}) do |videolisting| %>
+ <%= render 'videolisting_fields', :f => videolisting %>
<% end %>
+
+ [<%= link_to_add_association 'Add Videolisting', frm, :videolistings %>]
+
diff --git a/app/views/campaigns/_videolisting_fields.html.erb b/app/views/campaigns/_videolisting_fields.html.erb
new file mode 100644
index 0000000..712f12f
--- /dev/null
+++ b/app/views/campaigns/_videolisting_fields.html.erb
@@ -0,0 +1,29 @@
+
+ <%= 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 %>}
+
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 436d6ca..e2df355 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -5,6 +5,7 @@
<%= title %>
<%= stylesheet_link_tag :application, :media => 'all' %>
+
<%= csrf_meta_tags %>