Upload modified items after tag rename
The web library will probably still display the old tag in addition to the new one, at least until browser restart. We'll have to deal with that separately. Closes #1205
This commit is contained in:
parent
9637770c16
commit
bb489a45c3
3 changed files with 22 additions and 1 deletions
|
@ -235,6 +235,9 @@ Zotero.Tags = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var oldTagID = this.getID(oldName);
|
var oldTagID = this.getID(oldName);
|
||||||
|
if (!oldTagID) {
|
||||||
|
throw new Error(`Tag '${oldName}' not found`);
|
||||||
|
}
|
||||||
|
|
||||||
// We need to know if the old tag has a color assigned so that
|
// We need to know if the old tag has a color assigned so that
|
||||||
// we can assign it to the new name
|
// we can assign it to the new name
|
||||||
|
@ -255,10 +258,12 @@ Zotero.Tags = new function() {
|
||||||
+ 'WHERE tagID=? AND itemID IN (' + placeholders + ')';
|
+ 'WHERE tagID=? AND itemID IN (' + placeholders + ')';
|
||||||
yield Zotero.DB.queryAsync(sql, [newTagID, oldTagID].concat(chunk));
|
yield Zotero.DB.queryAsync(sql, [newTagID, oldTagID].concat(chunk));
|
||||||
|
|
||||||
sql = 'UPDATE items SET clientDateModified=? '
|
sql = 'UPDATE items SET clientDateModified=?, synced=0 '
|
||||||
+ 'WHERE itemID IN (' + placeholders + ')'
|
+ 'WHERE itemID IN (' + placeholders + ')'
|
||||||
yield Zotero.DB.queryAsync(sql, [Zotero.DB.transactionDateTime].concat(chunk));
|
yield Zotero.DB.queryAsync(sql, [Zotero.DB.transactionDateTime].concat(chunk));
|
||||||
|
|
||||||
|
chunk.forEach(id => Zotero.Items.get(id).updateSynced(false, true));
|
||||||
|
|
||||||
yield Zotero.Items.reload(oldItemIDs, ['tags'], true);
|
yield Zotero.Items.reload(oldItemIDs, ['tags'], true);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
|
@ -414,6 +414,9 @@ function createUnsavedDataObject(objectType, params = {}) {
|
||||||
if (params.collections !== undefined) {
|
if (params.collections !== undefined) {
|
||||||
obj.setCollections(params.collections);
|
obj.setCollections(params.collections);
|
||||||
}
|
}
|
||||||
|
if (params.tags !== undefined) {
|
||||||
|
obj.setTags(params.tags);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'collection':
|
case 'collection':
|
||||||
|
|
|
@ -25,6 +25,19 @@ describe("Zotero.Tags", function () {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("#rename()", function () {
|
||||||
|
it("should mark items as changed", function* () {
|
||||||
|
var item1 = yield createDataObject('item', { tags: [{ tag: "A" }], synced: true });
|
||||||
|
var item2 = yield createDataObject('item', { tags: [{ tag: "A" }, { tag: "B" }], synced: true });
|
||||||
|
var item3 = yield createDataObject('item', { tags: [{ tag: "B" }, { tag: "C" }], synced: true });
|
||||||
|
|
||||||
|
yield Zotero.Tags.rename(item1.libraryID, "A", "D");
|
||||||
|
assert.isFalse(item1.synced);
|
||||||
|
assert.isFalse(item2.synced);
|
||||||
|
assert.isTrue(item3.synced);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("#removeFromLibrary()", function () {
|
describe("#removeFromLibrary()", function () {
|
||||||
it("should reload tags of associated items", function* () {
|
it("should reload tags of associated items", function* () {
|
||||||
var libraryID = Zotero.Libraries.userLibraryID;
|
var libraryID = Zotero.Libraries.userLibraryID;
|
||||||
|
|
Loading…
Reference in a new issue