Changed Scholar.Objects.getTreeRows() to return children of a specified folder instead of all objects -- defaults to root folder
This commit is contained in:
parent
6b5ba60acf
commit
fdfd1e5116
1 changed files with 20 additions and 4 deletions
|
@ -809,15 +809,31 @@ Scholar.Objects = new function(){
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns an array of all folders and objects as
|
* Returns an array of all folders and objects that are children of a folder
|
||||||
* Scholar.Folder and Scholar.Object instances
|
* as Scholar.Folder and Scholar.Object instances
|
||||||
*
|
*
|
||||||
* Type can tested with instanceof (e.g. if (obj instanceof Scholar.Folder))
|
* Takes parent folderID as optional parameter; by default, returns root items
|
||||||
|
*
|
||||||
|
* Type can tested with instanceof (e.g. if (obj instanceof Scholar.Folder)) or isFolder()
|
||||||
*/
|
*/
|
||||||
function getTreeRows(){
|
function getTreeRows(parent){
|
||||||
var toReturn = new Array();
|
var toReturn = new Array();
|
||||||
|
|
||||||
|
/*
|
||||||
|
// To return all items (no longer used)
|
||||||
var sql = 'SELECT * FROM treeOrder WHERE id>0 ORDER BY orderIndex';
|
var sql = 'SELECT * FROM treeOrder WHERE id>0 ORDER BY orderIndex';
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!parent){
|
||||||
|
parent = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
var sql = 'SELECT TORD.* FROM treeOrder TORD '
|
||||||
|
+ 'LEFT JOIN objects O ON (TORD.id=O.objectID AND isFolder=0) '
|
||||||
|
+ 'LEFT JOIN folders F ON (TORD.id=F.folderID AND isFolder=1) '
|
||||||
|
+ 'WHERE IFNULL(O.folderID, F.parentFolderID)=' + parent
|
||||||
|
+ ' ORDER BY orderIndex';
|
||||||
|
|
||||||
var tree = Scholar.DB.query(sql);
|
var tree = Scholar.DB.query(sql);
|
||||||
|
|
||||||
if (!tree){
|
if (!tree){
|
||||||
|
|
Loading…
Reference in a new issue