NIHVIVO-646 Modifications to element structure of existing author listings, and associated changes to js and css
This commit is contained in:
parent
cbe6a58aa6
commit
8568c806b4
4 changed files with 99 additions and 28 deletions
|
@ -63,7 +63,10 @@ core:authorInAuthorship (Person : Authorship) - inverse of linkedAuthor
|
||||||
vreq.setAttribute("flagUri",flagUri);
|
vreq.setAttribute("flagUri",flagUri);
|
||||||
|
|
||||||
vreq.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString()));
|
vreq.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString()));
|
||||||
vreq.setAttribute("intDatatypeUriJson", MiscWebUtils.escape(XSD.xint.toString()));
|
|
||||||
|
String intDatatypeUri = XSD.xint.toString();
|
||||||
|
vreq.setAttribute("intDatatypeUri", intDatatypeUri);
|
||||||
|
vreq.setAttribute("intDatatypeUriJson", MiscWebUtils.escape(intDatatypeUri));
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<c:set var="vivoCore" value="http://vivoweb.org/ontology/core#" />
|
<c:set var="vivoCore" value="http://vivoweb.org/ontology/core#" />
|
||||||
|
@ -294,11 +297,16 @@ SPARQL queries for existing values. --%>
|
||||||
<ul id="authors">
|
<ul id="authors">
|
||||||
<%
|
<%
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int rank = 0;
|
int rank = 0;
|
||||||
for ( Individual authorship : authorships ) {
|
for ( Individual authorship : authorships ) {
|
||||||
rank = Integer.valueOf(authorship.getDataValue(rankUri));
|
int rank1 = Integer.valueOf(authorship.getDataValue(rankUri));
|
||||||
|
String rankValue = authorship.getDataValue(rankUri); // full value, including xsd type if present
|
||||||
|
if (rankValue == null) {
|
||||||
|
rankValue = "";
|
||||||
|
rank = 0;
|
||||||
|
} else {
|
||||||
|
rank = Integer.valueOf(rankValue); // just the integer value
|
||||||
|
}
|
||||||
Individual author = authorship.getRelatedIndividual(linkedAuthorProperty);
|
Individual author = authorship.getRelatedIndividual(linkedAuthorProperty);
|
||||||
if ( author != null ) {
|
if ( author != null ) {
|
||||||
request.setAttribute("author", author);
|
request.setAttribute("author", author);
|
||||||
|
@ -306,27 +314,31 @@ SPARQL queries for existing values. --%>
|
||||||
//request.setAttribute("authorUri", URLEncoder.encode(author.getURI(), "UTF-8"));
|
//request.setAttribute("authorUri", URLEncoder.encode(author.getURI(), "UTF-8"));
|
||||||
request.setAttribute("authorUri", author.getURI());
|
request.setAttribute("authorUri", author.getURI());
|
||||||
request.setAttribute("authorshipUri", authorship.getURI());
|
request.setAttribute("authorshipUri", authorship.getURI());
|
||||||
|
request.setAttribute("rank", rank);
|
||||||
|
|
||||||
%>
|
%>
|
||||||
<c:url var="authorHref" value="/individual">
|
<c:url var="authorHref" value="/individual">
|
||||||
<c:param name="uri" value="${authorUri}"/>
|
<c:param name="uri" value="${authorUri}"/>
|
||||||
</c:url>
|
</c:url>
|
||||||
<c:url var="deleteAuthorshipHref" value="/edit/primitiveRdfDelete" />
|
<c:url var="deleteAuthorshipHref" value="/edit/primitiveRdfDelete" />
|
||||||
<c:url var="undoHref" value="/edit/addAuthorToInformationResource" />
|
|
||||||
<li class="author" id="${authorUri}">
|
<%-- <c:url var="undoHref" value="/edit/addAuthorToInformationResource" /> --%>
|
||||||
<span class="authorName"><a href="${authorHref}" class="existingAuthor">${author.name}</a></span>
|
<li class="authorship" id="${authorshipUri}">
|
||||||
<a href="${deleteAuthorshipHref}" id="${authorshipUri}" class="remove">Remove</a>
|
<span class="rank" id="${rankValue}" />
|
||||||
<%-- <a href="${undoHref}" class="undo">Undo</a> --%>
|
<%-- This span will be used in the next phase, when we display a message that the author has been
|
||||||
|
removed. That text will replace the a.authorLink. --%>
|
||||||
|
<span class="author"><a href="${authorHref}" id="${authorUri}" class="authorLink">${author.name}</a>
|
||||||
|
<a href="${deleteAuthorshipHref}" class="remove">Remove</a>
|
||||||
|
<%-- <a href="${undoHref}" class="undo">Undo</a> --%></span>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<%
|
<%
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// A new author will be ranked last when added.
|
// A new author will be ranked last when added.
|
||||||
// This wouldn't handle gaps in the ranking: vreq.setAttribute("rank", authorships.size()+1);
|
// This wouldn't handle gaps in the ranking: vreq.setAttribute("rank", authorships.size()+1);
|
||||||
vreq.setAttribute("rank", rank + 1);
|
vreq.setAttribute("newRank", rank + 1);
|
||||||
|
vreq.setAttribute("rankPred", rankUri);
|
||||||
%>
|
%>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -356,8 +368,11 @@ SPARQL queries for existing values. --%>
|
||||||
<input type="hidden" id="personUri" name="personUri" value="" /> <!-- Field value populated by JavaScript -->
|
<input type="hidden" id="personUri" name="personUri" value="" /> <!-- Field value populated by JavaScript -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input type="hidden" name="rank" value="${rank}" />
|
<input type="hidden" name="rankPred" value="<${rankPred}>" />
|
||||||
|
<input type="hidden" name="rankXsdType" value="${intDatatypeUri}" />
|
||||||
|
<input type="hidden" name="rank" value="${newRank}" />
|
||||||
<input type="hidden" name="acUrl" id="acUrl" value="<c:url value="/autocomplete?type=${foaf}Person&stem=false" />" />
|
<input type="hidden" name="acUrl" id="acUrl" value="<c:url value="/autocomplete?type=${foaf}Person&stem=false" />" />
|
||||||
|
<input type="hidden" name="reorderUrl" id="reorderUrl" value="<c:url value="/edit/primitiveRdfEdit" />" />
|
||||||
|
|
||||||
<p class="submit"><v:input type="submit" id="submit" value="Add Author" cancel="true" /></p>
|
<p class="submit"><v:input type="submit" id="submit" value="Add Author" cancel="true" /></p>
|
||||||
|
|
||||||
|
|
|
@ -7,18 +7,15 @@
|
||||||
#authors li {
|
#authors li {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
margin-bottom: .75em;
|
margin-bottom: .75em;
|
||||||
|
padding-left: 1em;
|
||||||
|
background: url("../images/sortable_icon.png") no-repeat left center;
|
||||||
}
|
}
|
||||||
|
|
||||||
#authors a.existingAuthor {
|
#authors a.authorLink {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 15em;
|
width: 15em;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* These are only here for JavaScript to pick up. Don't display!! */
|
|
||||||
#authors span.existingAuthorUri {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
#showAddForm span.or {
|
#showAddForm span.or {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
@ -85,10 +82,15 @@ form a:hover.cancel,
|
||||||
margin-top: 3em;
|
margin-top: 3em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Disabling undo links for the present. Add back later. */
|
||||||
|
/*
|
||||||
a.undo,
|
a.undo,
|
||||||
#selectedAuthor {
|
#selectedAuthor {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/* Hide elements not used in non-JS version of form */
|
/* Hide elements not used in non-JS version of form */
|
||||||
/* rjy7 Currently not supporting non-JS version of this form. */
|
/* rjy7 Currently not supporting non-JS version of this form. */
|
||||||
|
|
BIN
productMods/edit/forms/images/sortable_icon.png
Normal file
BIN
productMods/edit/forms/images/sortable_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 234 B |
|
@ -50,7 +50,9 @@ var addAuthorForm = {
|
||||||
|
|
||||||
this.bindEventListeners();
|
this.bindEventListeners();
|
||||||
|
|
||||||
this.setUpAutocomplete();
|
this.initAutocomplete();
|
||||||
|
|
||||||
|
this.initAuthorReordering();
|
||||||
|
|
||||||
if (this.findValidationErrors()) {
|
if (this.findValidationErrors()) {
|
||||||
this.initFormAfterInvalidSubmission();
|
this.initFormAfterInvalidSubmission();
|
||||||
|
@ -97,6 +99,7 @@ var addAuthorForm = {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.removeAuthorshipLinks.click(function() {
|
this.removeAuthorshipLinks.click(function() {
|
||||||
|
console.log($(this).parents('.authorship'));
|
||||||
// RY Upgrade this to a modal window
|
// RY Upgrade this to a modal window
|
||||||
var message = "Are you sure you want to remove this author?";
|
var message = "Are you sure you want to remove this author?";
|
||||||
if (!confirm(message)) {
|
if (!confirm(message)) {
|
||||||
|
@ -106,17 +109,17 @@ var addAuthorForm = {
|
||||||
url: $(this).attr('href'),
|
url: $(this).attr('href'),
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: {
|
data: {
|
||||||
deletion: $(this).attr('id')
|
deletion: $(this).parents('.authorship').attr('id')
|
||||||
},
|
},
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
context: $(this), // context for callback
|
context: $(this), // context for callback
|
||||||
complete: function(request, status) {
|
complete: function(request, status) {
|
||||||
var authorListing = $(this).parent();
|
var authorship = $(this).parents('.authorship');
|
||||||
// var author = $(this).siblings('span.authorName');
|
// var author = $(this).siblings('span.author');
|
||||||
// var authorLink = author.children('a.existingAuthor');
|
// var authorLink = author.children('a.authorLink');
|
||||||
// var authorName = authorLink.html();
|
// var authorName = authorLink.html();
|
||||||
if (status === 'success') {
|
if (status === 'success') {
|
||||||
authorListing.fadeOut(400, function() {
|
authorship.fadeOut(400, function() {
|
||||||
$(this).remove();
|
$(this).remove();
|
||||||
});
|
});
|
||||||
// $(this).hide();
|
// $(this).hide();
|
||||||
|
@ -272,7 +275,58 @@ var addAuthorForm = {
|
||||||
this.personUriField.val('');
|
this.personUriField.val('');
|
||||||
},
|
},
|
||||||
|
|
||||||
setUpAutocomplete: function() {
|
initAuthorReordering: function() {
|
||||||
|
$('#authors').sortable({
|
||||||
|
update: function() {
|
||||||
|
addAuthorForm.resetRankings();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
resetRankings: function() {
|
||||||
|
var rankPred = '<' + $('#rankPred').val() + '>',
|
||||||
|
additions = '',
|
||||||
|
retractions = '',
|
||||||
|
rankTypeSuffix = '^^<' + $('#rankType').val() + '>',
|
||||||
|
uri,
|
||||||
|
newRank,
|
||||||
|
oldRank;
|
||||||
|
$('li.authorship').each(function(index) {
|
||||||
|
// This value does double duty, for removal and reordering
|
||||||
|
uri = $(this).children('.remove').attr('id');
|
||||||
|
oldRank = $(this).children('.rank').attr('id'); // already contains the rankSuffix, if present
|
||||||
|
newRank = index + 1;
|
||||||
|
additions += uri + ' ' + rankPred + ' ' + '"' + newRank + '"' + rankTypeSuffix + ' .';
|
||||||
|
retractions += uri + ' ' + rankPred + ' ' + '"' + oldRank + ' .';
|
||||||
|
});
|
||||||
|
console.log(additions);
|
||||||
|
console.log(retractions);
|
||||||
|
$.ajax({
|
||||||
|
url: $('#reorderUrl').val(),
|
||||||
|
data: {
|
||||||
|
additions: additions,
|
||||||
|
retractions: retractions
|
||||||
|
},
|
||||||
|
dataType: 'json',
|
||||||
|
type: 'POST',
|
||||||
|
success: function(xhr, status, error) {
|
||||||
|
// reset rank in the span
|
||||||
|
// can just do from values we computed, if easier than getting data back from server
|
||||||
|
//
|
||||||
|
},
|
||||||
|
error: function(data, status, request) {
|
||||||
|
addAuthorForm.restorePreviousRankings();
|
||||||
|
alert('Reordering of author ranks failed.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
restorePreviousRankings: function() {
|
||||||
|
// restore existing rankings after reordering failure
|
||||||
|
// use span.rank id attr value to determine
|
||||||
|
},
|
||||||
|
|
||||||
|
initAutocomplete: function() {
|
||||||
|
|
||||||
var cache = {};
|
var cache = {};
|
||||||
var url = $('#acUrl').val();
|
var url = $('#acUrl').val();
|
||||||
|
|
Loading…
Add table
Reference in a new issue