foundation, change forms, nested forms

This commit is contained in:
Tyrel Souza 2014-04-07 17:24:08 -04:00
parent 2d56a97674
commit df64bd03bf
13 changed files with 1599 additions and 181 deletions

View File

@ -3,28 +3,30 @@ source 'https://rubygems.org'
ruby '2.1.0'
gem 'airbrake'
gem 'bourbon'
gem 'coffee-rails'
gem 'delayed_job_active_record', '>= 4.0.0'
gem 'email_validator'
gem 'flutie'
gem 'high_voltage'
gem 'jquery-rails'
gem 'neat'
gem 'pg'
gem 'rack-timeout'
gem 'rails', '>= 4.0.3'
gem 'recipient_interceptor'
gem 'sass-rails'
gem 'sass-rails', '~> 4.0.2'
gem 'simple_form'
gem 'title'
gem 'uglifier'
gem 'unicorn'
gem 'foundation-rails'
group :development do
gem 'foreman'
gem 'spring'
gem 'spring-commands-rspec'
gem 'better_errors'
gem 'binding_of_caller'
end
group :development, :test do

View File

@ -31,9 +31,11 @@ GEM
multi_json
arel (4.0.2)
awesome_print (1.2.0)
bourbon (3.1.8)
sass (>= 3.2.0)
thor
better_errors (1.1.0)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
builder (3.1.4)
capybara (2.1.0)
mime-types (>= 1.16)
@ -55,6 +57,7 @@ GEM
crack (0.4.2)
safe_yaml (~> 1.0.0)
database_cleaner (1.2.0)
debug_inspector (0.0.2)
delayed_job (4.0.0)
activesupport (>= 3.0, < 4.1)
delayed_job_active_record (4.0.0)
@ -78,6 +81,9 @@ GEM
foreman (0.63.0)
dotenv (>= 0.7)
thor (>= 0.13.6)
foundation-rails (5.2.2.0)
railties (>= 3.1.0)
sass (>= 3.2.0)
high_voltage (2.1.0)
hike (1.2.3)
i18n (0.6.9)
@ -96,9 +102,6 @@ GEM
mini_portile (0.5.3)
minitest (4.7.5)
multi_json (1.9.2)
neat (1.6.0)
bourbon (>= 3.1)
sass (>= 3.3)
newrelic_rpm (3.7.3.204)
nokogiri (1.6.1)
mini_portile (~> 0.5.0)
@ -144,10 +147,11 @@ GEM
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
safe_yaml (1.0.2)
sass (3.3.4)
sass-rails (4.0.1)
sass (3.2.19)
sass-rails (4.0.2)
railties (>= 4.0.0, < 5.0)
sass (>= 3.1.10)
sass (~> 3.2.0)
sprockets (~> 2.8, <= 2.11.0)
sprockets-rails (~> 2.0.0)
shoulda-matchers (2.5.0)
activesupport (>= 3.0.0)
@ -163,7 +167,7 @@ GEM
spring (1.1.2)
spring-commands-rspec (1.0.1)
spring (>= 0.9.1)
sprockets (2.12.0)
sprockets (2.11.0)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
@ -202,7 +206,8 @@ PLATFORMS
DEPENDENCIES
airbrake
awesome_print
bourbon
better_errors
binding_of_caller
capybara-webkit (>= 1.0.0)
coffee-rails
database_cleaner
@ -212,10 +217,10 @@ DEPENDENCIES
factory_girl_rails
flutie
foreman
foundation-rails
high_voltage
jquery-rails
launchy
neat
newrelic_rpm (>= 3.7.3)
pg
pry-rails
@ -223,7 +228,7 @@ DEPENDENCIES
rails (>= 4.0.3)
recipient_interceptor
rspec-rails (>= 2.14)
sass-rails
sass-rails (~> 4.0.2)
shoulda-matchers
simple_form
simplecov

View File

@ -2,7 +2,6 @@
///////////////////////////////////////////////////////////////////////////////
@import 'bourbon';
@import 'neat';
@import 'foundation_and_overrides';
///////////////////////////////////////////////////////////////////////////////

File diff suppressed because it is too large Load Diff

View File

