Fix crash if item field invalid for new type is open on type change

https://forums.zotero.org/discussion/71200/bug-when-changing-item-type-report-id-607330517
This commit is contained in:
Dan Stillman 2018-04-01 15:34:44 -04:00
parent 8d0dc359b4
commit a8d199967e

View File

@ -1087,12 +1087,17 @@
<method name="changeTypeTo">
<parameter name="itemTypeID"/>
<parameter name="menu"/>
<body>
<![CDATA[
<body><![CDATA[
return (async function () {
if (itemTypeID == this.item.itemTypeID) {
return true;
}
if (this.saveOnEdit) {
await this.blurOpenField();
await this.item.saveTx();
}
var fieldsToDelete = this.item.getFieldsNotInType(itemTypeID, true);
// Special cases handled below
@ -1149,15 +1154,15 @@
if (this.saveOnEdit) {
// See note in transformText()
this.blurOpenField().then(() => this.item.saveTx());
await this.blurOpenField();
await this.item.saveTx();
}
else {
this.refresh();
}
if (this.eventHandlers['itemtypechange'] && this.eventHandlers['itemtypechange'].length) {
var self = this;
this.eventHandlers['itemtypechange'].forEach(function (f) f.bind(self)());
this.eventHandlers['itemtypechange'].forEach(f => f.bind(this)());
}
return true;
@ -1169,8 +1174,8 @@
}
return false;
]]>
</body>
}.bind(this))();
]]></body>
</method>