Skip to content

Commit

Permalink
Merge pull request #3385 from projectblacklight/release-8.x-backports
Browse files Browse the repository at this point in the history
Release 8.x backports
  • Loading branch information
jcoyne authored Oct 23, 2024
2 parents b254af1 + 94b2110 commit 0d8c463
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<div class="search-context page-links">
<%= link_to_previous_document %> |
<% if total == 1 %>
<%= item_page_entry_info %>
<% else %>
<%= link_to_previous_document %> |

<%= item_page_entry_info %> |
<%= item_page_entry_info %> |

<%= link_to_next_document %>
<%= link_to_next_document %>
<% end %>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def initialize(search_context:, search_session:, current_document:)
end

def render?
@search_context.present? && (@search_context[:prev] || @search_context[:next]) && (@search_session['document_id'] == @current_document_id)
@search_context.present? && (@search_context[:prev] || @search_context[:next] || total.positive?) && (@search_session['document_id'] == @current_document_id)
end

##
Expand Down
2 changes: 1 addition & 1 deletion app/components/blacklight/skip_link_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<nav id="skip-link" role="navigation" class="visually-hidden-focusable sr-only sr-only-focusable" aria-label="<%= t('blacklight.skip_links.label') %>">
<div class="container-xl">
<%= link_to_search %>
<%= link_to_main %>
<%= link_to_search %>
<%= content %>
</div>
</nav>
8 changes: 5 additions & 3 deletions app/javascript/blacklight/checkbox_submit.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export default class CheckboxSubmit {
this.labelTarget.removeAttribute('disabled')
this.checkboxTarget.removeAttribute('disabled')
this.updateStateFor(!this.checked)
if (this.bookmarkCounter()) this.bookmarkCounter().innerHTML = json.bookmarks.count
this.bookmarksCounter().forEach(counter => {
counter.innerHTML = json.bookmarks.count;
});
}).catch((error) => {
this.handleError(error)
})
Expand All @@ -63,8 +65,8 @@ export default class CheckboxSubmit {
return this.form.querySelector('[data-checkboxsubmit-target="span"]')
}

bookmarkCounter() {
return document.querySelector('[data-role="bookmark-counter"]')
bookmarksCounter() {
return document.querySelectorAll('[data-role="bookmark-counter"]')
}

handleError() {
Expand Down
2 changes: 2 additions & 0 deletions lib/generators/blacklight/user_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def generate_devise_assets
" self.string_display_key ||= :email\n"
end
gsub_file("config/initializers/devise.rb", "config.sign_out_via = :delete", "config.sign_out_via = :get")
# Work around for https://github.com/heartcombo/devise/issues/5720
gsub_file("config/initializers/devise.rb", "# config.reload_routes = true", "config.reload_routes = false")
end

# Add Blacklight to the user model
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "8.4.0",
"description": "The frontend code and styles for Blacklight",
"main": "app/assets/javascripts/blacklight",
"type": "module",
"module": "app/assets/javascripts/blacklight/blacklight.esm.js",
"scripts": {
"prepare": "rollup --config rollup.config.js --sourcemap && ESM=true rollup --config rollup.config.js --sourcemap"
Expand All @@ -22,7 +23,7 @@
},
"homepage": "https://github.com/projectblacklight/blacklight#readme",
"devDependencies": {
"rollup": "^2.60.0",
"rollup": "^4.24.0",
"rollup-plugin-includepaths": "^0.2.4"
},
"browserslist": [
Expand Down
18 changes: 6 additions & 12 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
'use strict'

import includePaths from 'rollup-plugin-includepaths';

const path = require('path')

const BUNDLE = process.env.BUNDLE === 'true'
const ESM = process.env.ESM === 'true'
Expand All @@ -19,19 +16,16 @@ let includePathOptions = {
};

const rollupConfig = {
input: path.resolve(__dirname, `app/javascript/blacklight/index.js`),
input: 'app/javascript/blacklight/index.js',
output: {
file: path.resolve(__dirname, `app/assets/javascripts/blacklight/${fileDest}.js`),
format: ESM ? 'esm' : 'umd',
file: `app/assets/javascripts/blacklight/${fileDest}.js`,
format: ESM ? 'es' : 'umd',
globals,
generatedCode: 'es2015'
generatedCode: { preset: 'es2015' },
name: ESM ? undefined : 'Blacklight'
},
external,
plugins: [includePaths(includePathOptions)]
}

if (!ESM) {
rollupConfig.output.name = 'Blacklight'
}

module.exports = rollupConfig
export default rollupConfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

let(:current_document_id) { 9 }
let(:current_document) { SolrDocument.new(id: current_document_id) }
let(:search_session) { { 'document_id' => current_document_id } }
let(:search_session) { { 'document_id' => current_document_id, 'counter' => 1, 'total' => '3' } }
let(:instance) { described_class.new(search_context: search_context, search_session: search_session, current_document: current_document) }

before do
Expand All @@ -23,6 +23,17 @@
end
end

context 'when there is exactly one search result with no next or previous document' do
let(:search_context) { { prev: nil, next: nil } }
let(:search_session) { { 'document_id' => current_document_id, 'counter' => 1, 'total' => '1' } }

it "renders single page count" do
expect(render.to_html).to include '<strong>1</strong> of <strong>1</strong>'
expect(render.css('span.previous').to_html).to be_blank
expect(render.css('span.next').to_html).to be_blank
end
end

context 'when there is next and previous' do
let(:search_context) { { next: next_doc, prev: prev_doc } }
let(:prev_doc) { SolrDocument.new(id: '777') }
Expand Down
4 changes: 2 additions & 2 deletions tasks/blacklight.rake
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def with_solr(&block)
# We're being invoked by the app entrypoint script and solr is already up via docker compose
if ENV['SOLR_ENV'] == 'docker-compose'
yield
elsif system('docker compose -v')
elsif system('docker compose version')
# We're not running `docker compose up' but still want to use a docker instance of solr.
begin
puts "Starting Solr"
Expand All @@ -47,7 +47,7 @@ task ci: ['build:npm'] do
with_solr do
Rake::Task['blacklight:internal:seed'].invoke
within_test_app do
# Precompiles the javascript
# Precompiles the assets
system "bin/rake spec:prepare"
end
Rake::Task['blacklight:coverage'].invoke
Expand Down

0 comments on commit 0d8c463

Please sign in to comment.