@ -13,6 +13,7 @@ class CampaignsController < ApplicationController
# GET /campaigns/new
def new
@campaign = Campaign.new
@campaign.videolistings.build
end
# GET /campaigns/1/edit
@ -53,6 +54,7 @@ class CampaignsController < ApplicationController
# Only allow a trusted parameter "white list" through.
def campaign_params
params.require(:campaign).permit(:clientid, :listingcode, :billingcode, :advertisername, :address1, :address2, :city, :state, :zip, :emailaddress, :customerfirstname, :customerlastname, :salesrep, :salesrepemail, :businessphone, :contactphone, :websiteurl)
params.require(:campaign).permit(:clientid, :listingcode, :billingcode, :advertisername, :address1, :address2, :city, :state, :zip, :emailaddress, :customerfirstname, :customerlastname, :salesrep, :salesrepemail, :businessphone, :contactphone, :websiteurl,
videolistings_attributes: [:videocode, :producttypeid, :remoteassetsarchive, :voiceoverselection, :musicselection, :clientprovidedscript, :keywords, :focus, :notes, :asseturls,])
end
end

View File

@ -1,4 +1,4 @@
<%= form_for(@campaign) do |f| %>
<%= simple_form_for(@campaign) do |frm| %>
<% if @campaign.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@campaign.errors.count, "error") %> prohibited this campaign from being saved:</h2>
@ -11,75 +11,43 @@
</div>
<% end %>
<div class="field">
<%= f.label :clientid %><br>
<%= f.text_field :clientid %>
</div>
<div class="field">
<%= f.label :listingcode %><br>
<%= f.text_field :listingcode %>
</div>
<div class="field">
<%= f.label :billingcode %><br>
<%= f.text_field :billingcode %>
</div>
<div class="field">
<%= f.label :advertisername %><br>
<%= f.text_field :advertisername %>
</div>
<div class="field">
<%= f.label :address1 %><br>
<%= f.text_field :address1 %>
</div>
<div class="field">
<%= f.label :address2 %><br>
<%= f.text_field :address2 %>
</div>
<div class="field">
<%= f.label :city %><br>
<%= f.text_field :city %>
</div>
<div class="field">
<%= f.label :state %><br>
<%= f.text_field :state %>
</div>
<div class="field">
<%= f.label :zip %><br>
<%= f.text_field :zip %>
</div>
<div class="field">
<%= f.label :emailaddress %><br>
<%= f.text_field :emailaddress %>
</div>
<div class="field">
<%= f.label :customerfirstname %><br>
<%= f.text_field :customerfirstname %>
</div>
<div class="field">
<%= f.label :customerlastname %><br>
<%= f.text_field :customerlastname %>
</div>
<div class="field">
<%= f.label :salesrep %><br>
<%= f.text_field :salesrep %>
</div>
<div class="field">
<%= f.label :salesrepemail %><br>
<%= f.text_field :salesrepemail %>
</div>
<div class="field">
<%= f.label :businessphone %><br>
<%= f.text_field :businessphone %>
</div>
<div class="field">
<%= f.label :contactphone %><br>
<%= f.text_field :contactphone %>
</div>
<div class="field">
<%= f.label :websiteurl %><br>
<%= f.text_field :websiteurl %>
</div>
<%= frm.input :clientid %>
<%= frm.input :listingcode %>
<%= frm.input :billingcode %>
<%= frm.input :advertisername %>
<%= frm.input :address1 %>
<%= frm.input :address2 %>
<%= frm.input :city %>
<%= frm.input :state %>
<%= frm.input :zip %>
<%= frm.input :emailaddress %>
<%= frm.input :customerfirstname %>
<%= frm.input :customerlastname %>
<%= frm.input :salesrep %>
<%= frm.input :salesrepemail %>
<%= frm.input :businessphone %>
<%= frm.input :contactphone %>
<%= frm.input :websiteurl %>
<ul>
<%= frm.simple_fields_for :videolistings do |vidlist| %>
<li>
<%= vidlist.input :videocode %>
<%= vidlist.input :producttypeid %>
<%= vidlist.input :remoteassetsarchive %>
<%= vidlist.input :voiceoverselection %>
<%= vidlist.input :musicselection %>
<%= vidlist.input :clientprovidedscript %>
<%= vidlist.input :keywords %>
<%= vidlist.input :focus %>
<%= vidlist.input :notes %>
<%= vidlist.input :asseturls %>
</li>
<% end %>
</ul>
<div class="actions">
<%= f.submit %>
<%= frm.submit %>
</div>
<% end %>

