From 234127e65a2eb5f139835e0b44cce12f1baa90e7 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 25 Mar 2016 16:48:33 -0400 Subject: [PATCH] Update toolbar icons on group editability change And trigger 'group' 'modify' notifier event for inherited Zotero.Library properties --- chrome/content/zotero/xpcom/data/library.js | 4 ++ chrome/content/zotero/zoteroPane.js | 80 +++++++++++---------- test/tests/collectionTreeViewTest.js | 19 +++++ test/tests/groupsTest.js | 15 ++++ 4 files changed, 82 insertions(+), 36 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/library.js b/chrome/content/zotero/xpcom/data/library.js index d9b28e9ae..7ab8c0011 100644 --- a/chrome/content/zotero/xpcom/data/library.js +++ b/chrome/content/zotero/xpcom/data/library.js @@ -458,6 +458,10 @@ Zotero.Library.prototype._saveData = Zotero.Promise.coroutine(function* (env) { let sql = "UPDATE libraries SET " + changedCols.map(function(v) v + "=?").join(", ") + " WHERE libraryID=?"; yield Zotero.DB.queryAsync(sql, params); + + // Since these are Zotero.Library properties, the 'modify' for the inheriting object may not + // get triggered, so call it here too + Zotero.Notifier.queue('modify', this.libraryType, this.libraryTypeID); } else { Zotero.debug("Library data did not change for " + this._objectType + " " + this.id, 5); } diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 298d7ffac..53b81a232 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -1128,6 +1128,9 @@ var ZoteroPane = new function() if (this.itemsView && this.itemsView.collectionTreeRow.id == collectionTreeRow.id) { Zotero.debug("Collection selection hasn't changed"); + + // Update toolbar, in case editability has changed + this._updateToolbarIconsForRow(collectionTreeRow); return; } @@ -1168,42 +1171,7 @@ var ZoteroPane = new function() collectionTreeRow.setSearch(''); collectionTreeRow.setTags(getTagSelection()); - // Enable or disable toolbar icons and menu options as necessary - const disableIfNoEdit = [ - "cmd_zotero_newCollection", - "cmd_zotero_newSavedSearch", - "zotero-tb-add", - "cmd_zotero_newItemFromCurrentPage", - "zotero-tb-lookup", - "cmd_zotero_newStandaloneNote", - "zotero-tb-note-add", - "zotero-tb-attachment-add" - ]; - for(var i=0; i