Don't store "Version Number" in Extra for books coming from RDF

The RDF translator assigns 'versionNumber' in addition to 'edition'.
This commit is contained in:
Dan Stillman 2020-03-24 14:48:09 -04:00
parent 02c5510710
commit 679148d8d6
2 changed files with 20 additions and 0 deletions

View file

@ -4424,6 +4424,14 @@ Zotero.Item.prototype.fromJSON = function (json, options = {}) {
invalidFieldLogLines.delete(mappedField);
}
}
// Remove "Version Number" if "Edition" is set, since as of 3/2020 the RDF translator
// assigns it
if (extraFields.has('versionNumber') && setFields.has('edition')
&& extraFields.get('versionNumber') == this.getField('edition')) {
extraFields.delete('versionNumber');
invalidFieldLogLines.delete('versionNumber');
}
}
for (let line of invalidFieldLogLines.values()) {

View file

@ -1913,6 +1913,18 @@ describe("Zotero.Item", function () {
item.fromJSON(json);
assert.equal(item.getField('extra'), '');
});
it("should ignore versionNumber for books", async function () {
var json = {
itemType: "book",
edition: "1",
versionNumber: "1"
};
var item = new Zotero.Item;
item.fromJSON(json);
assert.equal(item.getField('edition'), "1");
assert.equal(item.getField('extra'), '');
});
});
describe("strict mode", function () {