Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to using the bookmark icon by default #3389

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/blacklight/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ def initialized_default_configuration?
# @!attribute bookmark_icon_component
# @since v8.3.1
# component class used to render a document
# set to Blacklight::Icons::BookmarkIconComponent to replace checkbox with icon
property :bookmark_icon_component, default: nil
# set to nil if a checkbox is prefered to the icon
property :bookmark_icon_component, default: Blacklight::Icons::BookmarkIconComponent

# @!attribute index
# General configuration for all views
Expand Down
45 changes: 24 additions & 21 deletions spec/features/bookmarks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,25 @@
expect(page).to have_content 'Successfully removed bookmark.'
end

it 'shows bookmarks as checkboxes', :js do
visit solr_document_path('2007020969')
check 'Bookmark'
context 'when bookmark_icon_component is set to nil' do
let!(:default_bookmark_icon_component) { CatalogController.blacklight_config.bookmark_icon_component }

visit solr_document_path('2007020969')
expect(page).to have_css('input[type="checkbox"][checked]')
uncheck 'In Bookmarks'
before do
CatalogController.blacklight_config.bookmark_icon_component = nil
end

after do
CatalogController.blacklight_config.bookmark_icon_component = default_bookmark_icon_component
end

it 'shows bookmarks as checkboxes', :js do
visit solr_document_path('2007020969')
check 'Bookmark'

visit solr_document_path('2007020969')
expect(page).to have_css('input[type="checkbox"][checked]')
uncheck 'In Bookmarks'
end
end

it "adds bookmarks after a user logs in" do
Expand Down Expand Up @@ -87,18 +99,8 @@
expect(page).to have_content 'Ci an zhou bian'
end

context "has bookmark icon" do
let!(:default_bookmark_icon_component) { CatalogController.blacklight_config.bookmark_icon_component }

before do
CatalogController.blacklight_config.bookmark_icon_component = Blacklight::Icons::BookmarkIconComponent
end

after do
CatalogController.blacklight_config.bookmark_icon_component = default_bookmark_icon_component
end

it 'shows bookmark icon instead of checkbox', :js do
context "when the bookmark icon is configured (default)" do
it 'shows bookmark icon', :js do
visit solr_document_path('2007020969')
expect(page).to have_css('.blacklight-icons-bookmark')
find('.blacklight-icons-bookmark').click
Expand All @@ -122,12 +124,13 @@
it 'adds and removes bookmarks', :js do
visit solr_document_path('2007020969')
expect(page).to have_no_css('#bookmarks_nav')
check 'Bookmark'
find('.blacklight-icons-bookmark').click

expect(page).to have_content 'In Bookmarks'

visit solr_document_path('2007020969')
expect(page).to have_css('input[type="checkbox"][checked]')
uncheck 'In Bookmarks'
expect(find('.toggle-bookmark-input', visible: false)).to be_checked
find('.blacklight-icons-bookmark').click
end
end
end