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' ruby '2.1.0'
gem 'airbrake' gem 'airbrake'
gem 'bourbon'
gem 'coffee-rails' gem 'coffee-rails'
gem 'delayed_job_active_record', '>= 4.0.0' gem 'delayed_job_active_record', '>= 4.0.0'
gem 'email_validator' gem 'email_validator'
gem 'flutie' gem 'flutie'
gem 'high_voltage' gem 'high_voltage'
gem 'jquery-rails' gem 'jquery-rails'
gem 'neat'
gem 'pg' gem 'pg'
gem 'rack-timeout' gem 'rack-timeout'
gem 'rails', '>= 4.0.3' gem 'rails', '>= 4.0.3'
gem 'recipient_interceptor' gem 'recipient_interceptor'
gem 'sass-rails' gem 'sass-rails', '~> 4.0.2'
gem 'simple_form' gem 'simple_form'
gem 'title' gem 'title'
gem 'uglifier' gem 'uglifier'
gem 'unicorn' gem 'unicorn'
gem 'foundation-rails'
group :development do group :development do
gem 'foreman' gem 'foreman'
gem 'spring' gem 'spring'
gem 'spring-commands-rspec' gem 'spring-commands-rspec'
gem 'better_errors'
gem 'binding_of_caller'
end end
group :development, :test do group :development, :test do

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -13,6 +13,7 @@ class CampaignsController < ApplicationController
# GET /campaigns/new # GET /campaigns/new
def new def new
@campaign = Campaign.new @campaign = Campaign.new
@campaign.videolistings.build
end end
# GET /campaigns/1/edit # GET /campaigns/1/edit
@ -53,6 +54,7 @@ class CampaignsController < ApplicationController
# Only allow a trusted parameter "white list" through. # Only allow a trusted parameter "white list" through.
def campaign_params 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
end end

View File

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

View File

@ -5,21 +5,10 @@
<tr> <tr>
<th>Clientid</th> <th>Clientid</th>
<th>Listingcode</th> <th>Listingcode</th>
<th>Billingcode</th>
<th>Advertisername</th>
<th>Address1</th> <th>Address1</th>
<th>Address2</th>
<th>City</th> <th>City</th>
<th>State</th> <th>State</th>
<th>Zip</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> <th></th>
<th></th> <th></th>
@ -31,21 +20,10 @@
<tr> <tr>
<td><%= campaign.clientid %></td> <td><%= campaign.clientid %></td>
<td><%= campaign.listingcode %></td> <td><%= campaign.listingcode %></td>
<td><%= campaign.billingcode %></td>
<td><%= campaign.advertisername %></td>
<td><%= campaign.address1 %></td> <td><%= campaign.address1 %></td>
<td><%= campaign.address2 %></td>
<td><%= campaign.city %></td> <td><%= campaign.city %></td>
<td><%= campaign.state %></td> <td><%= campaign.state %></td>
<td><%= campaign.zip %></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 'Show', campaign %></td>
<td><%= link_to 'Edit', edit_campaign_path(campaign) %></td> <td><%= link_to 'Edit', edit_campaign_path(campaign) %></td>
<td><%= link_to 'Destroy', campaign, method: :delete, data: { confirm: 'Are you sure?' } %></td> <td><%= link_to 'Destroy', campaign, method: :delete, data: { confirm: 'Are you sure?' } %></td>

View File

@ -1,3 +1,5 @@
<div class="row">
<div class="small-6 medium-6 large-6 columns">
<p id="notice"><%= notice %></p> <p id="notice"><%= notice %></p>
<p> <p>
@ -84,6 +86,57 @@
<strong>Websiteurl:</strong> <strong>Websiteurl:</strong>
<%= @campaign.websiteurl %> <%= @campaign.websiteurl %>
</p> </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 'Edit', edit_campaign_path(@campaign) %> |
<%= link_to 'Back', campaigns_path %> <%= link_to 'Back', campaigns_path %>

View File

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