NIHVIVO-646 Adding an existing person as an author on the add authors to publications form
This commit is contained in:
parent
ac6ccc2981
commit
98c027b00c
6 changed files with 172 additions and 61 deletions
|
@ -3,7 +3,7 @@
|
|||
xmlns:j.0="http://vitro.mannlib.cornell.edu/ns/vitro/0.7#" >
|
||||
<rdf:Description rdf:about="http://vivoweb.org/ontology/core#pmcid">
|
||||
<j.0:hiddenFromDisplayBelowRoleLevelAnnot rdf:resource="http://vitro.mannlib.cornell.edu/ns/vitro/role#public"/>
|
||||
<j.0:prohibitedFromUpdateBelowRoleLevelAnnot rdf:resource="http://vitro.mannlib.cornell.edu/ns/vitro/role#public"/>
|
||||
<j.0:prohibitedFrinformationResourceHasomUpdateBelowRoleLevelAnnot rdf:resource="http://vitro.mannlib.cornell.edu/ns/vitro/role#public"/>
|
||||
</rdf:Description>
|
||||
<rdf:Description rdf:about="http://vivoweb.org/ontology/core#nihmsid">
|
||||
<j.0:hiddenFromDisplayBelowRoleLevelAnnot rdf:resource="http://vitro.mannlib.cornell.edu/ns/vitro/role#public"/>
|
||||
|
@ -1796,6 +1796,7 @@
|
|||
<j.0:offerCreateNewOptionAnnot rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</j.0:offerCreateNewOptionAnnot>
|
||||
<j.0:objectIndividualSortProperty rdf:resource="http://vivoweb.org/ontology/core#authorRank"/>
|
||||
<j.0:prohibitedFromUpdateBelowRoleLevelAnnot rdf:resource="http://vitro.mannlib.cornell.edu/ns/vitro/role#public"/>
|
||||
<j.0:customEntryFormAnnot rdf:datatype="http://www.w3.org/2001/XMLSchema#string">addAuthorsToInformationResource.jsp</j.0:customEntryFormAnnot>
|
||||
</rdf:Description>
|
||||
<rdf:Description rdf:about="http://purl.org/ontology/bibo/isbn10">
|
||||
<j.0:displayLimitAnnot rdf:datatype="http://www.w3.org/2001/XMLSchema#int">1</j.0:displayLimitAnnot>
|
||||
|
|
|
@ -32,7 +32,7 @@ core:authorInAuthorship (Person : Authorship) - inverse of linkedAuthor
|
|||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.DataPropertyComparator" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.CreateLabelFromNameFields"%>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.PublicationHasAuthorValidator" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils" %>
|
||||
|
@ -69,6 +69,7 @@ core:authorInAuthorship (Person : Authorship) - inverse of linkedAuthor
|
|||
<c:set var="rdfs" value="<%= VitroVocabulary.RDFS %>" />
|
||||
<c:set var="label" value="${rdfs}label" />
|
||||
<c:set var="foaf" value="http://xmlns.com/foaf/0.1/" />
|
||||
<c:set var="personClassUri" value="${foaf}Person" />
|
||||
|
||||
<%-- Unlike other custom forms, this form does not allow edits of existing authors, so there are no
|
||||
SPARQL queries for existing values. --%>
|
||||
|
@ -125,6 +126,8 @@ SPARQL queries for existing values. --%>
|
|||
?newPerson core:authorInAuthorship ?authorshipUri .
|
||||
</v:jsonset>
|
||||
|
||||
<v:jsonset var="personClassUriJson">${personClassUri}</v:jsonset>
|
||||
|
||||
<c:set var="returnPathAfterSubmit" value="/edit/editRequestDispatch.jsp?subjectUri=${subjectUri}&predicateUri=${predicateUri}" />
|
||||
|
||||
<c:set var="editjson" scope="request">
|
||||
|
@ -169,7 +172,7 @@ SPARQL queries for existing values. --%>
|
|||
},
|
||||
"firstName" : {
|
||||
"newResource" : "false",
|
||||
"validators" : [ "nonempty", "datatype:${stringDatatypeUriJson}" ],
|
||||
"validators" : [ "datatype:${stringDatatypeUriJson}" ],
|
||||
"optionsType" : "UNDEFINED",
|
||||
"literalOptions" : [ ],
|
||||
"predicateUri" : "",
|
||||
|
@ -191,7 +194,7 @@ SPARQL queries for existing values. --%>
|
|||
},
|
||||
"lastName" : {
|
||||
"newResource" : "false",
|
||||
"validators" : [ "nonempty", "datatype:${stringDatatypeUriJson}" ],
|
||||
"validators" : [ "datatype:${stringDatatypeUriJson}" ],
|
||||
"optionsType" : "UNDEFINED",
|
||||
"literalOptions" : [ ],
|
||||
"predicateUri" : "",
|
||||
|
@ -210,6 +213,17 @@ SPARQL queries for existing values. --%>
|
|||
"rangeDatatypeUri" : "${intDatatypeUriJson}",
|
||||
"rangeLang" : "",
|
||||
"assertions" : ["${authorshipRankAssertion}"]
|
||||
},
|
||||
"personUri" : {
|
||||
"newResource" : "false",
|
||||
"validators" : [ ],
|
||||
"optionsType" : "UNDEFINED",
|
||||
"literalOptions" : [ ],
|
||||
"predicateUri" : "",
|
||||
"objectClassUri" : "${personClassUriJson}",
|
||||
"rangeDatatypeUri" : "",
|
||||
"rangeLang" : "",
|
||||
"assertions" : ["${n3ForExistingPerson}"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -224,11 +238,7 @@ SPARQL queries for existing values. --%>
|
|||
EditConfiguration.putConfigInSession(editConfig,session);
|
||||
}
|
||||
|
||||
// Doing this in Javascript instead.
|
||||
// For now the field names in CreateLabelFromFieldNames.processEditSubmission() are
|
||||
// hard-coded. If we want flexibility in naming them, we can pass in a map of
|
||||
// the field names when creating the preprocessor.
|
||||
// editConfig.addEditSubmissionPreprocessor(new CreateLabelFromNameFields(editConfig));
|
||||
//editConfig.addValidator(new PublicationHasAuthorValidator());
|
||||
|
||||
Model model = (Model) application.getAttribute("jenaOntModel");
|
||||
String objectUri = (String) request.getAttribute("objectUri");
|
||||
|
@ -295,22 +305,33 @@ SPARQL queries for existing values. --%>
|
|||
|
||||
</ul>
|
||||
|
||||
<%
|
||||
if (authorships.size() == 0) {
|
||||
%><p>This publication currently has no authors specified.</p><%
|
||||
}
|
||||
%>
|
||||
|
||||
<div id="showAddForm">
|
||||
<v:input type="submit" value="Add Author" id="showAddFormButton" cancel="true" cancelLabel="Return to Publication" cancelUrl="/individual" />
|
||||
</div>
|
||||
|
||||
|
||||
<form id="addAuthorForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
|
||||
|
||||
<h3>Add an Author</h3>
|
||||
|
||||
<p class="inline"><v:input type="text" id="lastName" label="Last name ${requiredHint}" size="30" /></p>
|
||||
<p class="inline"><v:input type="text" id="firstName" label="First name ${requiredHint}" size="20" />${initialHint}</p>
|
||||
<p class="inline"><v:input type="text" id="middleName" label="Middle name" size="20" />${initialHint}</p>
|
||||
<input type="hidden" id="label" name="label" value="" /> <!-- Field value populated by JavaScript -->
|
||||
|
||||
<div id="selectedAuthor">
|
||||
<%-- RY maybe make this a label and input field. See what looks best. --%>
|
||||
<p class="inline"><label>Selected author: </label><span id="selectedAuthorName"></span></p>
|
||||
<input type="hidden" id="personUri" name="personUri" value="" /> <!-- Field value populated by JavaScript -->
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="rank" value="${rank}" />
|
||||
<input type="hidden" name="acUrl" id="acUrl" value="<c:url value="/autocomplete?type=${foaf}Person" />" />
|
||||
<!-- Field values populated by JavaScript -->
|
||||
<input type="hidden" id="label" name="label" value="" />
|
||||
<input type="hidden" id="personUri" name="personUri" value="" />
|
||||
|
||||
<p class="submit"><v:input type="submit" id="submit" value="Add Author" cancel="true" /></p>
|
||||
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
|
||||
/* Hide elements not used in non-JS version of form */
|
||||
#showAddForm,
|
||||
a.remove {
|
||||
a.remove,
|
||||
#selectedAuthor {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
@ -28,6 +29,10 @@ a.remove {
|
|||
margin-left: 2em;
|
||||
}
|
||||
|
||||
form h3 {
|
||||
margin-bottom: .5em;
|
||||
}
|
||||
|
||||
form a:link.cancel, form a:visited.cancel,
|
||||
#authors a:link.remove, #authors a:visited.remove,
|
||||
#showAddForm a:link.cancel, #showAddForm a:visited.cancel {
|
||||
|
@ -67,3 +72,7 @@ form a:hover.cancel,
|
|||
#content form p.inline span.hint {
|
||||
margin-left: .5em;
|
||||
}
|
||||
|
||||
#selectedAuthor {
|
||||
clear: left;
|
||||
}
|
||||
|
|
|
@ -103,3 +103,14 @@ option {
|
|||
#content form textarea {
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
|
||||
/* jQuery UI autocomplete */
|
||||
ul.ui-autocomplete {
|
||||
font-size: .95em;
|
||||
}
|
||||
|
||||
li.ui-menu-item a.ui-corner-all {
|
||||
text-align: left;
|
||||
padding-left: .25em;
|
||||
}
|
|
@ -6,8 +6,7 @@ var addAuthorForm = {
|
|||
|
||||
this.mixIn();
|
||||
this.initObjects();
|
||||
this.adjustForJs();
|
||||
this.initForm();
|
||||
this.initPage();
|
||||
},
|
||||
|
||||
mixIn: function() {
|
||||
|
@ -15,12 +14,12 @@ var addAuthorForm = {
|
|||
vitro.utils.borrowMethods(vitro.customFormUtils, this);
|
||||
},
|
||||
|
||||
// On page load, create references within the customForm scope to DOM elements.
|
||||
// On page load, create references within the addAuthorForm scope to DOM elements.
|
||||
// NB These must be assigned after the elements have been loaded onto the page.
|
||||
initObjects: function() {
|
||||
|
||||
this.form = $('#addAuthorForm');
|
||||
this.showFormDiv = $('#showAddForm');
|
||||
this.showFormButtonWrapper = $('#showAddForm');
|
||||
this.showFormButton = $('#showAddFormButton');
|
||||
this.removeLinks = $('a.remove');
|
||||
this.submit = this.form.find(':submit');
|
||||
|
@ -32,42 +31,103 @@ var addAuthorForm = {
|
|||
this.personUriField = $('#personUri');
|
||||
this.firstNameWrapper = this.firstNameField.parent();
|
||||
this.middleNameWrapper = this.middleNameField.parent();
|
||||
this.lastNameWrapper = this.lastNameField.parent();
|
||||
this.selectedAuthor = $('#selectedAuthor');
|
||||
this.selectedAuthorName = $('#selectedAuthorName');
|
||||
|
||||
},
|
||||
|
||||
// On page load, make changes to the non-Javascript version for the Javascript version.
|
||||
// These are features that will NOT CHANGE throughout the workflow of the Javascript version.
|
||||
adjustForJs: function() {
|
||||
// Initial page setup. Called only at page load.
|
||||
initPage: function() {
|
||||
|
||||
// Show elements that are hidden by css on load since not used in non-JS version
|
||||
this.showFormDiv.show();
|
||||
// Show elements hidden by CSS for the non-JavaScript-enabled version.
|
||||
// NB The non-JavaScript version of this form is currently not functional.
|
||||
this.removeLinks.show();
|
||||
|
||||
this.form.hide();
|
||||
this.bindEventListeners();
|
||||
|
||||
this.setUpAutocomplete();
|
||||
|
||||
this.initAuthorListOnlyView();
|
||||
},
|
||||
|
||||
initForm: function() {
|
||||
|
||||
this.firstNameWrapper.hide();
|
||||
this.middleNameWrapper.hide();
|
||||
bindEventListeners: function() {
|
||||
|
||||
this.showFormButton.click(function() {
|
||||
addAuthorForm.showFormDiv.hide();
|
||||
addAuthorForm.form.show();
|
||||
addAuthorForm.initFormView();
|
||||
return false;
|
||||
});
|
||||
|
||||
this.submit.click(function() {
|
||||
addAuthorForm.insertLabel(); // might be insertLabelOrPersonUri
|
||||
addAuthorForm.prepareFieldValuesForSubmit();
|
||||
});
|
||||
},
|
||||
|
||||
this.cancel.click(function() {
|
||||
addAuthorForm.hideFields(addAuthorForm.form);
|
||||
addAuthorForm.showFormDiv.show();
|
||||
// This view shows the list of existing authors and hides the form.
|
||||
// There is a button to show the form.
|
||||
initAuthorListOnlyView: function() {
|
||||
this.hideForm();
|
||||
this.showFormButtonWrapper.show();
|
||||
},
|
||||
|
||||
// Initial view of add author form
|
||||
initFormView: function() {
|
||||
|
||||
// Hide the button that shows the form
|
||||
this.showFormButtonWrapper.hide();
|
||||
|
||||
// Hide form fields that shouldn't display on first view.
|
||||
// Includes clearing their contents.
|
||||
this.hideFields(this.firstNameWrapper);
|
||||
this.hideFields(this.middleNameWrapper);
|
||||
this.hideSelectedAuthor();
|
||||
|
||||
this.cancel.unbind('click');
|
||||
this.cancel.bind('click', function() {
|
||||
addAuthorForm.initAuthorListOnlyView();
|
||||
return false;
|
||||
});
|
||||
|
||||
this.setUpAutocomplete();
|
||||
// Reset the last name field. It had been hidden if we selected an author from
|
||||
// the autocomplete field.
|
||||
this.lastNameWrapper.show();
|
||||
// This shouldn't be needed, because calling this.hideFormFields(this.lastNameWrapper)
|
||||
// from showSelectedAuthor should do it. However, it doesn't work from there,
|
||||
// or in the cancel action, or if referring to this.lastNameField. None of those work,
|
||||
// however.
|
||||
$('#lastName').val('');
|
||||
|
||||
// Show the form
|
||||
this.form.show();
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
// Action taken after selecting an author from the autocomplete list
|
||||
showSelectedAuthor: function(ui) {
|
||||
|
||||
this.personUriField.val(ui.item.uri);
|
||||
this.selectedAuthor.show();
|
||||
|
||||
// Transfer the name from the autocomplete field to the selected author
|
||||
// name display, and hide the last name field.
|
||||
this.selectedAuthorName.html(this.lastNameField.val());
|
||||
// NB For some reason this doesn't delete the value from the last name
|
||||
// field when the form is redisplayed. Need to do in initFormView.
|
||||
this.hideFields(this.lastNameWrapper);
|
||||
|
||||
// Cancel restores form to initial state
|
||||
this.cancel.unbind('click');
|
||||
this.cancel.bind('click', function() {
|
||||
addAuthorForm.initFormView();
|
||||
return false;
|
||||
});
|
||||
},
|
||||
|
||||
hideSelectedAuthor: function() {
|
||||
this.selectedAuthor.hide();
|
||||
this.selectedAuthorName.html('');
|
||||
this.personUriField.val('');
|
||||
},
|
||||
|
||||
setUpAutocomplete: function() {
|
||||
|
@ -84,45 +144,53 @@ var addAuthorForm = {
|
|||
|
||||
$.ajax({
|
||||
url: url,
|
||||
dataType: "json",
|
||||
dataType: 'json',
|
||||
data: request,
|
||||
success: function(data) {
|
||||
cache[request.term] = data;
|
||||
response(data);
|
||||
}
|
||||
// on select: fill in person uri
|
||||
|
||||
});
|
||||
},
|
||||
select: function(event, ui) {
|
||||
addAuthorForm.showSelectedAuthor(ui);
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
insertLabel: function() {
|
||||
prepareFieldValuesForSubmit: function() {
|
||||
var firstName,
|
||||
middleName,
|
||||
lastName,
|
||||
name;
|
||||
|
||||
if (!this.firstNameField.is(':hidden')) {
|
||||
// If selecting an existing person, don't submit name fields
|
||||
if (this.personUriField.val() != '') {
|
||||
this.firstNameField.attr('disabled', 'disabled');
|
||||
this.middleNameField.attr('disabled', 'disabled');
|
||||
this.lastNameField.attr('disabled', 'disabled');
|
||||
}
|
||||
else {
|
||||
firstName = this.firstNameField.val();
|
||||
middleName = this.middleNameField.val();
|
||||
lastName = this.lastNameField.val();
|
||||
|
||||
name = lastName;
|
||||
if (firstName) {
|
||||
name += ", " + firstName;
|
||||
name += ', ' + firstName;
|
||||
}
|
||||
if (middleName) {
|
||||
name += " " + middleName;
|
||||
name += ' ' + middleName;
|
||||
}
|
||||
|
||||
this.labelField.val(name);
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
// RY To be implemented later.
|
||||
toggleRemoveLink: function() {
|
||||
// when clicking remove: remove the author, and change link text to "undo"
|
||||
// when clicking undo: add the author back, and change link text to "remove"
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
<#-- We don't do title here because some pages don't get a title, or it may not be the same as the <title> text.
|
||||
<h2>${title}</h2> -->
|
||||
${body}
|
||||
<#-- <@dumpDataModel /> -->
|
||||
</div> <!-- content -->
|
||||
</div> <!-- contentwrap -->
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue