-
Notifications
You must be signed in to change notification settings - Fork 0
Ap 840:Metadata link doesn't allow download #114
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
Changes from all commits
4959d4e
65a4594
f58e0de
9a49f4a
866aeb8
af29741
6c2a32a
883edfc
008c77e
43f35fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| export class GeoBlacklightMetadataDownloadButton { | ||
| constructor(el, i, options = {}) { | ||
| this.options = options | ||
| this.el = typeof el === "string" ? document.querySelector(el) : el | ||
| this.download = document.querySelector(this.options.target || this.el.getAttribute("data-ref-download")) | ||
| // On initialization only do this for the first one. | ||
| if (i === 0) { | ||
| this.setRefUrl() | ||
| } | ||
| this.configureHandler() | ||
| } | ||
|
|
||
| configureHandler() { | ||
| this.el.addEventListener("click", () => this.setRefUrl()) | ||
| } | ||
|
|
||
| setRefUrl() { | ||
| const refUrl = this.el.getAttribute("data-ref-endpoint") | ||
| if (!refUrl) { | ||
| this.download.style.display = "none" | ||
| } else { | ||
| this.download.style.display = "" | ||
| this.download.setAttribute("href", refUrl) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| export default function initializeMetadataDownload() { | ||
| const modal = document.getElementById("blacklight-modal") | ||
|
|
||
| // Use Blacklight's dialog-based modal dispatches these custom events | ||
| modal.addEventListener("show.blacklight.blacklight-modal", (e) => { | ||
| e.target.querySelectorAll(".metadata-body").forEach((el) => { | ||
| el.closest(".modal-content").classList.add("metadata-modal") | ||
| }) | ||
|
|
||
| e.target.querySelectorAll(".pill-metadata").forEach((element, i) => { | ||
| new GeoBlacklightMetadataDownloadButton(element, i) | ||
| }) | ||
| }) | ||
|
|
||
| modal.addEventListener("hide.blacklight.blacklight-modal", (e) => { | ||
| e.target.querySelectorAll(".metadata-body").forEach((el) => { | ||
| el.closest(".modal-content").classList.remove("metadata-modal") | ||
| }) | ||
| }) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <%= render Blacklight::System::ModalComponent.new do |component| %> | ||
| <% component.with_title do %> | ||
| <%= t('geoblacklight.metadata.view_metadata') %> | ||
| <% end %> | ||
| <% component.with_body do %> | ||
| <div class="modal-body metadata-body"> | ||
| <%= render partial: 'metadata' %> | ||
| </div> | ||
| <% end %> | ||
| <% component.with_footer do %> | ||
| <a href="#" target="_blank" rel="noopener noreferrer" id="btn-metadata-download" class="btn btn-primary" aria-label="<%= t('geoblacklight.download.download_metadata_new_tab') %>">Download</a> | ||
| <button type="button" class="btn btn-secondary" data-bl-dismiss="modal"><%= t('blacklight.modal.close') %></button> | ||
| <% end %> | ||
| <% end %> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,3 +9,4 @@ | |
| pin '@github/auto-complete-element', to: 'https://cdn.skypack.dev/@github/auto-complete-element' | ||
| pin '@popperjs/core', to: 'https://ga.jspm.io/npm:@popperjs/core@2.11.6/dist/esm/popper.js' | ||
| pin 'bootstrap', to: 'https://ga.jspm.io/npm:bootstrap@5.3.2/dist/js/bootstrap.esm.js' | ||
| pin 'geoblacklight/initializers/metadata_download', to: 'geoblacklight/initializers/metadata_download.js' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this adequate to pull in all the dependencies needed by geoblacklight?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The metadata link is not displayed when a record does not include ISO 19139 metadata. The default Solr sample records from GeoBlacklight are outdated. Most records either lack metadata or contain incorrectly formatted ISO metadata. As a result, the metadata link may not appear, or the metadata modal may display incorrect ISO information. I ingested a record with valid ISO 19139 metadata from GeoCombine, which allows me to properly test the metadata modal and its buttons locally.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you give me an example record? i'm going based on the fixture data that is used for testing.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @yzhoubk OK, I pulled some sample records and indexed them locally. I can confirm that the downloads work for me now. Has a bug been filed upstream for the 5.3.0 download button issue? |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| namespace :geodata do | ||
| namespace :index do | ||
| desc 'Index app fixture metadata into Solr' | ||
| task seed: :environment do | ||
| fixtures_pattern = ENV.fetch('SOLR_FIXTURES_PATH', Rails.root.join('spec', 'fixtures', 'solr_documents', '*.json').to_s) | ||
| docs = Dir[fixtures_pattern].flat_map { |f| JSON.parse(File.read(f)) } | ||
|
|
||
| abort("No Solr fixtures found for pattern: #{fixtures_pattern}") if docs.empty? | ||
|
|
||
| puts "Indexing #{docs.size} fixture document(s) from #{fixtures_pattern}" | ||
| Blacklight.default_index.connection.add(docs) | ||
| Blacklight.default_index.connection.commit | ||
| end | ||
| end | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this intended to be different from the initializer javascript shipped with GeoBlacklight 5.3.0? why do we need to override it?