Fix some collection bugs in data layer, thanks to MozMill/Ben
This commit is contained in:
parent
ee4460fcac
commit
9318d2ad3e
1 changed files with 13 additions and 3 deletions
|
@ -221,12 +221,15 @@ Zotero.Collection.prototype.loadFromRow = function(row) {
|
||||||
this._hasChildCollections = !!row.hasChildCollections;
|
this._hasChildCollections = !!row.hasChildCollections;
|
||||||
this._childItemsLoaded = false;
|
this._childItemsLoaded = false;
|
||||||
this._hasChildItems = !!row.hasChildItems;
|
this._hasChildItems = !!row.hasChildItems;
|
||||||
this._loadChildItems();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Zotero.Collection.prototype.isEmpty = function() {
|
Zotero.Collection.prototype.isEmpty = function() {
|
||||||
return !(parseInt(this._hasChildCollections)) && !(parseInt(this._hasChildItems));
|
if (this._hasChildCollections == undefined) {
|
||||||
|
this.hasChildCollections();
|
||||||
|
}
|
||||||
|
|
||||||
|
return !(this._hasChildCollections || this._hasChildItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
Zotero.Collection.prototype.hasChildCollections = function() {
|
Zotero.Collection.prototype.hasChildCollections = function() {
|
||||||
|
@ -245,7 +248,7 @@ Zotero.Collection.prototype.hasChildCollections = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Zotero.Collection.prototype.hasChildItems = function() {
|
Zotero.Collection.prototype.hasChildItems = function() {
|
||||||
return !!(parseInt(this._hasChildItems));
|
return !!this._hasChildItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -696,12 +699,16 @@ Zotero.Collection.prototype.addItems = function(itemIDs) {
|
||||||
catch(e) {
|
catch(e) {
|
||||||
throw (e + ' [ERROR: ' + Zotero.DB.getLastErrorString() + ']');
|
throw (e + ' [ERROR: ' + Zotero.DB.getLastErrorString() + ']');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Zotero.Notifier.trigger('add', 'collection-item', this.id + '-' + itemID);
|
||||||
}
|
}
|
||||||
|
|
||||||
sql = "UPDATE collections SET dateModified=?, clientDateModified=? WHERE collectionID=?";
|
sql = "UPDATE collections SET dateModified=?, clientDateModified=? WHERE collectionID=?";
|
||||||
Zotero.DB.query(sql, [Zotero.DB.transactionDateTime, Zotero.DB.transactionDateTime, this.id]);
|
Zotero.DB.query(sql, [Zotero.DB.transactionDateTime, Zotero.DB.transactionDateTime, this.id]);
|
||||||
|
|
||||||
Zotero.DB.commitTransaction();
|
Zotero.DB.commitTransaction();
|
||||||
|
|
||||||
|
Zotero.Collections.reload(this.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -718,6 +725,9 @@ Zotero.Collection.prototype.removeItem = function(itemID) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Zotero.DB.beginTransaction();
|
Zotero.DB.beginTransaction();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue