Skip to content

Commit

Permalink
Merge pull request #1076 from OpenTreeOfLife/coerce-new-taxon-dois-to…
Browse files Browse the repository at this point in the history
…-urls

Coerce new taxon DOIs to URLs (in curation app)
  • Loading branch information
jar398 authored Oct 13, 2016
2 parents ced8a1f + 7e564cf commit ac11f0b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions curator/static/js/study-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7822,6 +7822,9 @@ function formatDataDepositDOIAsURL() {
*/
function DOItoURL( doi ) {
/* Return the DOI provided (if any) in URL form */
if (!doi) { // null, undefined, or empty string
return "";
}
if (urlPattern.test(doi) === true) {
// It's already in the form of a URL, return unchanged
return doi;
Expand Down Expand Up @@ -9645,12 +9648,31 @@ function disableRankDivider(option, item) {

function updateActiveTaxonSources() {
// trigger validation, updates to next/previous buttons
coerceTaxonSourceDOIsToURLs();
currentTaxonCandidate.valueHasMutated();
updateTaxonSourceDetails();
updateTaxonSourceTypeOptions();
taxonCondidateIsValid(currentTaxonCandidate());
}

function coerceTaxonSourceDOIsToURLs() {
var activeSources = getActiveTaxonSources(currentTaxonCandidate());
$.each(activeSources(), function(i, source) {
switch( source.type ) {
case undefined:
case '':
case 'The taxon is described in this study':
case 'Other':
break;
default:
// its value should be a valid URL (convert simple DOIs)
source.value = DOItoURL( source.value );
activeSources.replace(source, source);
break;
}
});
}

function updateTaxonSourceDetails( ) {
var activeSources = getActiveTaxonSources(currentTaxonCandidate());
$.each(activeSources(), function(i, source) {
Expand Down

0 comments on commit ac11f0b

Please sign in to comment.