Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Adding config options for placeholders and phone number field. #104

Merged
merged 2 commits into from

2 participants

@patrickdavey

No description provided.

@parndt parndt merged commit 2df37cd into refinery:master

1 check passed

Details default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
22 app/views/refinery/inquiries/inquiries/new.html.erb
@@ -10,19 +10,27 @@
} %>
<div class="field">
<%= f.required_label :name, :class => 'placeholder-fallback' %>
- <%= f.text_field :name, :class => 'text', :required => 'required', :placeholder => t('name', :scope => 'activerecord.attributes.refinery/inquiries/inquiry') %>
+ <%= f.text_field :name, :class => 'text', :required => 'required',
+ :placeholder => t('name', :scope => 'activerecord.attributes.refinery/inquiries/inquiry') if Refinery::Inquiries.show_placeholders %>
</div>
<div class="field">
<%= f.required_label :email, :class => 'placeholder-fallback' %>
- <%= f.email_field :email, :class => 'text email', :required => 'required', :placeholder => t('email', :scope => 'activerecord.attributes.refinery/inquiries/inquiry') %>
- </div>
- <div class="field">
- <%= f.label :phone, :class => 'placeholder-fallback' %>
- <%= f.text_field :phone, :class => 'text phone', :placeholder => t('phone', :scope => 'activerecord.attributes.refinery/inquiries/inquiry') %>
+ <%= f.email_field :email, :class => 'text email', :required => 'required',
+ :placeholder => t('email', :scope => 'activerecord.attributes.refinery/inquiries/inquiry') if Refinery::Inquiries.show_placeholders %>
</div>
+
+ <% if Refinery::Inquiries.show_phone_number_field %>
+ <div class="field">
+ <%= f.label :phone, :class => 'placeholder-fallback' %>
+ <%= f.text_field :phone, :class => 'text phone',
+ :placeholder => t('phone', :scope => 'activerecord.attributes.refinery/inquiries/inquiry') if Refinery::Inquiries.show_placeholders %>
+ </div>
+ <% end %>
+
<div class='field message_field'>
<%= f.required_label :message, :class => 'placeholder-fallback' %>
- <%= f.text_area :message, :rows => 8, :required => 'required', :placeholder => t('message', :scope => 'activerecord.attributes.refinery/inquiries/inquiry') %>
+ <%= f.text_area :message, :rows => 8, :required => 'required',
+ :placeholder => t('message', :scope => 'activerecord.attributes.refinery/inquiries/inquiry') if Refinery::Inquiries.show_placeholders %>
</div>
<div class="actions">
<%= f.submit t('.send') %>
View
6 lib/generators/refinery/inquiries/templates/config/initializers/refinery/inquiries.rb.erb
@@ -1,4 +1,10 @@
Refinery::Inquiries.configure do |config|
# Configure whether to show privacy link
# config.show_contact_privacy_link = <%= Refinery::Inquiries.show_contact_privacy_link.inspect %>
+
+ # Configure whether to show phone number field
+ # config.show_phone_number_field = <%= Refinery::Inquiries.show_phone_number_field.inspect %>
+
+ # Configure whether to show form field placeholders
+ # config.show_placeholders = <%= Refinery::Inquiries.show_placeholders.inspect %>
end
View
4 lib/refinery/inquiries/configuration.rb
@@ -3,7 +3,11 @@ module Inquiries
include ActiveSupport::Configurable
config_accessor :show_contact_privacy_link
+ config_accessor :show_phone_number_field
+ config_accessor :show_placeholders
self.show_contact_privacy_link = true
+ self.show_phone_number_field = true
+ self.show_placeholders = true
end
end
View
56 spec/requests/refinery/inquiries/inquiries_spec.rb
@@ -64,7 +64,7 @@ module Inquiries
describe "privacy" do
context "when show contact privacy link setting set to false" do
before(:each) do
- Refinery::Inquiries.stub(:show_contact_privacy_link).and_return(false)
+ Refinery::Inquiries.config.stub(:show_contact_privacy_link).and_return(false)
end
it "won't show link" do
@@ -88,6 +88,60 @@ module Inquiries
end
end
end
+
+ describe "palceholders" do
+ context "when show placeholders setting set to false" do
+ before(:each) do
+ Refinery::Inquiries.config.stub(:show_placeholders).and_return(false)
+ end
+
+ it "won't show placeholders" do
+ visit refinery.inquiries_new_inquiry_path
+
+ page.should have_no_selector("input[placeholder]")
+ end
+ end
+
+ context "when show placeholders setting set to true" do
+ before(:each) do
+ Refinery::Inquiries.config.stub(:show_placeholders).and_return(true)
+ end
+
+ it "shows the placeholders" do
+ visit refinery.inquiries_new_inquiry_path
+
+ page.should have_selector("input[placeholder]")
+ end
+ end
+ end
+
+ describe "phone number" do
+ context "when show phone numbers setting set to false" do
+ before(:each) do
+ Refinery::Inquiries.config.stub(:show_phone_number_field).and_return(false)
+ end
+
+ it "won't show phone number" do
+ visit refinery.inquiries_new_inquiry_path
+
+ page.should have_no_selector("label", :text => 'Phone')
+ page.should have_no_selector("#inquiry_phone")
+ end
+ end
+
+ context "when show phone numbers setting set to true" do
+ before(:each) do
+ Refinery::Inquiries.config.stub(:show_phone_number_field).and_return(true)
+ end
+
+ it "shows the phone number" do
+ visit refinery.inquiries_new_inquiry_path
+
+ page.should have_selector("label", :text => 'Phone')
+ page.should have_selector("#inquiry_phone")
+ end
+ end
+ end
end
end
end
Something went wrong with that request. Please try again.