-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a "Report an Issue" form to catalog records (#732)
- Loading branch information
1 parent
5951d8b
commit 9b6e213
Showing
15 changed files
with
225 additions
and
15 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
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,30 @@ | ||
# frozen_string_literal: true | ||
|
||
module ReportIssue | ||
extend ActiveSupport::Concern | ||
|
||
private | ||
|
||
def report_issue_action(_documents) | ||
mail = RecordMailer.email_report_issue(title: params[:title], | ||
record_number: params[:record_number], | ||
comment: params[:comment], | ||
email: params[:email]) | ||
|
||
if mail.respond_to? :deliver_now | ||
mail.deliver_now | ||
else | ||
mail.deliver | ||
end | ||
|
||
flash[:success] = t('blacklight.email.success') | ||
end | ||
|
||
def validate_report_issue_params | ||
if params[:comment].blank? | ||
flash[:error] = t('blackcat.report_issue.errors.comment') | ||
end | ||
|
||
flash[:error].blank? | ||
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
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,24 +1,30 @@ | ||
<div class="col record-actions "> | ||
<div class="float-right" role="group" aria-label="Actions including with nested dropdown"> | ||
<%= render_show_doc_actions @document do |config, inner| %> | ||
<% if (config.key == :citation) %> | ||
<%= inner %> | ||
<div class="float-right"> | ||
<div class="d-inline-block mb-1" role="group" aria-label="Actions including with nested dropdown"> | ||
<%= render_show_doc_actions @document do |config, inner| %> | ||
<% if (config.key == :citation) %> | ||
<%= inner %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
|
||
<div class="dropdown"> | ||
<a class="btn btn-info btn-sm dropdown-toggle" href="#" role="button" id="btnGroupDrop1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Share</a> | ||
<div class="dropdown-menu" aria-labelledby="btnGroupDrop1"> | ||
<%= render_show_doc_actions @document do |config, inner| %> | ||
<% if (config.key != :citation) %> | ||
<%= inner %> | ||
<div class="dropdown"> | ||
<a class="btn btn-info btn-sm dropdown-toggle" href="#" role="button" id="btnGroupDrop1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Share</a> | ||
<div class="dropdown-menu" aria-labelledby="btnGroupDrop1"> | ||
<%= render_show_doc_actions @document do |config, inner| %> | ||
<% if (config.key != :citation) %> | ||
<%= inner %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="float-right mr-1"> | ||
<%= render(partial: 'bookmark_control', locals: { document: @document }) %> | ||
<div class="d-inline-block mb-1"> | ||
<%= render(partial: 'bookmark_control', locals: { document: @document }) %> | ||
</div> | ||
|
||
<div class="d-inline-block mb-1"> | ||
<a class="btn btn-sm btn-danger" data-blacklight-modal="trigger" href="<%= request.url %>/report_issue">Report an Issue</a> | ||
</div> | ||
</div> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<%= form_tag url_for(controller: controller_name, action: "report_issue"), | ||
data: { blacklight_modal: 'trigger' }, | ||
id: 'report_issue_form', | ||
class: "modal_form", | ||
method: :post do %> | ||
<div class="modal-body"> | ||
<%= render '/shared/flash_msg' %> | ||
|
||
<div class="form-group row"> | ||
<label class="control-label col-sm-3" for="to"> | ||
<%= t('blackcat.report_issue.form.record_title') %> | ||
</label> | ||
<div class="col-sm-9"> | ||
<%= text_field_tag :title, @documents.first['title_display_ssm'], class: 'form-control', :readonly => true %> | ||
</div> | ||
</div> | ||
|
||
<div class="form-group row"> | ||
<label class="control-label col-sm-3" for="to"> | ||
<%= t('blackcat.report_issue.form.record_number') %> | ||
</label> | ||
<div class="col-sm-9"> | ||
<%= text_field_tag :record_number, @documents.first.id, class: 'form-control', :readonly => true %> | ||
</div> | ||
</div> | ||
|
||
<div class="form-group row"> | ||
<label class="control-label col-sm-3" for="message"> | ||
<%= t('blackcat.report_issue.form.comment') %> | ||
</label> | ||
<div class="col-sm-9"> | ||
<%= text_area_tag :comment, params[:comment], class: 'form-control', :required => true %> | ||
</div> | ||
</div> | ||
|
||
<div class="form-group row"> | ||
<label class="control-label col-sm-3" for="to"> | ||
<%= t('blackcat.report_issue.form.email') %> | ||
</label> | ||
<div class="col-sm-9"> | ||
<%= email_field_tag :email, params[:email], class: 'form-control' %> | ||
</div> | ||
</div> | ||
|
||
<% @documents&.each do |doc| %> | ||
<%=hidden_field_tag "id[]", doc.id %> | ||
<% end %> | ||
<%- if params[:sort] -%> | ||
<%= hidden_field_tag "sort", params[:sort] %> | ||
<%- end -%> | ||
<%- if params[:per_page] -%> | ||
<%= hidden_field_tag "per_page", params[:per_page] %> | ||
<%- end -%> | ||
</div> | ||
|
||
<div class="modal-footer"> | ||
<button type="submit" class="btn btn-primary"> <%= t('blacklight.sms.form.submit') %></button> | ||
</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,7 @@ | ||
<%= render Blacklight::System::ModalComponent.new do |component| %> | ||
<% component.with(:title, t('blackcat.report_issue.form.title')) %> | ||
|
||
<% component.with(:body) do %> | ||
<%= render 'report_issue_form' %> | ||
<% 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,6 @@ | ||
<%= render Blacklight::System::ModalComponent.new do |component| %> | ||
<% component.with(:title, t('blacklight.email.success')) %> | ||
|
||
<%= render partial: '/shared/flash_msg' %> | ||
<span data-blacklight-modal="close"></span> | ||
<% 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,14 @@ | ||
<%= t('blackcat.report_issue.email.subject') %> | ||
|
||
<% unless @email.blank? %> | ||
<%= t('blackcat.report_issue.email.email', email: @email) %> | ||
|
||
<% end %> | ||
<%= t('blackcat.report_issue.email.title', title: @title) %> | ||
|
||
<%= t('blackcat.report_issue.email.record_number', record_number: @record_number) %> | ||
|
||
<%= t('blackcat.report_issue.email.record_url', record_number: @record_number) %> | ||
|
||
<%= t('blackcat.report_issue.email.comment') %> | ||
<%= @comment %> |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
hold_button_url: http://cat.libraries.psu.edu/cgi-bin/catredirpg?C= | ||
matomo_id: 10 | ||
report_issue_email_recipient: [email protected] | ||
solr: | ||
url: http://127.0.0.1:8983 | ||
collection: psul_catalog |
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,48 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe RecordMailer do | ||
before do | ||
allow(described_class).to receive(:default).and_return(from: '[email protected]') | ||
end | ||
|
||
describe 'report_issue' do | ||
before do | ||
@email = described_class.email_report_issue(title: 'My Book', | ||
record_number: 123, | ||
comment: 'Some comments', | ||
email: '[email protected]') | ||
end | ||
|
||
it 'receives the TO paramater and send the email to that address' do | ||
expect(@email.to).to include '[email protected]' | ||
end | ||
|
||
it 'has the correct subject' do | ||
expect(@email.subject).to match /Penn State University Libraries Catalog - Issue Report/ | ||
end | ||
|
||
it 'has the correct from address (w/o the port number)' do | ||
expect(@email.from).to include '[email protected]' | ||
end | ||
|
||
it 'prints out the correct body' do | ||
expect(@email.body).to match /Penn State University Libraries Catalog - Issue Report/ | ||
expect(@email.body).to match /Title: My Book/ | ||
expect(@email.body).to match /Record Number: 123/ | ||
expect(@email.body).to match /Record URL: https:\/\/catalog.libraries.psu.edu\/catalog\/123/ | ||
expect(@email.body).to match /Email Address: [email protected]/ | ||
end | ||
|
||
context 'when the email field is not provided' do | ||
email = described_class.email_report_issue(title: 'My Book', | ||
record_number: 123, | ||
comment: 'Some comments') | ||
|
||
it 'does not contain an email field in the body' do | ||
expect(email.body).not_to match /Email Address:/ | ||
end | ||
end | ||
end | ||
end |