commit b9a5c7dc3815d52f60e41b38e3e771db04cf453d
parent 551582eb7ed3bc8933d48d8b796dc9a8ef97b9a5
Author: Dan Stillman <dstillman@zotero.org>
Date: Thu, 1 Jun 2006 07:29:39 +0000
Fixed creators not getting inserted into itemCreators on new item save()
Diffstat:
1 file changed, 34 insertions(+), 34 deletions(-)
diff --git a/chrome/chromeFiles/content/scholar/xpcom/data_access.js b/chrome/chromeFiles/content/scholar/xpcom/data_access.js
@@ -500,40 +500,6 @@ Scholar.Item.prototype.save = function(){
Scholar.DB.beginTransaction();
//
- // Creators
- //
- if (this._changedCreators.length){
- for (orderIndex in this._changedCreators.items){
- var creator = this.getCreator(orderIndex);
-
- // If empty, skip
- if (!creator['firstName'] && !creator['lastName']){
- continue;
- }
-
- // See if this is an existing creator
- var creatorID = Scholar.Creators.getID(
- creator['firstName'],
- creator['lastName']
- );
-
- // If not, add it
- if (!creatorID){
- creatorID = Scholar.Creators.add(
- creator['firstName'],
- creator['lastName']
- );
- }
-
- sql += 'INSERT INTO itemCreators VALUES ('
- + itemID + ',' + creatorID + ','
- + creator['creatorTypeID'] + ', ' + orderIndex
- + ");\n";
- }
- }
-
-
- //
// itemData fields
//
var sql = "INSERT INTO items (" + sqlColumns.join() + ')'
@@ -572,6 +538,40 @@ Scholar.Item.prototype.save = function(){
}
}
+ //
+ // Creators
+ //
+ if (this._changedCreators.length){
+ for (orderIndex in this._changedCreators.items){
+ var creator = this.getCreator(orderIndex);
+
+ // If empty, skip
+ if (!creator['firstName'] && !creator['lastName']){
+ continue;
+ }
+
+ // See if this is an existing creator
+ var creatorID = Scholar.Creators.getID(
+ creator['firstName'],
+ creator['lastName']
+ );
+
+ // If not, add it
+ if (!creatorID){
+ creatorID = Scholar.Creators.add(
+ creator['firstName'],
+ creator['lastName']
+ );
+ }
+
+ sql = 'INSERT INTO itemCreators VALUES ('
+ + itemID + ',' + creatorID + ','
+ + creator['creatorTypeID'] + ', ' + orderIndex
+ + ");\n";
+ Scholar.DB.query(sql);
+ }
+ }
+
Scholar.DB.commitTransaction();
// Reload collection to update isEmpty,