Clear parentKey change marker after save
Fixes #1325, Field editor closes during auto-sync of newly created parent item
This commit is contained in:
parent
2baa537542
commit
fdb9e20076
|
@ -1623,6 +1623,11 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
|
||||||
yield Zotero.DB.queryAsync(sql, [parentItemID, this.id]);
|
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
|
// Note
|
||||||
if ((isNew && this.isNote()) || this._changed.note) {
|
if ((isNew && this.isNote()) || this._changed.note) {
|
||||||
if (!isNew) {
|
if (!isNew) {
|
||||||
|
|
|
@ -438,6 +438,18 @@ describe("Zotero.Item", function () {
|
||||||
assert.isFalse(item.hasChanged());
|
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* () {
|
it("should move a top-level note under another item", function* () {
|
||||||
var noteItem = new Zotero.Item('note');
|
var noteItem = new Zotero.Item('note');
|
||||||
var id = yield noteItem.saveTx()
|
var id = yield noteItem.saveTx()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user