From deea149235c02404218bc042d6f0de228ce28b95 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 20 May 2006 15:18:36 +0000 Subject: [PATCH] Moved creatorTypeID into itemCreators and changed code accordingly; updated sample data Added Scholar.CreatorTypes with methods getTypes() (multi-dim array with 'id' and 'name') and getTypeName(creatorTypeID) Fixed bug in Scholar.Creators.purge() causing SQL error when deleting a non-existent creator Fixed incorrect field order for itemCreators INSERT queries in save() Changed setCreator() to take empty creator names (causing DELETE in itemCreators but without shifting up creators below it (or down and above, depending on your perspective) like removeCreators()) --- .../content/scholar/data_access.js | 102 +++++++++++------- chrome/chromeFiles/content/scholar/db.js | 10 +- chrome/chromeFiles/content/scholar/scholar.js | 2 +- schema.sql | 78 +++++++------- 4 files changed, 112 insertions(+), 80 deletions(-) diff --git a/chrome/chromeFiles/content/scholar/data_access.js b/chrome/chromeFiles/content/scholar/data_access.js index 2f532a2b4..1ecbe84fa 100644 --- a/chrome/chromeFiles/content/scholar/data_access.js +++ b/chrome/chromeFiles/content/scholar/data_access.js @@ -183,12 +183,12 @@ Scholar.Item.prototype.setCreator = function(orderIndex, firstName, lastName, cr this._loadCreators(); } - if (!creatorTypeID){ - creatorTypeID = 1; + if (!firstName){ + firstName = ''; } - if (!firstName && !lastName){ - throw ('Name not provided for creator'); + if (!lastName){ + lastName = ''; } if (this._creators.has(orderIndex) && @@ -198,6 +198,10 @@ Scholar.Item.prototype.setCreator = function(orderIndex, firstName, lastName, cr return true; } + if (!creatorTypeID){ + creatorTypeID = 1; + } + var creator = new Array(); creator['firstName'] = firstName; creator['lastName'] = lastName; @@ -222,7 +226,8 @@ Scholar.Item.prototype.removeCreator = function(orderIndex){ } this._creators.remove(orderIndex); - for (var i=orderIndex,len=this._creators.length; i<=len; i++){ + // Go to length+1 so we clear the last one + for (var i=orderIndex, max=this._creators.length+1; i