Clear parentKey change marker after save

Fixes #1325, Field editor closes during auto-sync of newly created
parent item
This commit is contained in:
Dan Stillman 2018-01-04 19:10:41 -05:00
parent 2baa537542
commit fdb9e20076
2 changed files with 17 additions and 0 deletions

View file

@ -1623,6 +1623,11 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
yield Zotero.DB.queryAsync(sql, [parentItemID, this.id]);
}
// There's no reload for parentKey, so clear it here
if (this._changed.parentKey) {
this._clearChanged('parentKey');
}
// Note
if ((isNew && this.isNote()) || this._changed.note) {
if (!isNew) {

View file

@ -438,6 +438,18 @@ describe("Zotero.Item", function () {
assert.isFalse(item.hasChanged());
});
it("should not be marked as changed after a save", async function () {
var item = await createDataObject('item');
var attachment = new Zotero.Item('attachment');
attachment.attachmentLinkMode = 'linked_url';
await attachment.saveTx();
attachment.parentKey = item.key;
assert.isTrue(attachment._changed.parentKey);
await attachment.saveTx();
assert.isUndefined(attachment._changed.parentKey);
});
it("should move a top-level note under another item", function* () {
var noteItem = new Zotero.Item('note');
var id = yield noteItem.saveTx()