-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
526 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
@import "utils/variables"; | ||
|
||
// reset form styling cross-browser | ||
.form-control, | ||
.form-control:focus { | ||
-webkit-box-shadow: 0 5px 15px rgba(0, 0, 0, 0); | ||
-moz-box-shadow: 0 5px 15px rgba(0, 0, 0, 0); | ||
-o-box-shadow: 0 5px 15px rgba(0, 0, 0, 0); | ||
box-shadow: 0 5px 15px rgba(0, 0, 0, 0); | ||
} | ||
|
||
form table th:first-child { | ||
width: 30px; | ||
} | ||
|
||
.blacklight-feedback h1 { | ||
margin-bottom: 0.25em; | ||
display: block; | ||
} | ||
.blacklight-feedback small { | ||
margin-bottom: 2em; | ||
display: block; | ||
} | ||
|
||
// overwrite bootstrap glyphicon for errors in input fields | ||
.form-control-feedback { | ||
right: 15px; | ||
} | ||
|
||
.feedback-button { | ||
margin-bottom: 15px; | ||
} | ||
|
||
.has-error .error { | ||
font-weight: bold; | ||
color: $brand-danger; | ||
} | ||
|
||
.blacklight-feedback-hidden { | ||
display: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
class FeedbackController < ApplicationController | ||
before_action :current_user_email | ||
before_action :build_feedback_form, only: [:create] | ||
|
||
def new | ||
@feedback_form = FeedbackForm.new if @feedback_form.nil? | ||
@feedback_form.current_url = request.referer || root_url | ||
end | ||
|
||
def create | ||
respond_to do |format| | ||
if @feedback_form.valid? | ||
@feedback_form.deliver | ||
format.js { flash.now[:notice] = I18n.t('blacklight.feedback.success') } | ||
else | ||
format.js { flash.now[:error] = @feedback_form.error_message } | ||
end | ||
end | ||
end | ||
|
||
protected | ||
|
||
def build_feedback_form | ||
@feedback_form = FeedbackForm.new(feedback_form_params) | ||
@feedback_form.request = request | ||
@feedback_form | ||
end | ||
|
||
def feedback_form_params | ||
params.require(:feedback_form).permit(:name, :email, :message, :current_url, :feedback_desc) | ||
end | ||
|
||
def current_user_email | ||
return if current_user.nil? | ||
return if current_user.provider != 'cas' | ||
@user_email = "#{current_user.uid}@princeton.edu" | ||
@user_email | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require 'mail_form' | ||
|
||
class FeedbackForm < MailForm::Base | ||
attribute :name, validate: true | ||
attribute :email, validate: /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i | ||
attribute :message, validate: true | ||
attribute :current_url | ||
attribute :feedback_desc, captcha: true | ||
append :remote_ip, :user_agent | ||
|
||
def headers | ||
{ | ||
subject: "#{I18n.t(:'blacklight.application_name')} Feedback Form", | ||
to: ENV['MAP_FEEDBACK_TO'] || 'lsupport@princeton.edu', | ||
from: %("#{name}" <#{email}>), | ||
cc: ENV['MAP_FEEDBACK_CC'] | ||
} | ||
end | ||
|
||
def error_message | ||
I18n.t(:'blacklight.feedback.error').to_s | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<%= simple_form_for(@feedback_form, url: '/contact-us', id: 'feedback_form', remote: true, class: "form-horizontal" ) do |f| %> | ||
<fieldset class="form-group"> | ||
<label class="control-label col-sm-2" for="name"> | ||
Your name | ||
</label> | ||
<div class="col-sm-10"> | ||
<%= f.text_field :name, class: 'form-control', error: 'Please provide a name' %> | ||
<% unless @feedback_form.errors[:name].empty? %> | ||
<span class="glyphicon glyphicon-remove form-control-feedback" aria-hidden="true"></span> | ||
<span id="inputError2Status" class="sr-only">(error)</span> | ||
<span class="error">This field <%= @feedback_form.errors[:name].first %></span> | ||
<% end %> | ||
</div> | ||
</fieldset> | ||
<fieldset class="form-group"> | ||
<label class="control-label col-sm-2" for="email"> | ||
Your email | ||
</label> | ||
<div class="col-sm-10"> | ||
<%= f.email_field :email, class: 'form-control', error: 'Please provide a valid email address', value: @user_email %> | ||
<% unless @feedback_form.errors[:email].empty? %> | ||
<span class="glyphicon glyphicon-remove form-control-feedback" aria-hidden="true"></span> | ||
<span id="inputError2Status" class="sr-only">(error)</span> | ||
<span class="error">Email <%= @feedback_form.errors[:email].first %></span> | ||
<% end %> | ||
</div> | ||
</fieldset> | ||
<fieldset class="form-group"> | ||
<label class="control-label col-sm-2" for="message"> | ||
Questions or comments | ||
</label> | ||
<div class="col-sm-10"> | ||
<%= f.text_area :message, class: 'form-control', rows: '5', error: 'Please describe the problem you encountered or ask a question.' %> | ||
<% unless @feedback_form.errors[:message].empty? %> | ||
<span class="error">This field <%= @feedback_form.errors[:message].first %></span> | ||
<% end %> | ||
</div> | ||
</fieldset> | ||
<fieldset class="form-group blacklight-feedback-hidden"> | ||
<label class="control-label col-sm-2" for="feedback_desc"> | ||
If you are a human do not fill in this value | ||
</label> | ||
<div class="col-sm-10"> | ||
<%= f.text_field :feedback_desc, class: 'form-control', error: 'Please describe' %> | ||
</div> | ||
</fieldset> | ||
|
||
<%= f.hidden_field :current_url %> | ||
<div class="form-group"> | ||
<div class="col-sm-offset-2 col-md-10 feedback-button"> | ||
<%= f.submit t('blacklight.sms.form.submit'), class: 'btn btn-primary pull-right' %> | ||
</div> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<p><%= I18n.t('blacklight.feedback.confirmation') %></p> | ||
<%= link_to t('blacklight.feedback.return').html_safe, @feedback_form.current_url, class: 'btn btn-default feedback-button' %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
$(".flash_messages").html("<%= escape_javascript(render :partial=>'shared/flash_msg', layout: 'shared/flash_messages') %>"); | ||
|
||
setTimeout(function() { | ||
$(".flash_messages .alert-info, .flash_messages .alert-success").fadeOut('slow', function(){ | ||
$(".flash_messages .alert-info, .flash_messages .alert-success").remove(); | ||
}); | ||
}, 3000); | ||
|
||
<% if !@feedback_form.errors.full_messages.empty? %> | ||
$("#new_feedback_form").replaceWith("<%= escape_javascript(render 'form') %>"); | ||
$(".error").each(function( index ) { | ||
$(this).parent().addClass('has-error'); | ||
}); | ||
<% else %> | ||
$("#new_feedback_form").replaceWith("<%= escape_javascript(render 'return') %>"); | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<%= render 'shared/start_over_row' %> | ||
<div class="col-sm-12"> | ||
<h1 class="page-heading">Contact Us</h1> | ||
<small>*All fields are required</small> | ||
</div> | ||
|
||
<div class="col-sm-12"> | ||
<%= render 'form' %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<div class="col-xs-12 col-lg-12 alert alert-warning beta"> | ||
<p><strong>This is Beta Software</strong><br /> | ||
There may be features missing. <a title="Feedback on New Catalog" href="http://library.princeton.edu/help/contact-us">Please send us a note</a> | ||
There may be features missing. <a title="Feedback on New Geo Search" href="/feedback">Please send us a note</a> | ||
if you have feedback or think you have found an error. | ||
</p> | ||
</div> |
Oops, something went wrong.