NIHVIVO-646 Disable author drag-drop if only 1 author (on page load or after removing an author)
This commit is contained in:
parent
addabdc245
commit
745e98e0fb
3 changed files with 37 additions and 10 deletions
|
@ -300,6 +300,7 @@ SPARQL queries for existing values. --%>
|
|||
|
||||
int rank = 0;
|
||||
int index = 0;
|
||||
request.setAttribute("authorshipCount", authorships.size());
|
||||
for ( Individual authorship : authorships ) {
|
||||
String rankDatatypeUri = "";
|
||||
DataPropertyStatement rankStmt = authorship.getDataPropertyStatement(rankPredicateUri);
|
||||
|
@ -329,13 +330,12 @@ SPARQL queries for existing values. --%>
|
|||
<c:param name="uri" value="${authorUri}"/>
|
||||
</c:url>
|
||||
<c:url var="deleteAuthorshipHref" value="/edit/primitiveDelete" />
|
||||
|
||||
<%-- <c:url var="undoHref" value="/edit/addAuthorToInformationResource" /> --%>
|
||||
|
||||
<li class="authorship" id="${authorshipUri}">
|
||||
<span class="rank" id="${rankValue}"></span>
|
||||
<span class="position" id="${position}"></span>
|
||||
<%-- 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. --%>
|
||||
removed. That text will replace the a.authorLink, which will be removed. --%>
|
||||
<span class="author"><a href="${authorHref}" id="${authorUri}" class="authorLink">${authorName}</a>
|
||||
<a href="${deleteAuthorshipHref}" class="remove">Remove</a>
|
||||
<%-- <a href="${undoHref}" class="undo">Undo</a> --%></span>
|
||||
|
|
|
@ -7,8 +7,11 @@
|
|||
#authorships li {
|
||||
list-style: none;
|
||||
margin-bottom: .75em;
|
||||
}
|
||||
|
||||
#authorships.ui-sortable li {
|
||||
padding-left: 1em;
|
||||
background: url("../images/sortable_icon.png") no-repeat left center;
|
||||
background: url("../images/sortable_icon.png") no-repeat left center;
|
||||
}
|
||||
|
||||
#authorships a.authorLink {
|
||||
|
@ -95,8 +98,6 @@ form a:hover.cancel,
|
|||
margin-top: 3em;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Disabling undo links for the present. Add back later. */
|
||||
/*
|
||||
a.undo,
|
||||
|
|
|
@ -97,7 +97,6 @@ var addAuthorForm = {
|
|||
});
|
||||
|
||||
this.removeAuthorshipLinks.click(function() {
|
||||
console.log($(this).parents('.authorship'));
|
||||
// RY Upgrade this to a modal window
|
||||
var message = "Are you sure you want to remove this author?";
|
||||
if (!confirm(message)) {
|
||||
|
@ -122,17 +121,22 @@ var addAuthorForm = {
|
|||
var pos = parseInt($(this).children('.position').attr('id'));
|
||||
$(this).children('.position').attr('id', pos-1);
|
||||
});
|
||||
|
||||
authorship.fadeOut(400, function() {
|
||||
$(this).remove();
|
||||
// If there's just one author remaining, remove the drag and drop title message.
|
||||
if ($('.authorship').length == 1) {
|
||||
addAuthorForm.disableAuthorDD();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// $(this).hide();
|
||||
// $(this).siblings('.undo').show();
|
||||
// author.html(authorName + ' has been removed');
|
||||
// author.css('width', 'auto');
|
||||
// author.effect("highlight", {}, 3000);
|
||||
} else {
|
||||
alert('Error processing request');
|
||||
alert('Error processing request: author not removed');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -148,6 +152,14 @@ var addAuthorForm = {
|
|||
|
||||
},
|
||||
|
||||
// Disable DD and cues if only one author remaining
|
||||
disableAuthorDD: function() {
|
||||
var author = $('.authorship');
|
||||
$('#authorships').sortable({ disable: true} );
|
||||
author.css('background', 'none');
|
||||
author.css('padding-left', '0');
|
||||
},
|
||||
|
||||
onLastNameChange: function() {
|
||||
this.showFieldsForNewPerson();
|
||||
this.firstNameField.focus();
|
||||
|
@ -279,7 +291,21 @@ var addAuthorForm = {
|
|||
},
|
||||
|
||||
initAuthorReordering: function() {
|
||||
$('#authorships').sortable({
|
||||
|
||||
var authorshipList = $('#authorships'),
|
||||
authorships = authorshipList.children();
|
||||
|
||||
if (authorships.length < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
authorships.each(function() {
|
||||
// Make sure all browsers support title attribute on elements other than link and image.
|
||||
// If not, move title to the author link.
|
||||
$(this).attr('title', 'Drag and drop to reorder authors');
|
||||
});
|
||||
|
||||
authorshipList.sortable({
|
||||
stop: function(event, ui) {
|
||||
var predicateUri = '<' + $('.rankPred').attr('id') + '>',
|
||||
rankXsdType = $('.rankXsdType').attr('id'),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue