NIHVIVO-646 Broke removeAuthorship out into a separate function
This commit is contained in:
parent
96d9b0508e
commit
3772389dd7
1 changed files with 44 additions and 39 deletions
|
@ -96,27 +96,42 @@ var addAuthorForm = {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.removeAuthorshipLinks.click(function() {
|
this.removeAuthorshipLinks.click(function() {
|
||||||
// RY Upgrade this to a modal window
|
addAuthorForm.removeAuthorship(this);
|
||||||
var message = "Are you sure you want to remove this author?";
|
|
||||||
if (!confirm(message)) {
|
return false;
|
||||||
return false;
|
});
|
||||||
}
|
|
||||||
$.ajax({
|
// this.undoLinks.click(function() {
|
||||||
url: $(this).attr('href'),
|
// $.ajax({
|
||||||
type: 'POST',
|
// url: $(this).attr('href')
|
||||||
data: {
|
// });
|
||||||
deletion: $(this).parents('.authorship').attr('id')
|
// return false;
|
||||||
},
|
// });
|
||||||
dataType: 'json',
|
|
||||||
context: $(this), // context for callback
|
},
|
||||||
complete: function(request, status) {
|
|
||||||
var authorship = $(this).parents('.authorship'),
|
removeAuthorship: function(link) {
|
||||||
nextAuthorships = authorship.nextAll(),
|
// RY Upgrade this to a modal window
|
||||||
rank;
|
var message = "Are you sure you want to remove this author?";
|
||||||
// author = $(this).siblings('span.author'),
|
if (!confirm(message)) {
|
||||||
// authorLink = author.children('a.authorLink'),
|
return false;
|
||||||
// authorName = authorLink.html();
|
}
|
||||||
|
$.ajax({
|
||||||
|
url: $(link).attr('href'),
|
||||||
|
type: 'POST',
|
||||||
|
data: {
|
||||||
|
deletion: $(link).parents('.authorship').attr('id')
|
||||||
|
},
|
||||||
|
dataType: 'json',
|
||||||
|
context: link, // context for callback
|
||||||
|
complete: function(request, status) {
|
||||||
|
var authorship = $(this).parents('.authorship'),
|
||||||
|
nextAuthorships = authorship.nextAll(),
|
||||||
|
rank;
|
||||||
|
// author = $(this).siblings('span.author'),
|
||||||
|
// authorLink = author.children('a.authorLink'),
|
||||||
|
// authorName = authorLink.html();
|
||||||
|
|
||||||
if (status === 'success') {
|
if (status === 'success') {
|
||||||
|
|
||||||
if (nextAuthorships.length) {
|
if (nextAuthorships.length) {
|
||||||
|
@ -132,7 +147,7 @@ var addAuthorForm = {
|
||||||
rank = addAuthorForm.getRank(authorship);
|
rank = addAuthorForm.getRank(authorship);
|
||||||
$('input#rank').val(rank);
|
$('input#rank').val(rank);
|
||||||
}
|
}
|
||||||
|
|
||||||
// In future, do this selectively by only clearing terms that match the
|
// In future, do this selectively by only clearing terms that match the
|
||||||
// deleted author's name
|
// deleted author's name
|
||||||
addAuthorForm.acCache = {};
|
addAuthorForm.acCache = {};
|
||||||
|
@ -149,26 +164,16 @@ var addAuthorForm = {
|
||||||
addAuthorForm.setAcUrl();
|
addAuthorForm.setAcUrl();
|
||||||
});
|
});
|
||||||
|
|
||||||
// $(this).hide();
|
// $(this).hide();
|
||||||
// $(this).siblings('.undo').show();
|
// $(this).siblings('.undo').show();
|
||||||
// author.html(authorName + ' has been removed');
|
// author.html(authorName + ' has been removed');
|
||||||
// author.css('width', 'auto');
|
// author.css('width', 'auto');
|
||||||
// author.effect("highlight", {}, 3000);
|
// author.effect("highlight", {}, 3000);
|
||||||
} else {
|
} else {
|
||||||
alert('Error processing request: author not removed');
|
alert('Error processing request: author not removed');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
// this.undoLinks.click(function() {
|
|
||||||
// $.ajax({
|
|
||||||
// url: $(this).attr('href')
|
|
||||||
// });
|
|
||||||
// return false;
|
|
||||||
// });
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Disable DD and associated cues if only one author remains
|
// Disable DD and associated cues if only one author remains
|
||||||
|
@ -452,11 +457,11 @@ var addAuthorForm = {
|
||||||
minLength: 2,
|
minLength: 2,
|
||||||
source: function(request, response) {
|
source: function(request, response) {
|
||||||
if (request.term in addAuthorForm.acCache) {
|
if (request.term in addAuthorForm.acCache) {
|
||||||
console.log("found term in cache");
|
// console.log("found term in cache");
|
||||||
response(addAuthorForm.acCache[request.term]);
|
response(addAuthorForm.acCache[request.term]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log("not getting term from cache");
|
// console.log("not getting term from cache");
|
||||||
|
|
||||||
// If the url query params are too long, we could do a post
|
// If the url query params are too long, we could do a post
|
||||||
// here instead of a get. Add the exclude uris to the data
|
// here instead of a get. Add the exclude uris to the data
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue