Collection.hasDescendent(type, id) -- type is 'collection' or 'item', for now
This commit is contained in:
parent
15ec35c927
commit
4545a5d8a8
1 changed files with 18 additions and 7 deletions
|
@ -1140,13 +1140,10 @@ Scholar.Collection.prototype.changeParent = function(parent){
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parent){
|
if (parent){
|
||||||
var descendents = this._getDescendents();
|
if (this.hasDescendent('collection', parent)){
|
||||||
for (var i=0, len=descendents.length; i<len; i++){
|
Scholar.debug('Cannot move collection into one of its own '
|
||||||
if (descendents[i]['isCollection'] && parent==descendents[i]['id']){
|
+ 'descendents!', 2);
|
||||||
Scholar.debug('Cannot move collection into one of its own '
|
return false;
|
||||||
+ '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
|
* Deletes collection and all descendent collections and items
|
||||||
**/
|
**/
|
||||||
|
|
Loading…
Reference in a new issue