Notification improvements for notes
Missing query() call for unlinking notes in Item.erase()
This commit is contained in:
parent
672ca5956e
commit
5ab37dacd5
|
@ -839,6 +839,8 @@ Scholar.Item.prototype.setNoteSource = function(sourceItemID){
|
||||||
this.updateDateModified();
|
this.updateDateModified();
|
||||||
Scholar.DB.commitTransaction();
|
Scholar.DB.commitTransaction();
|
||||||
|
|
||||||
|
Scholar.Notifier.trigger('modify', 'item', this.getID());
|
||||||
|
|
||||||
// Update the note counts of the previous and new sources
|
// Update the note counts of the previous and new sources
|
||||||
if (oldItem){
|
if (oldItem){
|
||||||
oldItem.decrementNoteCount();
|
oldItem.decrementNoteCount();
|
||||||
|
@ -938,14 +940,20 @@ Scholar.Item.prototype.erase = function(){
|
||||||
var sourceItemID = Scholar.DB.valueQuery(sql);
|
var sourceItemID = Scholar.DB.valueQuery(sql);
|
||||||
if (sourceItemID){
|
if (sourceItemID){
|
||||||
var sourceItem = Scholar.Items.get(sourceItemID);
|
var sourceItem = Scholar.Items.get(sourceItemID);
|
||||||
Scholar.debug(sourceItem);
|
|
||||||
sourceItem.decrementNoteCount();
|
sourceItem.decrementNoteCount();
|
||||||
|
Scholar.Notifier.trigger('modify', 'item', sourceItemID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If not note, unassociate any notes for which this is a source
|
// If not note, unassociate any notes for which this is a source
|
||||||
else {
|
else {
|
||||||
|
// TODO: option for deleting child notes instead of unlinking
|
||||||
|
|
||||||
|
var sql = "SELECT itemID FROM itemNotes WHERE sourceItemID=" + this.getID();
|
||||||
|
var childNotes = Scholar.DB.columnQuery(sql);
|
||||||
|
|
||||||
var sql = "UPDATE itemNotes SET sourceItemID=NULL WHERE sourceItemID="
|
var sql = "UPDATE itemNotes SET sourceItemID=NULL WHERE sourceItemID="
|
||||||
+ this.getID();
|
+ this.getID();
|
||||||
|
Scholar.DB.query(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove item from See Also table
|
// TODO: remove item from See Also table
|
||||||
|
@ -972,6 +980,11 @@ Scholar.Item.prototype.erase = function(){
|
||||||
|
|
||||||
Scholar.Items.unload(this.getID());
|
Scholar.Items.unload(this.getID());
|
||||||
|
|
||||||
|
// Send notification of unlinked notes
|
||||||
|
if (childNotes){
|
||||||
|
Scholar.Notifier.trigger('modify', 'item', childNotes);
|
||||||
|
}
|
||||||
|
|
||||||
// If we're not in the middle of a larger commit, trigger the notifier now
|
// If we're not in the middle of a larger commit, trigger the notifier now
|
||||||
if (!Scholar.DB.transactionInProgress()){
|
if (!Scholar.DB.transactionInProgress()){
|
||||||
Scholar.Notifier.trigger('delete', 'item', this.getID());
|
Scholar.Notifier.trigger('delete', 'item', this.getID());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user