View File

@ -5,21 +5,10 @@
<tr>
<th>Clientid</th>
<th>Listingcode</th>
<th>Billingcode</th>
<th>Advertisername</th>
<th>Address1</th>
<th>Address2</th>
<th>City</th>
<th>State</th>
<th>Zip</th>
<th>Emailaddress</th>
<th>Customerfirstname</th>
<th>Customerlastname</th>
<th>Salesrep</th>
<th>Salesrepemail</th>
<th>Businessphone</th>
<th>Contactphone</th>
<th>Websiteurl</th>
<th></th>
<th></th>
<th></th>
@ -31,21 +20,10 @@
<tr>
<td><%= campaign.clientid %></td>
<td><%= campaign.listingcode %></td>
<td><%= campaign.billingcode %></td>
<td><%= campaign.advertisername %></td>
<td><%= campaign.address1 %></td>
<td><%= campaign.address2 %></td>
<td><%= campaign.city %></td>
<td><%= campaign.state %></td>
<td><%= campaign.zip %></td>
<td><%= campaign.emailaddress %></td>
<td><%= campaign.customerfirstname %></td>
<td><%= campaign.customerlastname %></td>
<td><%= campaign.salesrep %></td>
<td><%= campaign.salesrepemail %></td>
<td><%= campaign.businessphone %></td>
<td><%= campaign.contactphone %></td>
<td><%= campaign.websiteurl %></td>
<td><%= link_to 'Show', campaign %></td>
<td><%= link_to 'Edit', edit_campaign_path(campaign) %></td>
<td><%= link_to 'Destroy', campaign, method: :delete, data: { confirm: 'Are you sure?' } %></td>

View File

@ -1,89 +1,142 @@
<p id="notice"><%= notice %></p>
<div class="row">
<div class="small-6 medium-6 large-6 columns">
<p id="notice"><%= notice %></p>
<p>
<strong>Clientid:</strong>
<%= @campaign.clientid %>
</p>
<p>
<strong>Clientid:</strong>
<%= @campaign.clientid %>
</p>
<p>
<strong>Listingcode:</strong>
<%= @campaign.listingcode %>
</p>
<p>
<strong>Listingcode:</strong>
<%= @campaign.listingcode %>
</p>
<p>
<strong>Billingcode:</strong>
<%= @campaign.billingcode %>
</p>
<p>
<strong>Billingcode:</strong>
<%= @campaign.billingcode %>
</p>
<p>
<strong>Advertisername:</strong>
<%= @campaign.advertisername %>
</p>
<p>
<strong>Advertisername:</strong>
<%= @campaign.advertisername %>
</p>
<p>
<strong>Address1:</strong>
<%= @campaign.address1 %>
</p>
<p>
<strong>Address1:</strong>
<%= @campaign.address1 %>
</p>
<p>
<strong>Address2:</strong>
<%= @campaign.address2 %>
</p>
<p>
<strong>Address2:</strong>
<%= @campaign.address2 %>
</p>
<p>
<strong>City:</strong>
<%= @campaign.city %>
</p>
<p>
<strong>City:</strong>
<%= @campaign.city %>
</p>
<p>
<strong>State:</strong>
<%= @campaign.state %>
</p>
<p>
<strong>State:</strong>
<%= @campaign.state %>
</p>
<p>
<strong>Zip:</strong>
<%= @campaign.zip %>
</p>
<p>
<strong>Zip:</strong>
<%= @campaign.zip %>
</p>
<p>
<strong>Emailaddress:</strong>
<%= @campaign.emailaddress %>
</p>
<p>
<strong>Emailaddress:</strong>
<%= @campaign.emailaddress %>
</p>
<p>
<strong>Customerfirstname:</strong>
<%= @campaign.customerfirstname %>
</p>
<p>
<strong>Customerfirstname:</strong>
<%= @campaign.customerfirstname %>
</p>
<p>
<strong>Customerlastname:</strong>
<%= @campaign.customerlastname %>
</p>
<p>
<strong>Customerlastname:</strong>
<%= @campaign.customerlastname %>
</p>
<p>
<strong>Salesrep:</strong>
<%= @campaign.salesrep %>
</p>
<p>
<strong>Salesrep:</strong>
<%= @campaign.salesrep %>
</p>
<p>
<strong>Salesrepemail:</strong>
<%= @campaign.salesrepemail %>
</p>
<p>
<strong>Salesrepemail:</strong>
<%= @campaign.salesrepemail %>
</p>
<p>
<strong>Businessphone:</strong>
<%= @campaign.businessphone %>
</p>
<p>
<strong>Businessphone:</strong>
<%= @campaign.businessphone %>
</p>
<p>
<strong>Contactphone:</strong>
<%= @campaign.contactphone %>
</p>
<p>
<strong>Contactphone:</strong>
<%= @campaign.contactphone %>
</p>
<p>
<strong>Websiteurl:</strong>
<%= @campaign.websiteurl %>
</p>
<p>
<strong>Websiteurl:</strong>
<%= @campaign.websiteurl %>
</p>
</div>
<div class="small-6 medium-6 large-6 columns">
<ul>
<% @campaign.videolistings.each do |vl| %>
<li>
<p>
<strong>videocode</strong>
<%= vl.videocode %>
</p>
<p>
<strong>producttypeid</strong>
<%= vl.producttypeid %>
</p>
<p>
<strong>remoteassetsarchive</strong>
<%= vl.remoteassetsarchive %>
</p>
<p>
<strong>voiceoverselection</strong>
<%= vl.voiceoverselection %>
</p>
<p>
<strong>musicselection</strong>
<%= vl.musicselection %>
</p>
<p>
<strong>clientprovidedscript</strong>
<%= vl.clientprovidedscript %>
</p>
<p>
<strong>keywords</strong>
<%= vl.keywords %>
</p>
<p>
<strong>focus</strong>
<%= vl.focus %>
</p>
<p>
<strong>notes</strong>
<%= vl.notes %>
</p>
<p>
<strong>asseturls</strong>
<%= vl.asseturls %>
</p>
</li>
<% end %>
</ul>
</div>
</div>
<%= link_to 'Edit', edit_campaign_path(@campaign) %> |
<%= link_to 'Back', campaigns_path %>

