diff --git a/chrome/content/zotero/xpcom/sync/syncRunner.js b/chrome/content/zotero/xpcom/sync/syncRunner.js index da99dd45a..42c12c588 100644 --- a/chrome/content/zotero/xpcom/sync/syncRunner.js +++ b/chrome/content/zotero/xpcom/sync/syncRunner.js @@ -1059,95 +1059,133 @@ Zotero.Sync.Runner_Module = function (options = {}) { else if (e.name && e.name == 'ZoteroObjectUploadError') { let { code, data, objectType, object } = e; - // Tag too long - if (code == 413 && objectType == 'item') { - if (data && data.tag !== undefined) { - // Show long tag fixer and handle result - e.dialogButtonText = Zotero.getString('general.fix'); - e.dialogButtonCallback = Zotero.Promise.coroutine(function* () { - var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] - .getService(Components.interfaces.nsIWindowMediator); - var lastWin = wm.getMostRecentWindow("navigator:browser"); - - // Open long tag fixer for every long tag in every editable library we're syncing - var editableLibraries = options.libraries - .filter(x => Zotero.Libraries.get(x).editable); - for (let libraryID of editableLibraries) { - let oldTagIDs = yield Zotero.Tags.getLongTagsInLibrary(libraryID); - for (let oldTagID of oldTagIDs) { - let oldTag = Zotero.Tags.getName(oldTagID); - let dataOut = { result: null }; - lastWin.openDialog( - 'chrome://zotero/content/longTagFixer.xul', - '', - 'chrome,modal,centerscreen', - oldTag, - dataOut - ); - // If dialog was cancelled, stop - if (!dataOut.result) { - return; - } - switch (dataOut.result.op) { - case 'split': - for (let libraryID of editableLibraries) { - let itemIDs = yield Zotero.Tags.getTagItems(libraryID, oldTagID); - yield Zotero.DB.executeTransaction(function* () { - for (let itemID of itemIDs) { - let item = yield Zotero.Items.getAsync(itemID); - for (let tag of dataOut.result.tags) { - item.addTag(tag); - } - item.removeTag(oldTag); - yield item.save(); - } - yield Zotero.Tags.purge(oldTagID); - }); - } - break; - - case 'edit': - for (let libraryID of editableLibraries) { - let itemIDs = yield Zotero.Tags.getTagItems(libraryID, oldTagID); - yield Zotero.DB.executeTransaction(function* () { - for (let itemID of itemIDs) { - let item = yield Zotero.Items.getAsync(itemID); - item.replaceTag(oldTag, dataOut.result.tag); - yield item.save(); - } - }); - } - break; - - case 'delete': - for (let libraryID of editableLibraries) { - yield Zotero.Tags.removeFromLibrary(libraryID, oldTagID); - } - break; - } - } - } - - options.restartSync = true; - }); - } - // Note too long - else if (object.isNote() || object.isAttachment()) { - // Throw an error that adds a button for selecting the item to the sync error dialog - if (e.message.includes(' { var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator); var win = wm.getMostRecentWindow("navigator:browser"); - win.ZoteroPane.selectItem(object.id); + win.ZoteroPane.collectionsView.selectCollection(object.id); }; } + else if (objectType == 'item') { + // Tag too long + if (data && data.tag !== undefined) { + // Show long tag fixer and handle result + e.dialogButtonText = Zotero.getString('general.fix'); + e.dialogButtonCallback = Zotero.Promise.coroutine(function* () { + var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] + .getService(Components.interfaces.nsIWindowMediator); + var lastWin = wm.getMostRecentWindow("navigator:browser"); + + // Open long tag fixer for every long tag in every editable library we're syncing + var editableLibraries = options.libraries + .filter(x => Zotero.Libraries.get(x).editable); + for (let libraryID of editableLibraries) { + let oldTagIDs = yield Zotero.Tags.getLongTagsInLibrary(libraryID); + for (let oldTagID of oldTagIDs) { + let oldTag = Zotero.Tags.getName(oldTagID); + let dataOut = { result: null }; + lastWin.openDialog( + 'chrome://zotero/content/longTagFixer.xul', + '', + 'chrome,modal,centerscreen', + oldTag, + dataOut + ); + // If dialog was cancelled, stop + if (!dataOut.result) { + return; + } + switch (dataOut.result.op) { + case 'split': + for (let libraryID of editableLibraries) { + let itemIDs = yield Zotero.Tags.getTagItems(libraryID, oldTagID); + yield Zotero.DB.executeTransaction(function* () { + for (let itemID of itemIDs) { + let item = yield Zotero.Items.getAsync(itemID); + for (let tag of dataOut.result.tags) { + item.addTag(tag); + } + item.removeTag(oldTag); + yield item.save(); + } + yield Zotero.Tags.purge(oldTagID); + }); + } + break; + + case 'edit': + for (let libraryID of editableLibraries) { + let itemIDs = yield Zotero.Tags.getTagItems(libraryID, oldTagID); + yield Zotero.DB.executeTransaction(function* () { + for (let itemID of itemIDs) { + let item = yield Zotero.Items.getAsync(itemID); + item.replaceTag(oldTag, dataOut.result.tag); + yield item.save(); + } + }); + } + break; + + case 'delete': + for (let libraryID of editableLibraries) { + yield Zotero.Tags.removeFromLibrary(libraryID, oldTagID); + } + break; + } + } + } + + options.restartSync = true; + }); + } + else { + // Note too long + if (object.isNote() || object.isAttachment()) { + // Throw an error that adds a button for selecting the item to the sync error dialog + if (e.message.includes(' { + var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] + .getService(Components.interfaces.nsIWindowMediator); + var win = wm.getMostRecentWindow("navigator:browser"); + win.ZoteroPane.selectItem(object.id); + }; + } + } // If not a background sync, show dialog immediately if (!options.background && e.dialogButtonCallback) { diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties index 4ec928bba..26460be1e 100644 --- a/chrome/locale/en-US/zotero/zotero.properties +++ b/chrome/locale/en-US/zotero/zotero.properties @@ -233,6 +233,7 @@ pane.collections.menu.export.feed = Export Feed… pane.collections.menu.createBib.collection = Create Bibliography from Collection… pane.collections.menu.createBib.savedSearch = Create Bibliography from Saved Search… pane.collections.menu.createBib.feed = Create Bibliography from Feed… +pane.collections.showCollectionInLibrary = Show Collection in Library pane.collections.menu.generateReport.collection = Generate Report from Collection… pane.collections.menu.generateReport.savedSearch = Generate Report from Saved Search… @@ -908,6 +909,12 @@ sync.error.checkConnection = Error connecting to server. Check your Internet sync.error.emptyResponseServer = Empty response from server. sync.error.invalidCharsFilename = The filename '%S' contains invalid characters.\n\nRename the file and try again. If you rename the file via the OS, you will need to relink it in Zotero. sync.error.apiKeyInvalid = %S could not authenticate your account. Please re-enter your account details. +sync.error.collectionTooLong = The collection name “%S” is too long to sync. Shorten the name and sync again. +sync.error.fieldTooLong = The %1$S value “%2$S” in one of your items is too long to sync. Shorten the field and sync again. +sync.error.creatorTooLong = The creator name “%S” in one of your items is too long to sync. Shorten the field and sync again. +sync.error.noteEmbeddedImage = Notes with embedded images cannot currently be synced. Syncing of embedded images may be supported in a future version. +sync.error.noteTooLong = The note “%S” is too long to sync. Shorten the note and sync again. +sync.error.reportSiteIssuesToForums = If you receive this message repeatedly for items saved from a particular site, you can report this issue in the %S Forums. account.unlinkWarning = Unlinking your account will prevent %S from syncing your data. account.unlinkWarning.removeData = Remove my %S data from this computer