Featured Collections, Works, or Researchers - UVicLibrary/Vault GitHub Wiki
- Feature a Collection - Dashboard > Collections (sidebar) > All Collections > [Pick a collection] > Feature/Unfeature
- Feature a Work - Dashboard > Works (sidebar) > All Works > [Pick a work] > Feature/Unfeature
- Feature a Researcher - Dashboard > Settings > Content Blocks (sidebar) > Featured Researcher tab
- Change the order of featured collections/works - Home page (scroll down) > Drag and drop grey handle > Save order button
- Notes for Developers
Featured collections and featured works are displayed on the home page (vault.library.uvic.ca). Currently, we can feature up to six collections and up to six works. Click each tab below the main heading to cycle between categories (collections, works, researchers).
To feature a collection or work, these three criteria must be met:
- You have the right permissions (e.g. you are an admin) to feature the collection or work
- There are five or fewer featured items in that category already (the one you are about to add being the sixth)
- The collection or work you want to feature is public
To feature a collection, go to its page in the Dashboard by clicking Collections in the sidebar and click the name of the collection from the list. Then click the Feature button. If you can't feature a collection, there will be a message explaining why the button is disabled.
This is the same page for unfeaturing a collection.
Go to the public page for the work you want to feature (can be Dashboard > Works > [click the name of a work]). Click Feature/Unfeature button next to the Work title.
Go to the Dashboard and click Settings on the sidebar. A dropdown list will appear. Click on Content Blocks and then the Featured Researcher tab. Here, you can edit the text or upload an image/thumbnail to display on the homepage.
On the home page below the "Featured" cards, you'll find a sortable list of the currently featured works and collections. Drag and drop the grey handle of the collection or work you want to move. Then click Save Order to save these changes.
These partials are in views/hyrax/homepage
-
_home_content
contains therender
statements for other partials -
_sortable_featured
is the partial for the "change order" interface -
_card
is rendered for every featured collection or work. It needs a local variablepresenter
that takes each item in@featured_collection_list.collection_presenters
orHyrax::WorkShowPresenter
. -
_list_works
andlist_collections
are rendered by_works_table
and_collections_table
respectively
To change the max number of featured works or collections, look in app/models/featured_work.rb
or app/models/featured_collection.rb
. The limit is defined at the top as FEATURE_LIMIT
. The view with the feature/unfeature button is views/hyrax/dashboard/collections
or works/_show_actions
.
<% if @presenter.collection_featurable? && can?(:create, FeaturedCollection) %>
<% if FeaturedCollection.can_create_another? || FeaturedCollection.pluck(:collection_id).include?(@presenter.id) %>
<%= link_to "Feature", featured_collections_path(collection_id: params[:id], order: 1, format: :json, remote: true), method: :post,
data: { behavior: 'feature' },
class: @presenter.display_unfeature_link? ? 'btn btn-default collapse' : 'btn btn-default',
id: 'feature-coll-link' %>
<%= link_to "Unfeature", featured_collection_path(collection_id: params[:id], format: :json, remote: true), method: :delete,
data: { behavior: 'unfeature' },
class: @presenter.display_feature_link? ? 'btn btn-default collapse' : 'btn btn-default',
id: 'unfeature-coll-link' %>
<% else %>
<span class="text-muted feature-collection-error">Maximum of 6 featured collections.</span>
<a class="btn btn-default btn-disabled" disabled="disabled">Feature</a>
<% end %>
<% elsif [email protected]_document.public? %><%# could just be else statement, but this is more explicit %>
<span class="text-muted feature-collection-error">Collection must be public.</span>
<a class="btn btn-default btn-disabled" disabled="disabled">Feature</a>
<% end %>
.collection_featurable?
checks if the collection is public and if the user has permission to create new featured collections.
line 2 displays the feature button if there is room for another featured collection (.can_create_another?
), or the unfeature button if the collection is already featured (the 2nd condition).
Vault will display a maximum error message if the collection doesn't meet either of the above conditions, or a visibility error if the collection is not public.