View File

@ -9,7 +9,12 @@
</head>
<body class="<%= body_class %>">
<%= render 'flashes' -%>
<%= yield %>
<div class="row">
<div class="small-12 medium-12 large-12 columns">
<%= yield %>
</div>
</div>
<%= render 'javascript' %>
</body>
</html>

View File

@ -0,0 +1,145 @@
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
# Wrappers are used by the form builder to generate a
# complete input. You can remove any component from the
# wrapper, change the order or even add your own to the
# stack. The options given below are used to wrap the
# whole input.
config.wrappers :default, class: :input,
hint_class: :field_with_hint, error_class: :field_with_errors do |b|
## Extensions enabled by default
# Any of these extensions can be disabled for a
# given input by passing: `f.input EXTENSION_NAME => false`.
# You can make any of these extensions optional by
# renaming `b.use` to `b.optional`.
# Determines whether to use HTML5 (:email, :url, ...)
# and required attributes
b.use :html5
# Calculates placeholders automatically from I18n
# You can also pass a string as f.input placeholder: "Placeholder"
b.use :placeholder
## Optional extensions
# They are disabled unless you pass `f.input EXTENSION_NAME => :lookup`
# to the input. If so, they will retrieve the values from the model
# if any exists. If you want to enable the lookup for any of those
# extensions by default, you can change `b.optional` to `b.use`.
# Calculates maxlength from length validations for string inputs
b.optional :maxlength
# Calculates pattern from format validations for string inputs
b.optional :pattern
# Calculates min and max from length validations for numeric inputs
b.optional :min_max
# Calculates readonly automatically from readonly attributes
b.optional :readonly
## Inputs
b.use :label_input
b.use :hint, wrap_with: { tag: :span, class: :hint }
b.use :error, wrap_with: { tag: :span, class: :error }
end
# The default wrapper to be used by the FormBuilder.
config.default_wrapper = :default
# Define the way to render check boxes / radio buttons with labels.
# Defaults to :nested for bootstrap config.
# inline: input + label
# nested: label > input
config.boolean_style = :nested
# Default class for buttons
config.button_class = 'btn'
# Method used to tidy up errors. Specify any Rails Array method.
# :first lists the first message for each field.
# Use :to_sentence to list all errors for each field.
# config.error_method = :first
# Default tag used for error notification helper.
config.error_notification_tag = :div
# CSS class to add for error notification helper.
config.error_notification_class = 'alert alert-error'
# ID to add for error notification helper.
# config.error_notification_id = nil
# Series of attempts to detect a default label method for collection.
# config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
# Series of attempts to detect a default value method for collection.
# config.collection_value_methods = [ :id, :to_s ]
# You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
# config.collection_wrapper_tag = nil
# You can define the class to use on all collection wrappers. Defaulting to none.
# config.collection_wrapper_class = nil
# You can wrap each item in a collection of radio/check boxes with a tag,
# defaulting to :span. Please note that when using :boolean_style = :nested,
# SimpleForm will force this option to be a label.
# config.item_wrapper_tag = :span
# You can define a class to use in all item wrappers. Defaulting to none.
# config.item_wrapper_class = nil
# How the label text should be generated altogether with the required text.
# config.label_text = lambda { |label, required| "#{required} #{label}" }
# You can define the class to use on all labels. Default is nil.
config.label_class = 'control-label'
# You can define the class to use on all forms. Default is simple_form.
# config.form_class = :simple_form
# You can define which elements should obtain additional classes
# config.generate_additional_classes_for = [:wrapper, :label, :input]
# Whether attributes are required by default (or not). Default is true.
# config.required_by_default = true
# Tell browsers whether to use the native HTML5 validations (novalidate form option).
# These validations are enabled in SimpleForm's internal config but disabled by default
# in this configuration, which is recommended due to some quirks from different browsers.
# To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
# change this configuration to true.
config.browser_validations = false
# Collection of methods to detect if a file type was given.
# config.file_methods = [ :mounted_as, :file?, :public_filename ]
# Custom mappings for input types. This should be a hash containing a regexp
# to match as key, and the input type that will be used when the field name
# matches the regexp as value.
# config.input_mappings = { /count/ => :integer }
# Custom wrappers for input types. This should be a hash containing an input
# type as key and the wrapper that will be used for all inputs with specified type.
# config.wrapper_mappings = { string: :prepend }
# Default priority for time_zone inputs.
# config.time_zone_priority = nil
# Default priority for country inputs.
# config.country_priority = nil
# When false, do not use translations for labels.
# config.translate_labels = true
# Automatically discover new inputs in Rails' autoload path.
# config.inputs_discovery = true
# Cache SimpleForm inputs discovery
# config.cache_discovery = !Rails.env.development?
# Default class for inputs
# config.input_class = nil
end

