Fixed creators not getting inserted into itemCreators on new item save()

This commit is contained in:
Dan Stillman 2006-06-01 07:29:39 +00:00
parent 551582eb7e
commit b9a5c7dc38

View file

@ -499,40 +499,6 @@ Scholar.Item.prototype.save = function(){
try {
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
//
@ -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,