From d21638c465dc08fb03677d2ffea53caadacd53af Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 23 Mar 2006 08:51:05 +0000 Subject: [PATCH] Added in basic folder support to data access framework (no editing folders, no level information) New Scholar.Objects method for treeView: getTreeRows() -- returns mixed array of all Folder and Object objects in the proper order, type testable with instanceof (e.g. if (obj instanceof Scholar.Folder)) Scholar.Objects.get() and getAll() return arrays hashed by objectID again, since they're no longer used directly by treeView Scholar.Objects.get() now returns the object directly if only one argument and scalar (i.e. one id) Updated schema and sample data to handle folder ordering --- .../content/scholar/data_access.js | 152 ++++++++++++++++-- chrome/chromeFiles/content/scholar/db.js | 4 +- chrome/chromeFiles/content/scholar/scholar.js | 2 +- chrome/chromeFiles/content/scholar/sidebar.js | 2 +- schema.sql | 73 ++++++--- 5 files changed, 194 insertions(+), 39 deletions(-) diff --git a/chrome/chromeFiles/content/scholar/data_access.js b/chrome/chromeFiles/content/scholar/data_access.js index e21fe39a18..e60ce5212f 100644 --- a/chrome/chromeFiles/content/scholar/data_access.js +++ b/chrome/chromeFiles/content/scholar/data_access.js @@ -696,8 +696,9 @@ Scholar.Object.prototype._loadObjectData = function(){ - - +/* + * Primary interface for accessing Scholar objects + */ Scholar.Objects = new function(){ // Private members var _objects = new Array(); @@ -705,6 +706,7 @@ Scholar.Objects = new function(){ // Privileged methods this.get = get; this.getAll = getAll; + this.getTreeRows = getTreeRows; this.reload = reload; this.reloadAll = reloadAll; @@ -712,6 +714,9 @@ Scholar.Objects = new function(){ * Retrieves (and loads, if necessary) an arbitrary number of objects * * Can be passed ids as individual parameters or as an array of ids, or both + * + * If only one argument and it's an id, return object directly; + * otherwise, return array indexed by objectID */ function get(){ var toLoad = new Array(); @@ -722,7 +727,7 @@ Scholar.Objects = new function(){ } var ids = Scholar.flattenArguments(arguments); - + for (var i=0; i