www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit c0d6648b9eaf440e8a31d01ea50a0b2488e22320
parent 326d2bc1e34190a9be68d6b946466dc3a484f105
Author: Dan Stillman <dstillman@zotero.org>
Date:   Sat, 31 May 2014 14:20:53 -0400

Allow inline editing of collection names

Can be triggered by double-clicking or Return and also by F2 on
Windows/Linux

This does mean double-clicking no longer toggles the collection open and
closed. If we wanted to preserve that we could probably capture the
double-click.

Closes Trac ticket 231, only 8 years later

Diffstat:
Mchrome/content/zotero/xpcom/collectionTreeView.js | 23++++++++++++++++++++++-
Mchrome/content/zotero/zoteroPane.xul | 2+-
2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js @@ -575,6 +575,28 @@ Zotero.CollectionTreeView.prototype.isSelectable = function (row, col) { } +/** + * Tree method for whether to allow inline editing (not to be confused with this.editable) + */ +Zotero.CollectionTreeView.prototype.isEditable = function (row, col) { + return this.itemGroup.isCollection() && this.editable; +} + + +Zotero.CollectionTreeView.prototype.setCellText = function (row, col, val) { + val = val.trim(); + if (val === "") { + return; + } + this.itemGroup.ref.name = val; + this.itemGroup.ref.save(); +} + + + +/** + * Returns TRUE if the underlying view is editable + */ Zotero.CollectionTreeView.prototype.__defineGetter__('editable', function () { return this._getItemAtRow(this.selection.currentIndex).editable; }); @@ -1803,7 +1825,6 @@ Zotero.CollectionTreeView.prototype.drop = function(row, orient, dataTransfer) //////////////////////////////////////////////////////////////////////////////// Zotero.CollectionTreeView.prototype.isSorted = function() { return false; } -Zotero.CollectionTreeView.prototype.isEditable = function(row, idx) { return false; } /* Set 'highlighted' property on rows set by setHighlightedRows */ Zotero.CollectionTreeView.prototype.getRowProperties = function(row, prop) { diff --git a/chrome/content/zotero/zoteroPane.xul b/chrome/content/zotero/zoteroPane.xul @@ -301,7 +301,7 @@ <tree id="zotero-collections-tree" hidecolumnpicker="true" context="zotero-collectionmenu" onmouseover="ZoteroPane_Local.collectionsView.setHighlightedRows();" onselect="ZoteroPane_Local.onCollectionSelected();" - seltype="cell" flex="1"> + seltype="cell" flex="1" editable="true"> <treecols> <treecol id="zotero-collections-name-column"