www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 4545a5d8a8d86c4d1e29c0e916619a4c625d6aed
parent 15ec35c927932c4a6ac5f4c3d2793ba0233f0bc8
Author: Dan Stillman <dstillman@zotero.org>
Date:   Thu,  8 Jun 2006 19:11:10 +0000

Collection.hasDescendent(type, id) -- type is 'collection' or 'item', for now


Diffstat:
Mchrome/chromeFiles/content/scholar/xpcom/data_access.js | 25++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/chrome/chromeFiles/content/scholar/xpcom/data_access.js b/chrome/chromeFiles/content/scholar/xpcom/data_access.js @@ -1140,13 +1140,10 @@ Scholar.Collection.prototype.changeParent = function(parent){ } if (parent){ - var descendents = this._getDescendents(); - for (var i=0, len=descendents.length; i<len; i++){ - if (descendents[i]['isCollection'] && parent==descendents[i]['id']){ - Scholar.debug('Cannot move collection into one of its own ' - + 'descendents!', 2); - return false; - } + if (this.hasDescendent('collection', parent)){ + Scholar.debug('Cannot move collection into one of its own ' + + 'descendents!', 2); + return false; } } @@ -1250,6 +1247,20 @@ Scholar.Collection.prototype.hasItem = function(itemID){ } +Scholar.Collection.prototype.hasDescendent = function(type, id){ + var descendents = this._getDescendents(); + for (var i=0, len=descendents.length; i<len; i++){ + // TODO: fix this to work with smart collections + if (((type=='collection' && descendents[i]['isCollection']) || + (type=='item' && !descendents[i]['isCollection'])) + && id==descendents[i]['id']){ + return true; + } + } + return false; +} + + /** * Deletes collection and all descendent collections and items **/