additional custom form changes to support multiple autocomplete fields

This commit is contained in:
tworrall 2012-03-13 16:17:11 +00:00
parent e1cedc156d
commit 07c9c7c066
9 changed files with 355 additions and 103 deletions

View file

@ -13,6 +13,11 @@
<#assign editMode = "add"> <#assign editMode = "add">
</#if> </#if>
<#assign newUriSentinel = "" />
<#if editConfigurationConstants?has_content>
<#assign newUriSentinel = editConfigurationConstants["NEW_URI_SENTINEL"] />
</#if>
<#assign htmlForElements = editConfiguration.pageData.htmlForElements /> <#assign htmlForElements = editConfiguration.pageData.htmlForElements />
<#--Retrieve variables needed--> <#--Retrieve variables needed-->
@ -41,7 +46,7 @@
<#assign requiredHint = "<span class='requiredHint'> *</span>" /> <#assign requiredHint = "<span class='requiredHint'> *</span>" />
<#assign yearHint = "<span class='hint'>(YYYY)</span>" /> <#assign yearHint = "<span class='hint'>(YYYY)</span>" />
<h2>${titleVerb}&nbsp;award or honor for ${editConfiguration.subjectName}</h2> <h2>${titleVerb}&nbsp;presentation entry for ${editConfiguration.subjectName}</h2>
<#--Display error messages if any--> <#--Display error messages if any-->
<#if submissionErrors?has_content> <#if submissionErrors?has_content>
@ -177,7 +182,8 @@ var customFormData = {
editMode: '${editMode}', editMode: '${editMode}',
defaultTypeName: 'presentation', defaultTypeName: 'presentation',
multipleTypeNames: {presentation: 'presentation', conference: 'conference'}, multipleTypeNames: {presentation: 'presentation', conference: 'conference'},
baseHref: '${urls.base}/individual?uri=' baseHref: '${urls.base}/individual?uri=',
newUriSentinel : '${newUriSentinel}'
}; };
</script> </script>

View file

@ -7,6 +7,10 @@
<#--Retrieve certain edit configuration information--> <#--Retrieve certain edit configuration information-->
<#assign editMode = editConfiguration.pageData.editMode /> <#assign editMode = editConfiguration.pageData.editMode />
<#assign newUriSentinel = "" />
<#if editConfigurationConstants?has_content>
<#assign newUriSentinel = editConfigurationConstants["NEW_URI_SENTINEL"] />
</#if>
<#assign sparqlForAcFilter = editConfiguration.pageData.sparqlForAcFilter /> <#assign sparqlForAcFilter = editConfiguration.pageData.sparqlForAcFilter />
@ -114,7 +118,7 @@
<div class="acSelection" acGroupName="collection" > <div class="acSelection" acGroupName="collection" >
<p class="inline"> <p class="inline">
<label>Selected Venue:</label> <label>Selected Journal:</label>
<span class="acSelectionInfo"></span> <span class="acSelectionInfo"></span>
<a href="" class="verifyMatch" title="verify match">(Verify this match</a> or <a href="" class="verifyMatch" title="verify match">(Verify this match</a> or
<a href="#" class="changeSelection" id="changeSelection">change selection)</a> <a href="#" class="changeSelection" id="changeSelection">change selection)</a>
@ -130,7 +134,7 @@
<div class="acSelection" acGroupName="book" > <div class="acSelection" acGroupName="book" >
<p class="inline"> <p class="inline">
<label>Selected Venue:</label> <label>Selected Book:</label>
<span class="acSelectionInfo"></span> <span class="acSelectionInfo"></span>
<a href="" class="verifyMatch" title="verify match">(Verify this match</a> or <a href="" class="verifyMatch" title="verify match">(Verify this match</a> or
<a href="#" class="changeSelection" id="changeSelection">change selection)</a> <a href="#" class="changeSelection" id="changeSelection">change selection)</a>
@ -146,7 +150,7 @@
<div class="acSelection" acGroupName="conference" > <div class="acSelection" acGroupName="conference" >
<p class="inline"> <p class="inline">
<label>Selected Venue:</label> <label>Selected Event:</label>
<span class="acSelectionInfo"></span> <span class="acSelectionInfo"></span>
<a href="" class="verifyMatch" title="verify match">(Verify this match</a> or <a href="" class="verifyMatch" title="verify match">(Verify this match</a> or
<a href="#" class="changeSelection" id="changeSelection">change selection)</a> <a href="#" class="changeSelection" id="changeSelection">change selection)</a>
@ -170,6 +174,7 @@
<input class="acUriReceiver" type="hidden" id="eventUri" name="eventUri" value="${eventUriValue}" /> <input class="acUriReceiver" type="hidden" id="eventUri" name="eventUri" value="${eventUriValue}" />
</div> </div>
<#-- Editor --> <#-- Editor -->
<p> <p>
<label for="editor">Editor</label> <label for="editor">Editor</label>
@ -261,13 +266,14 @@
editMode: '${editMode}', editMode: '${editMode}',
defaultTypeName: 'publication', // used in repair mode to generate button text defaultTypeName: 'publication', // used in repair mode to generate button text
multipleTypeNames: {collection: 'publication', book: 'book', conference: 'conference', event: 'event', editor: 'editor', publisher: 'publisher'}, multipleTypeNames: {collection: 'publication', book: 'book', conference: 'conference', event: 'event', editor: 'editor', publisher: 'publisher'},
baseHref: '${urls.base}/individual?uri=' baseHref: '${urls.base}/individual?uri=',
newUriSentinel : '${newUriSentinel}'
}; };
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function(){ $(document).ready(function(){
publicationToPersonUtils.onLoad(); publicationToPersonUtils.onLoad('${urls.base}/individual?uri=', '${newUriSentinel}');
}); });
</script> </script>
</section> </section>

View file

@ -3,13 +3,14 @@
var awardReceiptUtils = { var awardReceiptUtils = {
onLoad: function(mode) { onLoad: function(mode, subjectName) {
this.initObjectReferences(); this.initObjectReferences();
this.bindEventListeners(); this.bindEventListeners();
// in edit mode, copy the year awarded to the displayed input element // in edit mode, copy the year awarded to the displayed input element
if ( mode == "edit" ) { if ( mode == "edit" ) {
this.displayedYear.val(this.yearAwarded.val()); this.displayedYear.val(this.yearAwarded.val());
} }
this.subjectName = subjectName;
}, },
initObjectReferences: function() { initObjectReferences: function() {
@ -35,7 +36,7 @@ var awardReceiptUtils = {
buildAwardReceiptLabel: function() { buildAwardReceiptLabel: function() {
var rdfsLabel = this.award.val(); var rdfsLabel = this.award.val();
if ( this.yearAwarded.val().length ) { if ( this.yearAwarded.val().length ) {
rdfsLabel += " (" + this.yearAwarded.val() + ")"; rdfsLabel += " (" + this.subjectName + ' - ' + this.yearAwarded.val() + ")";
} }
this.recLabel.val(rdfsLabel); this.recLabel.val(rdfsLabel);
}, },

View file

@ -82,6 +82,9 @@ var customForm = {
if ( this.multipleTypeNames != undefined || this.multipleTypeNames != null ) { if ( this.multipleTypeNames != undefined || this.multipleTypeNames != null ) {
this.hasMultipleTypeNames = true; this.hasMultipleTypeNames = true;
} }
// Used with the cancel link. If the user cancels after a type selection, this check
// ensures that any a/c fields (besides the one associated with the type) will be reset
this.clearAcSelections = false;
}, },
@ -170,6 +173,7 @@ var customForm = {
this.cancel.click(function() { this.cancel.click(function() {
customForm.clearFormData(); // clear any input and validation errors customForm.clearFormData(); // clear any input and validation errors
customForm.initFormTypeView(); customForm.initFormTypeView();
customForm.clearAcSelections = true;
return false; return false;
}); });
// In one-step forms, if there is a type selection field, but no value is selected, // In one-step forms, if there is a type selection field, but no value is selected,
@ -206,6 +210,7 @@ var customForm = {
this.typeSelector.change(function() { this.typeSelector.change(function() {
var typeVal = $(this).val(); var typeVal = $(this).val();
this.acCache = {};
// If an autocomplete selection has been made, undo it. // If an autocomplete selection has been made, undo it.
// NEED TO LINK THE TYPE SELECTOR TO THE ACSELECTOR IT'S ASSOCIATED WITH // NEED TO LINK THE TYPE SELECTOR TO THE ACSELECTOR IT'S ASSOCIATED WITH
@ -371,16 +376,6 @@ var customForm = {
customForm.acFilter = customForm.acFilter.concat(this.acFilterForIndividuals); customForm.acFilter = customForm.acFilter.concat(this.acFilterForIndividuals);
}, },
// Reset some autocomplete values after type is changed
resetAutocomplete: function(typeVal) {
// Append the type parameter to the base autocomplete url
var glue = this.baseAcUrl.indexOf('?') > -1 ? '&' : '?';
this.acUrl = this.baseAcUrl + glue + 'type=' + typeVal;
// Flush autocomplete cache when type is reset, since the cached values
// pertain only to the previous type.
this.acCache = {};
},
showAutocompleteSelection: function(label, uri, selectedObj) { showAutocompleteSelection: function(label, uri, selectedObj) {
// hide the acSelector field and set it's value to the selected ac item // hide the acSelector field and set it's value to the selected ac item
@ -428,36 +423,73 @@ var customForm = {
// change the type but keep the value. If no new value has been selected, form initialization // change the type but keep the value. If no new value has been selected, form initialization
// below will correctly empty the value anyway. // below will correctly empty the value anyway.
// Check to see if the parameter is the typeSelector. If it is, we need to get the acSelection div
// that is associated with it.
var $acSelectionObj = null; var $acSelectionObj = null;
var $acSelector = null;
// Check to see if the parameter is the typeSelector. If it is, we need to get the acSelection div
// that is associated with it. Also, when the type is changed, we need to determine whether the user
// has selected an existing individual in the corresponding name field or typed the label for a new
// individual. If the latter, we do not want to clear the value on type change. The clearAcSelectorVal
// boolean controls whether the acSelector value gets cleared.
var clearAcSelectorVal = true;
if ( $(selectedObj).attr('id') == "typeSelector" ) { if ( $(selectedObj).attr('id') == "typeSelector" ) {
$acSelectionObj = customForm.acSelections[$(selectedObj).attr('acGroupName')]; $acSelectionObj = customForm.acSelections[$(selectedObj).attr('acGroupName')];
if ( $acSelectionObj.is(':hidden') ) {
clearAcSelectorVal = false;
}
// if the type is being changed after a cancel, any additional a/c fields that may have been set
// by the user should be "undone". Only loop through these if this is not the initial type selection
if ( customForm.clearAcSelections ) {
$.each(customForm.acSelections, function(i, acS) {
var $checkSelection = customForm.acSelections[i];
if ( $checkSelection.is(':hidden') && $checkSelection.attr('acGroupName') != $acSelectionObj.attr('acGroupName') ) {
customForm.resetAcSelection($checkSelection);
$acSelector = customForm.getAcSelector($checkSelection);
$acSelector.parent("p").show();
}
});
}
} }
else { else {
$acSelectionObj = $(selectedObj); $acSelectionObj = $(selectedObj);
} }
var $acSelector = null;
$.each(this.acSelectors, function() { $acSelector = this.getAcSelector($acSelectionObj);
if ( $(this).attr('acGroupName') == $acSelectionObj.attr('acGroupName') ) {
$acSelector = $(this);
}
});
$acSelector.parent("p").show(); $acSelector.parent("p").show();
this.hideFields($acSelectionObj); this.resetAcSelection($acSelectionObj);
$acSelectionObj.removeClass('userSelected'); if ( clearAcSelectorVal == true ) {
//Might be useful here to replace the uri with the default "new uri needs to be created" value $acSelector.val('');
//$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('');
customForm.addAcHelpText($acSelector); customForm.addAcHelpText($acSelector);
//Resetting so disable submit button again for object property autocomplete //Resetting so disable submit button again for object property autocomplete
if ( this.acSelectOnly ) { if ( this.acSelectOnly ) {
this.disableSubmit(); this.disableSubmit();
} }
this.clearAcSelections = false;
},
// this is essentially a subtask of undoAutocompleteSelection
resetAcSelection: function(selectedObj) {
this.hideFields($(selectedObj));
$(selectedObj).removeClass('userSelected');
$(selectedObj).find("input.acUriReceiver").val(this.newUriSentinel);
$(selectedObj).find("span").text('');
$(selectedObj).find("a.verifyMatch").attr('href', this.baseHref);
},
// loops through the array of acSelector fields and returns the one
// associated with the selected object
getAcSelector: function(selectedObj){
var $selector = null
$.each(this.acSelectors, function() {
if ( $(this).attr('acGroupName') == $(selectedObj).attr('acGroupName') ) {
$selector = $(this);
}
});
return $selector;
}, },
// Set type uri for autocomplete, and type name for labels and button text. // Set type uri for autocomplete, and type name for labels and button text.

View file

@ -3,11 +3,13 @@
var publicationToPersonUtils = { var publicationToPersonUtils = {
onLoad: function(mode) { onLoad: function(href, sentinel) {
this.initObjectReferences(); this.initObjectReferences();
this.bindEventListeners(); this.bindEventListeners();
this.autoDateLabel.hide(); this.autoDateLabel.hide();
this.baseHref = href;
this.newUriSentinel = sentinel;
$.extend(this, vitro.customFormUtils);
}, },
initObjectReferences: function() { initObjectReferences: function() {
@ -32,6 +34,8 @@ var publicationToPersonUtils = {
this.endPage = $('#endPage'); this.endPage = $('#endPage');
this.ePLabel = $('#ePLabel'); this.ePLabel = $('#ePLabel');
this.typeSelector = $('#typeSelector'); this.typeSelector = $('#typeSelector');
this.cancel = $('.cancel');
this.fullViewOnly = $('.fullViewOnly');
this.autoDateLabel = null; this.autoDateLabel = null;
this.form.find('label').each(function() { this.form.find('label').each(function() {
@ -50,8 +54,13 @@ var publicationToPersonUtils = {
this.idCache = {}; this.idCache = {};
this.typeSelector.change(function() { this.typeSelector.change(function() {
// controls the fieldsForNewPub div. If the user selects an existing pub/title,
// this div gets hidden.
publicationToPersonUtils.showFieldsForPub(); publicationToPersonUtils.showFieldsForPub();
publicationToPersonUtils.displayFieldsForType(); // after a cancel, the first reset of the type selector resulted in all fields being displayed.
// by delaying this function just slightly, the timing issue between this js and the
// customFormWithAutocomplete js is resolved
window.setTimeout('publicationToPersonUtils.displayFieldsForType()', 60);
}); });
// we need the delay in the next two functions to ensure the correct timing after the user // we need the delay in the next two functions to ensure the correct timing after the user
@ -67,6 +76,7 @@ var publicationToPersonUtils = {
this.changeLink.click( function() { this.changeLink.click( function() {
publicationToPersonUtils.showFieldsForPub(); publicationToPersonUtils.showFieldsForPub();
}); });
}, },
hideFieldsForPub: function() { hideFieldsForPub: function() {
@ -76,12 +86,24 @@ var publicationToPersonUtils = {
}, },
showFieldsForPub: function() { showFieldsForPub: function() {
this.fieldsForNewPub.show(); this.fieldsForNewPub.show();
}, },
displayFieldsForType: function() { resetAcSelection: function(groupName) {
// hide everything, then show what's needed based on type var $acSelection = this.form.find('div.acSelection').attr('acGroupName', groupName);
// simpler in the event the user changes the type this.hideFields($acSelection);
$acSelection.removeClass('userSelected');
$acSelection.find("input.acUriReceiver").val(this.newUriSentinel);
$acSelection.find("span").text('');
$acSelection.find("a.verifyMatch").attr('href', this.baseHref);
},
getAcUriReceiverVal: function(groupName) {
var $collectionDiv = this.form.find('div.acSelection').attr('acGroupName', groupName);
return $collectionDiv.find('input#'+ groupName + 'Uri').val();
},
hideAllFields: function() {
this.collection.parent('p').hide(); this.collection.parent('p').hide();
this.book.parent('p').hide(); this.book.parent('p').hide();
this.presentedAt.parent('p').hide(); this.presentedAt.parent('p').hide();
@ -97,10 +119,21 @@ var publicationToPersonUtils = {
this.issueLabel.hide(); this.issueLabel.hide();
this.startPage.parent('p').hide(); this.startPage.parent('p').hide();
this.sPLabel.parent('p').hide(); this.sPLabel.parent('p').hide();
},
displayFieldsForType: function() {
// hide everything, then show what's needed based on type
// simpler in the event the user changes the type
this.hideAllFields();
var selectedType = this.typeSelector.find(':selected').text(); var selectedType = this.typeSelector.find(':selected').text();
if ( selectedType == 'Academic Article' || selectedType == 'Article' || selectedType == 'Editorial Article' || selectedType == 'Review') { if ( selectedType == 'Academic Article' || selectedType == 'Article' || selectedType == 'Editorial Article' || selectedType == 'Review') {
this.collection.parent('p').show(); // if the user has changed type, keep any relevant values and display the
// acSelection as appropriate
var ckForVal = this.getAcUriReceiverVal('collection');
if ( ckForVal == '' || ckForVal == this.newUriSentinel ) {
this.collection.parent('p').show();
}
this.volume.show(); this.volume.show();
this.volLabel.show(); this.volLabel.show();
this.number.show(); this.number.show();
@ -109,31 +142,222 @@ var publicationToPersonUtils = {
this.issueLabel.show(); this.issueLabel.show();
this.startPage.parent('p').show(); this.startPage.parent('p').show();
this.sPLabel.parent('p').show(); this.sPLabel.parent('p').show();
// if the user has changed type, ensure that irrelevant fields are cleared
// and reset an acSelection divs
if ( this.book.val() != '' && this.book.val().substring(0, 18) != "Select an existing" ) {
alert(this.book.val());
this.book.val('');
this.resetAcSelection('book');
alert(this.book.val());
}
if ( this.editor.val() != '' && this.editor.val().substring(0, 18) != "Select an existing" ) {
this.editor.val('');
this.resetAcSelection('editor');
}
if ( this.publisher.val() != '' && this.publisher.val().substring(0, 18) != "Select an existing" ) {
this.publisher.val('');
this.resetAcSelection('publisher');
}
if ( this.presentedAt.val() != '' && this.presentedAt.val().substring(0, 18) != "Select an existing" ) {
this.presentedAt.val('');
this.resetAcSelection('conference');
}
if ( this.proceedingsOf.val() != '' && this.proceedingsOf.val().substring(0, 18) != "Select an existing" ) {
this.proceedingsOf.val('');
this.resetAcSelection('event');
}
this.locale.val('');
} }
else if ( selectedType == 'Chapter' ) { else if ( selectedType == 'Chapter' ) {
this.book.parent('p').show(); // if the user has changed type, keep any relevant values and display the
this.editor.parent('p').show(); // acSelection as appropriate
this.publisher.parent('p').show(); var ckForVal = this.getAcUriReceiverVal('book');
if ( ckForVal == '' || ckForVal == this.newUriSentinel ) {
this.book.parent('p').show();
}
ckForVal = this.getAcUriReceiverVal('editor');
if ( ckForVal == '' || ckForVal == this.newUriSentinel ) {
this.editor.parent('p').show();
}
ckForVal = this.getAcUriReceiverVal('publisher');
if ( ckForVal == '' || ckForVal == this.newUriSentinel ) {
this.publisher.parent('p').show();
}
this.locale.parent('p').show(); this.locale.parent('p').show();
this.volume.show(); this.volume.show();
this.volLabel.show(); this.volLabel.show();
// if the user is changing type, ensure that irrelevant fields are cleared
// and reset an acSelection divs
if ( this.collection.val() != '' && this.collection.val().substring(0, 18) != "Select an existing" ) {
this.collection.val('');
this.resetAcSelection('collection');
}
if ( this.presentedAt.val() != '' && this.presentedAt.val().substring(0, 18) != "Select an existing" ) {
this.presentedAt.val('');
this.resetAcSelection('conference');
}
if ( this.proceedingsOf.val() != '' && this.proceedingsOf.val().substring(0, 18) != "Select an existing" ) {
this.proceedingsOf.val('');
this.resetAcSelection('event');
}
this.number.val('');
this.issue.val('');
this.startPage.val('');
this.endPage.val('');
} }
else if ( selectedType == 'Book' || selectedType == 'Edited Book' ) { else if ( selectedType == 'Book' || selectedType == 'Edited Book' ) {
this.editor.parent('p').show(); // if the user has changed type, keep any relevant values and display the
this.publisher.parent('p').show(); // acSelection as appropriate
var ckForVal = this.getAcUriReceiverVal('editor');
if ( ckForVal == '' || ckForVal == this.newUriSentinel ) {
this.editor.parent('p').show();
}
ckForVal = this.getAcUriReceiverVal('publisher');
if ( ckForVal == '' || ckForVal == this.newUriSentinel ) {
this.publisher.parent('p').show();
}
this.locale.parent('p').show(); this.locale.parent('p').show();
this.volume.show(); this.volume.show();
this.volLabel.show(); this.volLabel.show();
// if the user is changing type, ensure that irrelevant fields are cleared
// and reset an acSelection divs
if ( this.collection.val() != '' && this.collection.val().substring(0, 18) != "Select an existing" ) {
this.collection.val('');
this.resetAcSelection('collection');
}
if ( this.presentedAt.val() != '' && this.presentedAt.val().substring(0, 18) != "Select an existing" ) {
this.presentedAt.val('');
this.resetAcSelection('conference');
}
if ( this.proceedingsOf.val() != '' && this.proceedingsOf.val().substring(0, 18) != "Select an existing" ) {
this.proceedingsOf.val('');
this.resetAcSelection('event');
}
this.number.val('');
this.issue.val('');
this.startPage.val('');
this.endPage.val('');
} }
else if ( selectedType == 'Conference Paper' ) { else if ( selectedType == 'Conference Paper' ) {
// this.collection.parent('p').show(); // if the user has changed type, keep any relevant values and display the
this.presentedAt.parent('p').show(); // acSelection as appropriate
// this.startPage.parent('p').show(); var ckForVal = this.getAcUriReceiverVal('collection');
// this.sPLabel.parent('p').show(); if ( ckForVal == '' || ckForVal == this.newUriSentinel ) {
this.collection.parent('p').show();
}
ckForVal = this.getAcUriReceiverVal('conference');
if ( ckForVal == '' || ckForVal == this.newUriSentinel ) {
this.presentedAt.parent('p').show();
}
this.startPage.parent('p').show();
this.sPLabel.parent('p').show();
// if the user is changing type, ensure that irrelevant fields are cleared
// and reset an acSelection divs
if ( this.book.val() != '' && this.book.val().substring(0, 18) != "Select an existing" ) {
this.book.val('');
this.resetAcSelection('book');
}
if ( this.editor.val() != '' && this.editor.val().substring(0, 18) != "Select an existing" ) {
this.editor.val('');
this.resetAcSelection('editor');
}
if ( this.publisher.val() != '' && this.publisher.val().substring(0, 18) != "Select an existing" ) {
this.publisher.val('');
this.resetAcSelection('publisher');
}
if ( this.proceedingsOf.val() != '' && this.proceedingsOf.val().substring(0, 18) != "Select an existing" ) {
this.proceedingsOf.val('');
this.resetAcSelection('event');
}
this.number.val('');
this.issue.val('');
this.startPage.val('');
this.endPage.val('');
} }
else if ( selectedType == 'Conference Poster' || selectedType == 'Speech') { else if ( selectedType == 'Conference Poster' || selectedType == 'Speech') {
this.presentedAt.parent('p').show(); // if the user has changed type, keep any relevant values and display the
// acSelection as appropriate
var ckForVal = this.getAcUriReceiverVal('conference');
if ( ckForVal == '' || ckForVal == this.newUriSentinel ) {
this.presentedAt.parent('p').show();
}
// if the user is changing type, ensure that irrelevant fields are cleared
// and reset an acSelection divs
if ( this.collection.val() != '' && this.collection.val().substring(0, 18) != "Select an existing" ) {
this.collection.val('');
this.resetAcSelection('collection');
}
if ( this.book.val() != '' && this.book.val().substring(0, 18) != "Select an existing" ) {
this.book.val('');
this.resetAcSelection('book');
}
if ( this.editor.val() != '' && this.editor.val().substring(0, 18) != "Select an existing" ) {
this.editor.val('');
this.resetAcSelection('editor');
}
if ( this.publisher.val() != '' && this.publisher.val().substring(0, 18) != "Select an existing" ) {
this.publisher.val('');
this.resetAcSelection('publisher');
}
if ( this.proceedingsOf.val() != '' && this.proceedingsOf.val().substring(0, 18) != "Select an existing" ) {
this.proceedingsOf.val('');
this.resetAcSelection('event');
}
this.number.val('');
this.issue.val('');
this.startPage.val('');
this.endPage.val('');
} }
else {
// if the user is changing type, ensure that irrelevant fields are cleared
// and reset an acSelection divs
if ( this.collection.val() != '' && this.collection.val().substring(0, 18) != "Select an existing" ) {
this.collection.val('');
this.resetAcSelection('collection');
}
if ( this.book.val() != '' && this.book.val().substring(0, 18) != "Select an existing" ) {
this.book.val('');
this.resetAcSelection('book');
}
if ( this.editor.val() != '' && this.editor.val().substring(0, 18) != "Select an existing" ) {
this.editor.val('');
this.resetAcSelection('editor');
}
if ( this.publisher.val() != '' && this.publisher.val().substring(0, 18) != "Select an existing" ) {
this.publisher.val('');
this.resetAcSelection('publisher');
}
if ( this.proceedingsOf.val() != '' && this.proceedingsOf.val().substring(0, 18) != "Select an existing" ) {
this.proceedingsOf.val('');
this.resetAcSelection('event');
}
if ( this.presentedAt.val() != '' && this.presentedAt.val().substring(0, 18) != "Select an existing" ) {
this.presentedAt.val('');
this.resetAcSelection('conference');
}
this.volume.val('');
this.number.val('');
this.issue.val('');
this.startPage.val('');
this.endPage.val('');
}
} }
} }

View file

@ -13,6 +13,11 @@
<#assign editMode = "add"> <#assign editMode = "add">
</#if> </#if>
<#assign newUriSentinel = "" />
<#if editConfigurationConstants?has_content>
<#assign newUriSentinel = editConfigurationConstants["NEW_URI_SENTINEL"] />
</#if>
<#assign htmlForElements = editConfiguration.pageData.htmlForElements /> <#assign htmlForElements = editConfiguration.pageData.htmlForElements />
<#--Retrieve variables needed--> <#--Retrieve variables needed-->
@ -159,14 +164,15 @@ var customFormData = {
editMode: '${editMode}', editMode: '${editMode}',
defaultTypeName: 'award', defaultTypeName: 'award',
multipleTypeNames: {award: 'award', org: 'organization'}, multipleTypeNames: {award: 'award', org: 'organization'},
baseHref: '${urls.base}/individual?uri=' baseHref: '${urls.base}/individual?uri=',
newUriSentinel : '${newUriSentinel}'
}; };
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function(){ $(document).ready(function(){
awardReceiptUtils.onLoad("${editMode}"); awardReceiptUtils.onLoad('${editMode}', '${editConfiguration.subjectName}');
}); });
</script> </script>

View file

@ -64,7 +64,7 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
roleLabelAssertion, roleLabelAssertion,
presTypeAssertion, presTypeAssertion,
presLabelAssertion ) ); presLabelAssertion ) );
conf.setN3Optional( Arrays.asList( n3ForConference, n3ForConfLabel, n3ForStart, n3ForEnd ) ); conf.setN3Optional( Arrays.asList( n3ForConference, n3ForStart, n3ForEnd ) );
conf.addNewResource("presentation", DEFAULT_NS_FOR_NEW_RESOURCE); conf.addNewResource("presentation", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("conference", DEFAULT_NS_FOR_NEW_RESOURCE); conf.addNewResource("conference", DEFAULT_NS_FOR_NEW_RESOURCE);
@ -178,9 +178,7 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
final static String n3ForConference = final static String n3ForConference =
"?conference a <" + conferenceClass + "> . \n" + "?conference a <" + conferenceClass + "> . \n" +
"?conference <" + includesEventPred + "> ?presentation . \n" + "?conference <" + includesEventPred + "> ?presentation . \n" +
"?presentation <" + eventWithinPred + "> ?conference . "; "?presentation <" + eventWithinPred + "> ?conference . \n" +
final static String n3ForConfLabel =
"?conference <" + label + "> ?conferenceLabel ."; "?conference <" + label + "> ?conferenceLabel .";
final static String n3ForStart = final static String n3ForStart =

View file

@ -145,17 +145,11 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
getN3NewPubNameAssertion(), getN3NewPubNameAssertion(),
getN3NewPubTypeAssertion(), getN3NewPubTypeAssertion(),
getN3ForCollection(), getN3ForCollection(),
getN3CollectionNameAssertion(),
getN3ForBook(), getN3ForBook(),
getN3BookNameAssertion(),
getN3ForConference(), getN3ForConference(),
getN3ConferenceNameAssertion(),
getN3ForEvent(), getN3ForEvent(),
getN3EventNameAssertion(),
getN3ForEditor(), getN3ForEditor(),
getN3EditorNameAssertion(),
getN3ForPublisher(), getN3ForPublisher(),
getN3PublisherNameAssertion(),
getN3ForLocaleAssertion(), getN3ForLocaleAssertion(),
getN3ForVolumeAssertion(), getN3ForVolumeAssertion(),
getN3ForNumberAssertion(), getN3ForNumberAssertion(),
@ -205,66 +199,48 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
return "@prefix vivo: <" + vivoCore + "> . \n" + return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri vivo:hasPublicationVenue ?collectionUri . \n" + "?pubUri vivo:hasPublicationVenue ?collectionUri . \n" +
"?collectionUri a <" + collectionClass + "> . \n" + "?collectionUri a <" + collectionClass + "> . \n" +
"?collectionUri vivo:publicationVenueFor ?pubUri . "; "?collectionUri vivo:publicationVenueFor ?pubUri . \n" +
} "?collectionUri <" + label + "> ?collection .";
private String getN3CollectionNameAssertion() {
return "?collectionUri <" + label + "> ?collection .";
} }
private String getN3ForBook() { private String getN3ForBook() {
return "@prefix vivo: <" + vivoCore + "> . \n" + return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri vivo:hasPublicationVenue ?bookUri . \n" + "?pubUri vivo:hasPublicationVenue ?bookUri . \n" +
"?bookUri a <" + bookClass + "> . \n" + "?bookUri a <" + bookClass + "> . \n" +
"?bookUri vivo:publicationVenueFor ?pubUri . "; "?bookUri vivo:publicationVenueFor ?pubUri . \n " +
} "?bookUri <" + label + "> ?book .";
private String getN3BookNameAssertion() {
return "?bookUri <" + label + "> ?book .";
} }
private String getN3ForConference() { private String getN3ForConference() {
return "@prefix vivo: <" + vivoCore + "> . \n" + return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri <" + presentedAtPred + "> ?conferenceUri . \n" + "?pubUri <" + presentedAtPred + "> ?conferenceUri . \n" +
"?conferenceUri a <" + conferenceClass + "> . \n" + "?conferenceUri a <" + conferenceClass + "> . \n" +
"?conferenceUri vivo:includesEvent ?pubUri . "; "?conferenceUri vivo:includesEvent ?pubUri . \n" +
} "?conferenceUri <" + label + "> ?conference .";
private String getN3ConferenceNameAssertion() {
return "?conferenceUri <" + label + "> ?conference .";
} }
private String getN3ForEvent() { private String getN3ForEvent() {
return "@prefix vivo: <" + vivoCore + "> . \n" + return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri vivo:proceedingsOf ?eventUri . \n" + "?pubUri vivo:proceedingsOf ?eventUri . \n" +
"?eventUri a <" + conferenceClass + "> . \n" + "?eventUri a <" + conferenceClass + "> . \n" +
"?eventUri vivo:hasProceedings ?pubUri . "; "?eventUri vivo:hasProceedings ?pubUri . \n" +
} "?eventUri <" + label + "> ?event .";
private String getN3EventNameAssertion() {
return "?eventUri <" + label + "> ?event .";
} }
private String getN3ForEditor() { private String getN3ForEditor() {
return "@prefix vivo: <" + vivoCore + "> . \n" + return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri vivo:editor ?editorUri . \n" + "?pubUri vivo:editor ?editorUri . \n" +
"?editorUri a <" + editorClass + "> . \n" + "?editorUri a <" + editorClass + "> . \n" +
"?editorUri vivo:editorOf ?pubUri . "; "?editorUri vivo:editorOf ?pubUri . \n" +
} "?editorUri <" + label + "> ?editor .";
private String getN3EditorNameAssertion() {
return "?editorUri <" + label + "> ?editor .";
} }
private String getN3ForPublisher() { private String getN3ForPublisher() {
return "@prefix vivo: <" + vivoCore + "> . \n" + return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri vivo:publisher ?publisherUri . \n" + "?pubUri vivo:publisher ?publisherUri . \n" +
"?publisherUri a <" + publisherClass + "> . \n" + "?publisherUri a <" + publisherClass + "> . \n" +
"?publisherUri vivo:publisherOf ?pubUri . "; "?publisherUri vivo:publisherOf ?pubUri . \n" +
} "?publisherUri <" + label + "> ?publisher .";
private String getN3PublisherNameAssertion() {
return "?publisherUri <" + label + "> ?publisher .";
} }
private String getN3ForLocaleAssertion() { private String getN3ForLocaleAssertion() {
@ -351,6 +327,12 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
//activity label and role label are literals on form //activity label and role label are literals on form
List<String> literalsOnForm = new ArrayList<String>(); List<String> literalsOnForm = new ArrayList<String>();
literalsOnForm.add("title"); literalsOnForm.add("title");
literalsOnForm.add("collection");
literalsOnForm.add("book");
literalsOnForm.add("conference");
literalsOnForm.add("event");
literalsOnForm.add("editor");
literalsOnForm.add("publisher");
literalsOnForm.add("locale"); literalsOnForm.add("locale");
literalsOnForm.add("volume"); literalsOnForm.add("volume");
literalsOnForm.add("number"); literalsOnForm.add("number");

View file

@ -69,7 +69,6 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
n3ForAwardToReceipt, n3ForAwardToReceipt,
descriptionAssertion, descriptionAssertion,
n3ForOrgAssertion, n3ForOrgAssertion,
orgLabelAssertion,
awardLabelAssertion, awardLabelAssertion,
n3ForYearAwarded, n3ForYearAwarded,
n3ForStart, n3ForStart,
@ -200,11 +199,9 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
"?awardReceipt <"+ descriptionPred +"> ?description ."; "?awardReceipt <"+ descriptionPred +"> ?description .";
final static String n3ForOrgAssertion = final static String n3ForOrgAssertion =
"?awardReceipt <" + awardConferredByPred +"> ?org . \n" + "?award <" + awardConferredByPred +"> ?org . \n" +
"?org a <" + orgClass + "> . \n" + "?org a <" + orgClass + "> . \n" +
"?org <" + awardConferredPred + "> ?awardReceipt ."; "?org <" + awardConferredPred + "> ?award . \n" +
final static String orgLabelAssertion =
"?org <"+ label + "> ?orgLabel ."; "?org <"+ label + "> ?orgLabel .";
final static String n3ForYearAwarded = final static String n3ForYearAwarded =
@ -238,8 +235,8 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
final static String orgQuery = final static String orgQuery =
"SELECT ?existingOrg WHERE { \n" + "SELECT ?existingOrg WHERE { \n" +
" ?awardReceipt <" + awardConferredByPred + "> ?existingOrg . \n" + " ?award <" + awardConferredByPred + "> ?existingOrg . \n" +
" ?existingOrg <" + awardConferredPred + "> ?awardReceipt . }"; " ?existingOrg <" + awardConferredPred + "> ?award . }";
final static String awardReceiptLabelQuery = final static String awardReceiptLabelQuery =
"SELECT ?existingAwardReceiptLabel WHERE { \n" + "SELECT ?existingAwardReceiptLabel WHERE { \n" +