diff --git a/app/components/arclight/bookmark_component.html.erb b/app/components/arclight/bookmark_component.html.erb index cd485dfe0..ed8bb7699 100644 --- a/app/components/arclight/bookmark_component.html.erb +++ b/app/components/arclight/bookmark_component.html.erb @@ -11,7 +11,7 @@ }) do %>
diff --git a/app/helpers/arclight_helper.rb b/app/helpers/arclight_helper.rb index f47c9d07b..9cf50d997 100644 --- a/app/helpers/arclight_helper.rb +++ b/app/helpers/arclight_helper.rb @@ -5,6 +5,7 @@ module ArclightHelper include Arclight::EadFormatHelpers include Arclight::FieldConfigHelpers + include Blacklight::DocumentHelperBehavior include Blacklight::LayoutHelperBehavior def repository_collections_path(repository) @@ -91,6 +92,16 @@ def document_or_parent_icon(document) end end + ## + # Override of BL core https://github.com/projectblacklight/blacklight/blob/v8.1.0/app/helpers/blacklight/document_helper_behavior.rb#L55 + # Remove document_type check. It isn't a method on arclight documents + # Check if the document is in the user's bookmarks + # @param [Blacklight::Document] document + # @return [Boolean] + def bookmarked?(document) + current_bookmarks.any? { |x| x.document_id == document.id } + end + def current_context_document @document end diff --git a/spec/features/bookmarks_spec.rb b/spec/features/bookmarks_spec.rb new file mode 100644 index 000000000..b6807cf87 --- /dev/null +++ b/spec/features/bookmarks_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Bookmarks' do + it 'shows bookmarks as checkboxes', js: true do + visit solr_document_path('aoa271aspace_a951375d104030369a993ff943f61a77') + check 'Bookmark' + click_link 'Bookmarks' + + visit solr_document_path('aoa271aspace_a951375d104030369a993ff943f61a77') + expect(page).to have_css('input[type="checkbox"][checked]') + uncheck 'In Bookmarks' + end +end