View File

@ -0,0 +1,26 @@
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
config.wrappers :foundation, class: :input, hint_class: :field_with_hint, error_class: :error do |b|
b.use :html5
b.use :placeholder
b.optional :maxlength
b.optional :pattern
b.optional :min_max
b.optional :readonly
b.use :label_input
b.use :error, wrap_with: { tag: :small }
# Uncomment the following line to enable hints. The line is commented out by default since Foundation
# does't provide styles for hints. You will need to provide your own CSS styles for hints.
# b.use :hint, wrap_with: { tag: :span, class: :hint }
end
# CSS class for buttons
config.button_class = 'button'
# CSS class to add for error notification helper.
config.error_notification_class = 'alert-box alert'
# The default wrapper to be used by the FormBuilder.
config.default_wrapper = :foundation
end

View File

@ -0,0 +1,26 @@
en:
simple_form:
"yes": 'Yes'
"no": 'No'
required:
text: 'required'
mark: '*'
# You can uncomment the line below if you need to overwrite the whole required html.
# When using html, text and mark won't be used.
# html: '<abbr title="required">*</abbr>'
error_notification:
default_message: "Please review the problems below:"
# Labels and hints examples
# labels:
# defaults:
# password: 'Password'
# user:
# new:
# email: 'E-mail to sign in.'
# edit:
# email: 'E-mail.'
# hints:
# defaults:
# username: 'User name to sign in.'
# password: 'No special characters, please.'

View File

@ -0,0 +1,13 @@
<%%= simple_form_for(@<%= singular_table_name %>) do |f| %>
<%%= f.error_notification %>
<div class="form-inputs">
<%- attributes.each do |attribute| -%>
<%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %>
<%- end -%>
</div>
<div class="form-actions">
<%%= f.button :submit %>
</div>
<%% end %>