commit 5ab37dacd5032a839b1253c06697bc3fb32b806e
parent 672ca5956eb9bc54c012cf66b6609217c16cdb0b
Author: Dan Stillman <dstillman@zotero.org>
Date: Tue, 27 Jun 2006 19:42:02 +0000
Notification improvements for notes
Missing query() call for unlinking notes in Item.erase()
Diffstat:
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/chrome/chromeFiles/content/scholar/xpcom/data_access.js b/chrome/chromeFiles/content/scholar/xpcom/data_access.js
@@ -839,6 +839,8 @@ Scholar.Item.prototype.setNoteSource = function(sourceItemID){
this.updateDateModified();
Scholar.DB.commitTransaction();
+ Scholar.Notifier.trigger('modify', 'item', this.getID());
+
// Update the note counts of the previous and new sources
if (oldItem){
oldItem.decrementNoteCount();
@@ -938,14 +940,20 @@ Scholar.Item.prototype.erase = function(){
var sourceItemID = Scholar.DB.valueQuery(sql);
if (sourceItemID){
var sourceItem = Scholar.Items.get(sourceItemID);
- Scholar.debug(sourceItem);
sourceItem.decrementNoteCount();
+ Scholar.Notifier.trigger('modify', 'item', sourceItemID);
}
}
// If not note, unassociate any notes for which this is a source
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="
+ this.getID();
+ Scholar.DB.query(sql);
}
// TODO: remove item from See Also table
@@ -972,6 +980,11 @@ Scholar.Item.prototype.erase = function(){
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 (!Scholar.DB.transactionInProgress()){
Scholar.Notifier.trigger('delete', 'item', this.getID());