-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Institutional Theme Featured Collection Layout
This commit: - adds a new partial to the Institutional Repository theme to render the featured collections in a grid format rather than a table - adds a spec for the Institutional Repository featured collection partial Ref: - notch8/palni_palci_knapsack#240
- Loading branch information
Showing
2 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
...iews/themes/institutional_repository/hyrax/homepage/_featured_collection_section.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,35 @@ | ||
<%# OVERRIDE Hyrax v5.0.4 for theming - institutional repository homepage featured collections uses a grid layout %> | ||
|
||
<div id="featured_collections"> | ||
<% if @featured_collection_list.empty? %> | ||
<p id="no-collections"><%= t('hyrax.homepage.featured_collections.no_collections') %></p> | ||
<% elsif can? :update, FeaturedCollection %> | ||
<%= form_for [main_app, @featured_collection_list] do |f| %> | ||
<div class="dd" id="ff"> | ||
<ol id="featured_works"> | ||
<%= f.fields_for :featured_collections do |featured| %> | ||
<%= render 'hyrax/homepage/sortable_featured_collections', f: featured %> | ||
<% end %> | ||
</ol> | ||
</div> | ||
<%= f.submit('Save order', class: 'btn btn-secondary') %> | ||
<% end %> | ||
<% else %> | ||
<div class="container"> | ||
<%= form_for [main_app, @featured_collection_list] do |f| %> | ||
<div class="row"> | ||
<%= f.fields_for :featured_collections do |featured| %> | ||
<%= render 'explore_collections', f: featured %> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
</div> | ||
<ul class="list-inline collection-highlights-list"> | ||
<li> | ||
<%= link_to t('hyrax.homepage.admin_sets.link'), | ||
main_app.search_catalog_path(f: { generic_type_sim: ['Collection']}), | ||
class: 'btn btn-secondary mt-1' %> | ||
</li> | ||
</ul> |
80 changes: 80 additions & 0 deletions
80
spec/views/themes/institutional_repository/_featured_collection_section.html.erb_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,80 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe "themes/institutional_repository/hyrax/homepage/_featured_collection_section.html.erb", type: :view do | ||
let(:list) { FeaturedCollectionList.new } | ||
let(:presenter) do | ||
Hyku::WorkShowPresenter.new( | ||
SolrDocument.new( | ||
id: '123', | ||
title_tesim: ['Featured Collection'], | ||
has_model_ssim: ['Collection'] | ||
), | ||
nil | ||
) | ||
end | ||
let(:featured_collection) { FeaturedCollection.new } | ||
let(:rendered_template) { render } | ||
|
||
before do | ||
assign(:featured_collection_list, list) | ||
allow(view).to receive(:can?).with(:update, FeaturedCollection).and_return(false) | ||
allow(view).to receive(:render_thumbnail_tag).with(presenter, any_args).and_return('thumbnail') | ||
allow(view).to receive(:main_app).and_return(main_app) | ||
end | ||
|
||
context "when there are no featured collections" do | ||
before { render } | ||
|
||
it "displays the 'no collections' message" do | ||
expect(rendered).to have_content(t('hyrax.homepage.featured_collections.no_collections')) | ||
end | ||
|
||
it "does not show the form" do | ||
expect(rendered).not_to have_selector('form') | ||
end | ||
end | ||
|
||
context "when user can update featured collections" do | ||
before do | ||
allow(view).to receive(:can?).with(:update, FeaturedCollection).and_return(true) | ||
allow(view).to receive(:can?).with(:destroy, FeaturedCollection).and_return(true) | ||
allow(list).to receive(:empty?).and_return(false) | ||
allow(list).to receive(:featured_collections).and_return([featured_collection]) | ||
allow(featured_collection).to receive(:presenter).and_return(presenter) | ||
|
||
allow(view).to receive(:render_thumbnail_tag).with( | ||
presenter.solr_document, | ||
{ alt: "Featured Collection Thumbnail" }, | ||
{ suppress_link: true } | ||
).and_return('thumbnail') | ||
|
||
render | ||
end | ||
|
||
it "displays the form for reordering" do | ||
expect(rendered).to have_selector('form') | ||
expect(rendered).to have_selector('#ff') | ||
expect(rendered).to have_selector('#featured_works') | ||
expect(rendered).to have_selector('input[type="submit"][value="Save order"]') | ||
end | ||
end | ||
|
||
context "when user cannot update featured collections" do | ||
before do | ||
allow(list).to receive(:empty?).and_return(false) | ||
allow(list).to receive(:featured_collections).and_return([featured_collection]) | ||
allow(featured_collection).to receive(:presenter).and_return(presenter) | ||
render | ||
end | ||
|
||
it "displays the collections in a grid" do | ||
expect(rendered).to have_selector('.container') | ||
expect(rendered).to have_selector('.row') | ||
end | ||
|
||
it "displays the link to browse all collections" do | ||
expect(rendered).to have_selector('.collection-highlights-list') | ||
expect(rendered).to have_link(t('hyrax.homepage.admin_sets.link')) | ||
end | ||
end | ||
end |