Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.