-
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.
render popup modal for explicit; warning pseudo-flash for offensive
- Loading branch information
1 parent
0487fd6
commit 965c330
Showing
13 changed files
with
76 additions
and
8 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
15 changes: 15 additions & 0 deletions
15
app/helpers/commonwealth_vlr_engine/flagged_helper_behavior.rb
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,15 @@ | ||
# frozen_string_literal: true | ||
|
||
module CommonwealthVlrEngine | ||
module FlaggedHelperBehavior | ||
# return the correct name of the institution to link to for OAI objects | ||
def show_explicit_warning?(document) | ||
document[blacklight_config.flagged_field.to_sym] == 'explicit' | ||
end | ||
|
||
# return the correct name of the institution to link to for OAI objects | ||
def show_content_warning?(document) | ||
document[blacklight_config.flagged_field.to_sym] == 'offensive' | ||
end | ||
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
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
2 changes: 2 additions & 0 deletions
2
app/views/catalog/_show_partials/_show_flagged_modal_text.html.erb
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 @@ | ||
<div><strong>This item contains content that could be offensive to some viewers or inappropriate for minors.</strong></div> | ||
<div>Click "View Content" to continue to the item or "Back to Search" to return to the search results page.</div> |
3 changes: 3 additions & 0 deletions
3
app/views/catalog/_show_partials/_show_flagged_warning.html.erb
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,3 @@ | ||
<div id="flagged_content_warning" class="alert alert-warning"> | ||
<%= t('blacklight.flagged.warning') %> | ||
</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 |
---|---|---|
@@ -1,6 +1,11 @@ | ||
<%# override so we can add flagged popup and render sidebar elsewhere %> | ||
<% if @document[blacklight_config.flagged_field.to_sym] %> | ||
<%= render partial: 'catalog/_show_partials/show_flagged_notice' %> | ||
<%# override so we can add flagged behavior and render sidebar elsewhere %> | ||
<% if show_explicit_warning?(@document) %> | ||
<%= render partial: 'catalog/_show_partials/show_flagged_modal' %> | ||
<% end %> | ||
<% if show_content_warning?(@document) %> | ||
<%= render partial: 'catalog/_show_partials/show_flagged_warning', | ||
locals: { document: @document } %> | ||
<% end %> | ||
<%= render_document_main_content_partial %> |
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
File renamed without changes.
10 changes: 10 additions & 0 deletions
10
spec/features/catalog/_show_partials/_show_flagged_warning_spec.rb
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,10 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
describe 'flagged item warning' do | ||
it 'displays the flagged item warning' do | ||
visit solr_document_path(id: 'bpl-dev:g445cd14k') | ||
expect(page).to have_selector('#flagged_content_warning') | ||
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
describe CommonwealthVlrEngine::FlaggedHelperBehavior do | ||
let(:blacklight_config) { CatalogController.blacklight_config } | ||
|
||
before(:each) do | ||
allow(helper).to receive_messages(blacklight_config: blacklight_config) | ||
end | ||
|
||
describe '#show_explicit_warning?' do | ||
let(:document) { SolrDocument.find('bpl-dev:00000007x') } | ||
|
||
it 'returns true if the item is explicit' do | ||
expect(helper.show_explicit_warning?(document)).to be_truthy | ||
end | ||
end | ||
|
||
describe '#show_content_warning?' do | ||
let(:document) { SolrDocument.find('bpl-dev:g445cd14k') } | ||
|
||
it 'returns true if the item is offensive' do | ||
expect(helper.show_content_warning?(document)).to be_truthy | ||
end | ||
end | ||
end |