mirror of
https://github.com/zotero/zotero.git
synced 2026-09-27 01:21:27 +00:00
Properly clear previousData on save for primary data and item fields
Closes #5297
This commit is contained in:
parent
05a2539b81
commit
ded8dca668
1 changed files with 30 additions and 1 deletions
|
|
@ -819,7 +819,36 @@ Zotero.DataObject.prototype.hasChanged = function() {
|
|||
Zotero.DataObject.prototype._clearChanged = function (dataType) {
|
||||
if (dataType) {
|
||||
delete this._changed[dataType];
|
||||
delete this._previousData[dataType];
|
||||
|
||||
// Unlike _changed, which has primary/item data under .primaryData/.itemData properties,
|
||||
// _previousData has individual top-level fields regardless of category, so when clearing
|
||||
// 'primaryData'/'itemData', check whether each stored field is a primary data or item field
|
||||
// and clear if so
|
||||
switch (dataType) {
|
||||
case 'primaryData':
|
||||
case 'itemData':
|
||||
let toDelete = [];
|
||||
for (let field of Object.keys(this._previousData)) {
|
||||
if (dataType == 'primaryData') {
|
||||
if (this.ObjectsClass.isPrimaryField(field)) {
|
||||
toDelete.push(field);
|
||||
}
|
||||
}
|
||||
else if (dataType == 'itemData') {
|
||||
if (Zotero.ItemFields.getID(field)) {
|
||||
toDelete.push(field);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let field of toDelete) {
|
||||
delete this._previousData[field];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
delete this._previousData[dataType];
|
||||
}
|
||||
|
||||
delete this._changedData[dataType];
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue