Fixed creators not getting inserted into itemCreators on new item save()
This commit is contained in:
parent
551582eb7e
commit
b9a5c7dc38
|
@ -499,40 +499,6 @@ Scholar.Item.prototype.save = function(){
|
||||||
try {
|
try {
|
||||||
Scholar.DB.beginTransaction();
|
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
|
// 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();
|
Scholar.DB.commitTransaction();
|
||||||
|
|
||||||
// Reload collection to update isEmpty,
|
// Reload collection to update isEmpty,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user