diff --git a/productMods/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js b/productMods/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js index ecc1e32a..93bb33d5 100644 --- a/productMods/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js +++ b/productMods/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js @@ -254,6 +254,10 @@ var customForm = { $(selectedObj).autocomplete({ minLength: 3, source: function(request, response) { + //Reset the URI of the input to one that says new uri required + //That will be overwritten if value selected from autocomplete + //We do this everytime the user types anything in the autocomplete box + customForm.initDefaultNewURI(selectedObj); if (request.term in customForm.acCache) { // console.log('found term in cache'); response(customForm.acCache[request.term]); @@ -442,7 +446,9 @@ var customForm = { $acSelector.parent("p").show(); this.hideFields($acSelectionObj); $acSelectionObj.removeClass('userSelected'); - $acSelectionObj.find("input.acUriReceiver").val(''); + //Might be useful here to replace the uri with the default "new uri needs to be created" value + //$acSelectionObj.find("input.acUriReceiver").val(''); + $acSelectionObj.find("input.acUriReceiver").val(customForm.newUriSentinel); $acSelectionObj.find("span").text(''); $acSelectionObj.find("a.verifyMatch").attr('href', this.baseHref); $acSelector.val(''); @@ -553,6 +559,13 @@ var customForm = { enableSubmit:function() { this.button.removeAttr('disabled'); this.button.removeClass('disabledSubmit'); + }, + initDefaultNewURI:function(selectedObj) { + //get uri input for selected object and set to value indicating + //this will require a new uri when submitted if the uri is not replaced + //with one selected from autocomplete selection + var $acDiv = this.acSelections[$(selectedObj).attr('acGroupName')]; + $acDiv.find("input").val(customForm.newUriSentinel); } }; diff --git a/productMods/templates/freemarker/edit/forms/personHasAdvisingRelationship.ftl b/productMods/templates/freemarker/edit/forms/personHasAdvisingRelationship.ftl index 29b34a79..76a5fcd9 100644 --- a/productMods/templates/freemarker/edit/forms/personHasAdvisingRelationship.ftl +++ b/productMods/templates/freemarker/edit/forms/personHasAdvisingRelationship.ftl @@ -1,5 +1,8 @@ <#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> - +<#assign newUriSentinel = "" /> +<#if editConfigurationConstants?has_content> + <#assign newUriSentinel = editConfigurationConstants["NEW_URI_SENTINEL"] /> + <#-- this is in request.subject.name --> <#-- leaving this edit/add mode code in for reference in case we decide we need it --> @@ -187,7 +190,8 @@ var customFormData = { sparqlForAcFilter: '${sparqlForAcFilter}', sparqlQueryUrl: '${sparqlQueryUrl}', acFilterForIndividuals: ${acFilterForIndividuals}, - baseHref: '${urls.base}/individual?uri=' + baseHref: '${urls.base}/individual?uri=', + newUriSentinel : '${newUriSentinel}' }; diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/PersonHasAdvisingRelationshipGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/PersonHasAdvisingRelationshipGenerator.java index 56d8c20e..e91b7bc1 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/PersonHasAdvisingRelationshipGenerator.java +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/PersonHasAdvisingRelationshipGenerator.java @@ -72,8 +72,7 @@ public class PersonHasAdvisingRelationshipGenerator extends VivoBaseGenerator im degreeAssertion, firstNameAssertion, lastNameAssertion, - n3ForSubjAreaAssertion, - subjAreaLabelAssertion, + n3ForSubjAreaAssertion + "\n" + subjAreaLabelAssertion, //putting these statements together to prevent an empty label from generating a new URI n3ForStart, n3ForEnd ) );