Fixes #1444, Attachment arrow/count persists after delete
This was fixed but then broken again for trashed items. Now fixed again.
This commit is contained in:
parent
2bfb5af205
commit
e636fe0f65
1 changed files with 28 additions and 4 deletions
|
@ -1909,6 +1909,28 @@ Zotero.Item.prototype.save = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._changedDeleted) {
|
if (this._changedDeleted) {
|
||||||
|
// Update child item counts on parent
|
||||||
|
var sourceItemID = this.getSource();
|
||||||
|
if (sourceItemID) {
|
||||||
|
var sourceItem = Zotero.Items.get(sourceItemID);
|
||||||
|
if (this._deleted) {
|
||||||
|
if (this.isAttachment()) {
|
||||||
|
sourceItem.decrementAttachmentCount();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sourceItem.decrementNoteCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (this.isAttachment()) {
|
||||||
|
sourceItem.incrementAttachmentCount();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sourceItem.incrementNoteCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Refresh trash
|
||||||
Zotero.Notifier.trigger('refresh', 'collection', 0);
|
Zotero.Notifier.trigger('refresh', 'collection', 0);
|
||||||
if (this._deleted) {
|
if (this._deleted) {
|
||||||
Zotero.Notifier.trigger('trash', 'item', this.id);
|
Zotero.Notifier.trigger('trash', 'item', this.id);
|
||||||
|
@ -2342,13 +2364,11 @@ Zotero.Item.prototype.getNotes = function(includeTrashed) {
|
||||||
//
|
//
|
||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
Zotero.Item.prototype.incrementAttachmentCount = function() {
|
Zotero.Item.prototype.incrementAttachmentCount = function() {
|
||||||
Zotero.debug('incrementing attachment count from ' + this._numAttachments);
|
|
||||||
this._numAttachments++;
|
this._numAttachments++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Zotero.Item.prototype.decrementAttachmentCount = function() {
|
Zotero.Item.prototype.decrementAttachmentCount = function() {
|
||||||
Zotero.debug('decrementing attachment count from ' + this._numAttachments);
|
|
||||||
this._numAttachments--;
|
this._numAttachments--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3568,7 +3588,9 @@ Zotero.Item.prototype.erase = function(deleteChildren) {
|
||||||
if (sourceItemID) {
|
if (sourceItemID) {
|
||||||
var sourceItem = Zotero.Items.get(sourceItemID);
|
var sourceItem = Zotero.Items.get(sourceItemID);
|
||||||
changedItemsNotifierData[sourceItem.id] = { old: sourceItem.serialize() };
|
changedItemsNotifierData[sourceItem.id] = { old: sourceItem.serialize() };
|
||||||
sourceItem.decrementNoteCount();
|
if (!this.deleted) {
|
||||||
|
sourceItem.decrementNoteCount();
|
||||||
|
}
|
||||||
changedItems.push(sourceItemID);
|
changedItems.push(sourceItemID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3580,7 +3602,9 @@ Zotero.Item.prototype.erase = function(deleteChildren) {
|
||||||
if (sourceItemID) {
|
if (sourceItemID) {
|
||||||
var sourceItem = Zotero.Items.get(sourceItemID);
|
var sourceItem = Zotero.Items.get(sourceItemID);
|
||||||
changedItemsNotifierData[sourceItem.id] = { old: sourceItem.serialize() };
|
changedItemsNotifierData[sourceItem.id] = { old: sourceItem.serialize() };
|
||||||
sourceItem.decrementAttachmentCount();
|
if (!this.deleted) {
|
||||||
|
sourceItem.decrementAttachmentCount();
|
||||||
|
}
|
||||||
changedItems.push(sourceItemID);
|
changedItems.push(sourceItemID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue