Don't change title when renaming from parent metadata (#4363)
This commit is contained in:
parent
327206f931
commit
9ea56705a0
2 changed files with 2 additions and 25 deletions
|
@ -5672,7 +5672,6 @@ var ZoteroPane = new function()
|
|||
if (ext) {
|
||||
newName = newName + ext[0];
|
||||
}
|
||||
let origFilenameNoExt = origFilename.replace(extRE, '')
|
||||
|
||||
var renamed = await item.renameAttachmentFile(newName, false, true);
|
||||
if (renamed !== true) {
|
||||
|
@ -5680,13 +5679,6 @@ var ZoteroPane = new function()
|
|||
continue;
|
||||
}
|
||||
|
||||
// If the attachment title matched the filename, change it now
|
||||
let origTitle = item.getField('title');
|
||||
if (origTitle == origFilename || origTitle == origFilenameNoExt) {
|
||||
item.setField('title', newName);
|
||||
await item.saveTx();
|
||||
}
|
||||
|
||||
let str = await document.l10n.formatValue('file-renaming-file-renamed-to', { filename: newName });
|
||||
progressWin.addLines(str, item.getItemTypeIconName());
|
||||
progressWin.show();
|
||||
|
|
|
@ -671,7 +671,7 @@ describe("ZoteroPane", function() {
|
|||
assert.equal(attachment.getField('title'), 'Image')
|
||||
});
|
||||
|
||||
it("should change attachment title if the same as filename", async function () {
|
||||
it("should not change attachment title even if the same as filename", async function () {
|
||||
var item = createUnsavedDataObject('item');
|
||||
item.setField('title', 'Title');
|
||||
await item.saveTx();
|
||||
|
@ -683,22 +683,7 @@ describe("ZoteroPane", function() {
|
|||
|
||||
await zp.renameSelectedAttachmentsFromParents();
|
||||
assert.equal(attachment.attachmentFilename, 'Title.png');
|
||||
assert.equal(attachment.getField('title'), 'Title.png')
|
||||
});
|
||||
|
||||
it("should change attachment title if the same as filename without extension", async function () {
|
||||
var item = createUnsavedDataObject('item');
|
||||
item.setField('title', 'Title');
|
||||
await item.saveTx();
|
||||
|
||||
var attachment = await importFileAttachment('test.png', { parentItemID: item.id });
|
||||
attachment.setField('title', 'test');
|
||||
await attachment.saveTx();
|
||||
await zp.selectItem(attachment.id);
|
||||
|
||||
await zp.renameSelectedAttachmentsFromParents();
|
||||
assert.equal(attachment.attachmentFilename, 'Title.png');
|
||||
assert.equal(attachment.getField('title'), 'Title.png')
|
||||
assert.equal(attachment.getField('title'), 'test.png')
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue