From e85790541bf8e60828801247b56b2b3dee8a3115 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 20 Mar 2013 22:35:44 -0400 Subject: [PATCH] Remove per-library sync error indicators, at least for now The hidden column caused collection names to be cut off unnecessarily, and the extra icons were overly distracting. For now, just show the first error that comes in in the main sync error panel, along with the library name. --- .../zotero/xpcom/collectionTreeView.js | 24 ----- chrome/content/zotero/xpcom/sync.js | 96 ++++++++++++------- chrome/content/zotero/zoteroPane.js | 5 +- chrome/content/zotero/zoteroPane.xul | 19 ++-- chrome/skin/default/zotero/overlay.css | 13 ++- 5 files changed, 76 insertions(+), 81 deletions(-) diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js index e67ddfc444..17af51602a 100644 --- a/chrome/content/zotero/xpcom/collectionTreeView.js +++ b/chrome/content/zotero/xpcom/collectionTreeView.js @@ -403,9 +403,6 @@ Zotero.CollectionTreeView.prototype.getCellText = function(row, column) if (column.id == 'zotero-collections-name-column') { return obj.getName(); } - else if (column.id == 'zotero-collections-sync-status-column') { - return ""; - } else return ""; } @@ -426,27 +423,6 @@ Zotero.CollectionTreeView.prototype.getImageSrc = function(row, col) switch (collectionType) { case 'library': - if (col.id == 'zotero-collections-sync-status-column') { - if (itemGroup.isLibrary(true)) { - var libraryID = itemGroup.isLibrary() ? 0 : itemGroup.ref.libraryID; - var errors = Zotero.Sync.Runner.getErrors(libraryID); - if (errors) { - var e = Zotero.Sync.Runner.getPrimaryError(errors); - switch (e.errorMode) { - case 'warning': - var image = 'error'; - break; - - default: - var image = 'exclamation'; - break; - } - - return 'chrome://zotero/skin/' + image + '.png'; - } - } - return ''; - } break; case 'trash': diff --git a/chrome/content/zotero/xpcom/sync.js b/chrome/content/zotero/xpcom/sync.js index 67a14dbf10..7b2a2a1cce 100644 --- a/chrome/content/zotero/xpcom/sync.js +++ b/chrome/content/zotero/xpcom/sync.js @@ -947,51 +947,73 @@ Zotero.Sync.Runner = new function () { this.updateErrorPanel = function (doc, errors) { var panel = doc.getElementById('zotero-sync-error-panel'); - var panelContent = doc.getElementById('zotero-sync-error-panel-content'); - var panelButtons = doc.getElementById('zotero-sync-error-panel-buttons'); // Clear existing panel content - while (panelContent.hasChildNodes()) { - panelContent.removeChild(panelContent.firstChild); - } - while (panelButtons.hasChildNodes()) { - panelButtons.removeChild(panelButtons.firstChild); + while (panel.hasChildNodes()) { + panel.removeChild(panel.firstChild); } - // TEMP: for now, we only show one error - var e = errors.concat().shift(); - e = this.parseSyncError(e); + var e = this - var desc = doc.createElement('description'); - var msg = e.message; - /*if (e.fileName) { - msg += '\n\nFile: ' + e.fileName + '\nLine: ' + e.lineNumber; - }*/ - desc.textContent = msg; - panelContent.appendChild(desc); - - // If not an error and there's no explicit button text, don't show - // button to report errors - if (e.errorMode != 'error' && typeof e.buttonText == 'undefined') { - e.buttonText = null; - } - - if (e.buttonText !== null) { - if (typeof e.buttonText == 'undefined') { - var buttonText = Zotero.getString('errorReport.reportError'); - var buttonCallback = function () { - doc.defaultView.ZoteroPane.reportErrors(); - }; + for each(var e in errors.concat()) { + e = this.parseSyncError(e); + + var box = doc.createElement('vbox'); + var label = doc.createElement('label'); + if (typeof e.libraryID != 'undefined') { + label.className = "zotero-sync-error-panel-library-name"; + if (e.libraryID == 0) { + var libraryName = Zotero.getString('pane.collections.library'); + } + else { + let group = Zotero.Groups.getByLibraryID(e.libraryID); + var libraryName = group.name; + } + label.setAttribute('value', libraryName); } - else { - var buttonText = e.buttonText; - var buttonCallback = e.buttonCallback; + var content = doc.createElement('hbox'); + var buttons = doc.createElement('hbox'); + buttons.pack = 'end'; + box.appendChild(label); + box.appendChild(content); + box.appendChild(buttons); + + var desc = doc.createElement('description'); + var msg = e.message; + /*if (e.fileName) { + msg += '\n\nFile: ' + e.fileName + '\nLine: ' + e.lineNumber; + }*/ + desc.textContent = msg; + content.appendChild(desc); + + // If not an error and there's no explicit button text, don't show + // button to report errors + if (e.errorMode != 'error' && typeof e.buttonText == 'undefined') { + e.buttonText = null; } - var button = doc.createElement('button'); - button.setAttribute('label', buttonText); - button.onclick = buttonCallback; - panelButtons.appendChild(button); + if (e.buttonText !== null) { + if (typeof e.buttonText == 'undefined') { + var buttonText = Zotero.getString('errorReport.reportError'); + var buttonCallback = function () { + doc.defaultView.ZoteroPane.reportErrors(); + }; + } + else { + var buttonText = e.buttonText; + var buttonCallback = e.buttonCallback; + } + + var button = doc.createElement('button'); + button.setAttribute('label', buttonText); + button.onclick = buttonCallback; + buttons.appendChild(button); + } + + panel.appendChild(box) + + // TEMP: Only show one error for now + break; } return panel; diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index d8bd0fb074..b4e0417b8d 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -1093,10 +1093,11 @@ var ZoteroPane = new function() var itemgroup = this.collectionsView._getItemAtRow(this.collectionsView.selection.currentIndex); - if (itemgroup.isSeparator()) { + // Not necessary with seltype="cell", which calls nsITreeView::isSelectable() + /*if (itemgroup.isSeparator()) { document.getElementById('zotero-items-tree').view = this.itemsView = null; return; - } + }*/ itemgroup.setSearch(''); itemgroup.setTags(getTagSelection()); diff --git a/chrome/content/zotero/zoteroPane.xul b/chrome/content/zotero/zoteroPane.xul index 63eccc0fcb..ac26fe49f8 100644 --- a/chrome/content/zotero/zoteroPane.xul +++ b/chrome/content/zotero/zoteroPane.xul @@ -209,13 +209,13 @@