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 rank = 0;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
request.setAttribute("authorshipCount", authorships.size());
|
||||||
for ( Individual authorship : authorships ) {
|
for ( Individual authorship : authorships ) {
|
||||||
String rankDatatypeUri = "";
|
String rankDatatypeUri = "";
|
||||||
DataPropertyStatement rankStmt = authorship.getDataPropertyStatement(rankPredicateUri);
|
DataPropertyStatement rankStmt = authorship.getDataPropertyStatement(rankPredicateUri);
|
||||||
|
@ -330,12 +331,11 @@ SPARQL queries for existing values. --%>
|
||||||
</c:url>
|
</c:url>
|
||||||
<c:url var="deleteAuthorshipHref" value="/edit/primitiveDelete" />
|
<c:url var="deleteAuthorshipHref" value="/edit/primitiveDelete" />
|
||||||
|
|
||||||
<%-- <c:url var="undoHref" value="/edit/addAuthorToInformationResource" /> --%>
|
|
||||||
<li class="authorship" id="${authorshipUri}">
|
<li class="authorship" id="${authorshipUri}">
|
||||||
<span class="rank" id="${rankValue}"></span>
|
<span class="rank" id="${rankValue}"></span>
|
||||||
<span class="position" id="${position}"></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
|
<%-- 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>
|
<span class="author"><a href="${authorHref}" id="${authorUri}" class="authorLink">${authorName}</a>
|
||||||
<a href="${deleteAuthorshipHref}" class="remove">Remove</a>
|
<a href="${deleteAuthorshipHref}" class="remove">Remove</a>
|
||||||
<%-- <a href="${undoHref}" class="undo">Undo</a> --%></span>
|
<%-- <a href="${undoHref}" class="undo">Undo</a> --%></span>
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
#authorships li {
|
#authorships li {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
margin-bottom: .75em;
|
margin-bottom: .75em;
|
||||||
|
}
|
||||||
|
|
||||||
|
#authorships.ui-sortable li {
|
||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
background: url("../images/sortable_icon.png") no-repeat left center;
|
background: url("../images/sortable_icon.png") no-repeat left center;
|
||||||
}
|
}
|
||||||
|
@ -95,8 +98,6 @@ form a:hover.cancel,
|
||||||
margin-top: 3em;
|
margin-top: 3em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Disabling undo links for the present. Add back later. */
|
/* Disabling undo links for the present. Add back later. */
|
||||||
/*
|
/*
|
||||||
a.undo,
|
a.undo,
|
||||||
|
|
|
@ -97,7 +97,6 @@ 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)) {
|
||||||
|
@ -122,8 +121,13 @@ var addAuthorForm = {
|
||||||
var pos = parseInt($(this).children('.position').attr('id'));
|
var pos = parseInt($(this).children('.position').attr('id'));
|
||||||
$(this).children('.position').attr('id', pos-1);
|
$(this).children('.position').attr('id', pos-1);
|
||||||
});
|
});
|
||||||
|
|
||||||
authorship.fadeOut(400, function() {
|
authorship.fadeOut(400, function() {
|
||||||
$(this).remove();
|
$(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).hide();
|
||||||
|
@ -132,7 +136,7 @@ var addAuthorForm = {
|
||||||
// author.css('width', 'auto');
|
// author.css('width', 'auto');
|
||||||
// author.effect("highlight", {}, 3000);
|
// author.effect("highlight", {}, 3000);
|
||||||
} else {
|
} 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() {
|
onLastNameChange: function() {
|
||||||
this.showFieldsForNewPerson();
|
this.showFieldsForNewPerson();
|
||||||
this.firstNameField.focus();
|
this.firstNameField.focus();
|
||||||
|
@ -279,7 +291,21 @@ var addAuthorForm = {
|
||||||
},
|
},
|
||||||
|
|
||||||
initAuthorReordering: function() {
|
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) {
|
stop: function(event, ui) {
|
||||||
var predicateUri = '<' + $('.rankPred').attr('id') + '>',
|
var predicateUri = '<' + $('.rankPred').attr('id') + '>',
|
||||||
rankXsdType = $('.rankXsdType').attr('id'),
|
rankXsdType = $('.rankXsdType').attr('id'),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue