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

LC above fold and link fixes #30

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

qqmyers
Copy link
Member

@qqmyers qqmyers commented Jan 9, 2025

This PR fixes several issues:

The above-fold display could sometimes remain as a simple link due to the script running twice (on an ajax page refresh). The change here assures that the above-fold field is only updated once/only when the service url has been found from an unexpanded entry in the metadata table.

It adds a 'Project Not Found:" prefix if/when the call to LocalContexts fails (seen on the sandbox when a test project has been deleted).

It fixes the non-LC script formatting of the field that Dataverse creates. The original TSV used the convention of adding " marks around a string and using "" to indicate real quote marks in the string. This resulted in Dataverse producing HTML like
"<a href="" https:="" sandbox.localcontextshub.org="" projects="" 306f39fe-9610-47a9-b264-5f17895e1657="" ""="" target="" _blank""="" rel="" noopener""="">https://sandbox.localcontextshub.org/projects/306f39fe-9610-47a9-b264-5f17895e1657/</a>" The PR removes the start/end quotes and using single " chars internal to the string. That shows the URL without start/end quote marks and generates a usable link to the project. (Now that script rewrites the link in the Project Not Found case, Dataverse's internal formatting would only appear if the script is ever removed/deregistered. So reinstalling the metadatablock is not really required for proper operation with the script.)

It also adds a .val('') when resetting the hidden input. In other scripts (ORCID/ROR) I've seen issues with using the attr('value', ) method on a hidden input - that appears to set the value of the input in the DOM tree one can see in the browser console, but doesn't necessarily/always cause the value to be picked up to be sent back to Dataverse when the metadata is saved. Using the jQuery .val() method does (perhaps it triggers a change event that attr doesn't?). In any case, .val is needed in those other scripts and I've called both .val() and .attr() so the change can be seen in the DOM tree as well. The change here adds the .val() method to be consistent - if it has an effect, it would be to fix a possible intermittent issue with cancelling a project selection not removing the LC project metadata when the metadata is saved - I may have seen this but am not sure - might only have been the other scripts.

@qqmyers
Copy link
Member Author

qqmyers commented Jan 9, 2025

@transfluxus - I wanted to add you as a reviewer but I think you have to accept the invite to the repo first. In any case - take a look and let me know if it's OK to merge this. (Nominally this repo isn't set up like the previewers to allow things to be merged without affecting installations using the script from github.io, but since it sounds like you're aren't using a local copy (we aren't for demo.dataverse.org either right now), I didn't want to push a surprise.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant