Trigger inline editing from Rename Collection...

This commit is contained in:
Abe Jellinek 2024-01-30 12:02:32 -05:00 committed by Dan Stillman
parent ab5def98a7
commit a4c09ed701
3 changed files with 11 additions and 15 deletions

View file

@ -221,9 +221,7 @@ var CollectionTree = class CollectionTree extends LibraryTree {
let index = indices[0];
let treeRow = this.getRow(index);
if (treeRow.isCollection() && this.editable && this.selection.focused == index) {
this._editing = treeRow;
treeRow.editingName = treeRow.ref.name;
this.tree.invalidateRow(index);
this.startEditing(treeRow);
}
else if (treeRow.isLibrary()) {
let uri = Zotero.URI.getCurrentUserLibraryURI();
@ -256,6 +254,15 @@ var CollectionTree = class CollectionTree extends LibraryTree {
await treeRow.ref.saveTx();
}
startEditing = (treeRow) => {
if (!treeRow.isCollection()) {
throw new Error('Only collections can be edited inline');
}
this._editing = treeRow;
treeRow.editingName = treeRow.ref.name;
this.tree.invalidateRow(this._rowMap[treeRow.id]);
};
stopEditing = () => {
this._editing = null;
// Returning focus to the tree container

View file

@ -2642,17 +2642,7 @@ var ZoteroPane = new function()
var row = this.getCollectionTreeRow();
if (row) {
if (row.isCollection()) {
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var newName = { value: row.getName() };
var result = promptService.prompt(window, "",
Zotero.getString('pane.collections.rename'), newName, "", {});
if (result && newName.value) {
row.ref.name = newName.value;
row.ref.saveTx();
}
this.collectionsView.startEditing(row);
}
else {
let s = row.ref.clone();

View file

@ -262,7 +262,6 @@ pane.collections.deleteSearch = Are you sure you want to delete the selected
pane.collections.emptyTrash = Are you sure you want to permanently remove items in the Trash?
pane.collections.newSavedSeach = New Saved Search
pane.collections.savedSearchName = Enter a name for this saved search:
pane.collections.rename = Rename collection:
pane.collections.library = My Library
pane.collections.publications = My Publications
pane.collections.feeds = Feeds