Show error and doc prefs if style can't be found or retrieved

Previously a 404 downloading the file would prevent opening the doc
prefs window.
This commit is contained in:
Dan Stillman 2017-06-27 01:09:01 -04:00
parent a15261b3b3
commit 9b54ca9ca7
2 changed files with 21 additions and 3 deletions

View file

@ -1049,9 +1049,26 @@ Zotero.Integration.Document.prototype._getSession = Zotero.Promise.coroutine(fun
if (/^https?:\/\/(www\.)?(zotero\.org|citationstyles\.org)/.test(data.style.styleID) ||
me._doc.displayAlert(displayError, DIALOG_ICON_WARNING, DIALOG_BUTTONS_YES_NO)) {
yield Zotero.Styles.install({url: data.style.styleID}, data.style.styleID, true);
yield this._session.setData(data, true);
return Zotero.Promise.resolve(this._session);
let installed = false;
try {
yield Zotero.Styles.install(
{url: data.style.styleID}, data.style.styleID, true
);
installed = true;
}
catch (e) {
me._doc.displayAlert(
Zotero.getString(
'integration.error.styleNotFound', data.style.styleID
),
DIALOG_ICON_WARNING,
DIALOG_BUTTONS_OK
);
}
if (installed) {
yield this._session.setData(data, true);
return Zotero.Promise.resolve(this._session);
}
}
}
return this._session.setDocPrefs(this._doc, this._app.primaryFieldType,

View file

@ -827,6 +827,7 @@ integration.error.deletePipe = The pipe that Zotero uses to communicate with t
integration.error.invalidStyle = The style you have selected does not appear to be valid. If you have created this style yourself, please ensure that it passes validation as described at https://github.com/citation-style-language/styles/wiki/Validation. Alternatively, try selecting another style.
integration.error.fieldTypeMismatch = Zotero cannot update this document because it was created by a different word processing application with an incompatible field encoding. In order to make a document compatible with both Word and LibreOffice, open the document in the word processor with which it was originally created and switch the field type to Bookmarks in the Zotero Document Preferences.
integration.error.styleMissing = The citation style used in this document is missing. Would you like to install it from %S?
integration.error.styleNotFound = The citation style %S could not be found.
integration.replace = Replace this Zotero field?
integration.missingItem.single = The highlighted citation no longer exists in your Zotero database. Do you want to select a substitute item?