parent
c73e664312
commit
6125d65bc2
4 changed files with 44 additions and 1 deletions
|
@ -103,6 +103,22 @@ Zotero.Searches = function() {
|
|||
},
|
||||
|
||||
|
||||
this.getNextName = async function (libraryID, name) {
|
||||
// Trim '(1)', etc.
|
||||
var matches = name.match(/^(.+) \(\d+\)$/);
|
||||
if (matches) {
|
||||
name = matches[1].trim();
|
||||
}
|
||||
var sql = "SELECT savedSearchName FROM savedSearches "
|
||||
+ "WHERE libraryID=? AND savedSearchName LIKE ? ESCAPE '\\'";
|
||||
var names = await Zotero.DB.columnQueryAsync(
|
||||
sql,
|
||||
[libraryID, Zotero.DB.escapeSQLExpression(name) + '%']
|
||||
);
|
||||
return Zotero.Utilities.Internal.getNextName(name, names);
|
||||
};
|
||||
|
||||
|
||||
this._loadConditions = Zotero.Promise.coroutine(function* (libraryID, ids, idSQL) {
|
||||
var sql = "SELECT savedSearchID, searchConditionID, condition, operator, value, required "
|
||||
+ "FROM savedSearches LEFT JOIN savedSearchConditions USING (savedSearchID) "
|
||||
|
|
|
@ -2056,6 +2056,24 @@ var ZoteroPane = new function()
|
|||
});
|
||||
|
||||
|
||||
// Currently only works on searches
|
||||
this.duplicateSelectedCollection = async function () {
|
||||
if (!this.canEdit()) {
|
||||
this.displayCannotEditLibraryMessage();
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.collectionsView.selection.count == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var row = this.collectionsView.selectedTreeRow;
|
||||
let o = row.ref.clone();
|
||||
o.name = await row.ref.ObjectsClass.getNextName(row.ref.libraryID, o.name);
|
||||
await o.saveTx();
|
||||
};
|
||||
|
||||
|
||||
this.editSelectedCollection = Zotero.Promise.coroutine(function* () {
|
||||
if (!this.canEdit()) {
|
||||
this.displayCannotEditLibraryMessage();
|
||||
|
@ -2453,6 +2471,10 @@ var ZoteroPane = new function()
|
|||
id: "editSelectedCollection",
|
||||
oncommand: () => this.editSelectedCollection()
|
||||
},
|
||||
{
|
||||
id: "duplicate",
|
||||
oncommand: () => this.duplicateSelectedCollection()
|
||||
},
|
||||
{
|
||||
id: "markReadFeed",
|
||||
oncommand: () => this.markFeedRead()
|
||||
|
@ -2611,6 +2633,7 @@ var ZoteroPane = new function()
|
|||
else if (collectionTreeRow.isSearch()) {
|
||||
show = [
|
||||
'editSelectedCollection',
|
||||
'duplicate',
|
||||
'deleteCollection',
|
||||
'sep3',
|
||||
'exportCollection',
|
||||
|
@ -2618,7 +2641,6 @@ var ZoteroPane = new function()
|
|||
'loadReport'
|
||||
];
|
||||
|
||||
m.deleteCollection.setAttribute('label', Zotero.getString('pane.collections.menu.delete.savedSearch'));
|
||||
|
||||
if (!this.itemsView.rowCount) {
|
||||
disable.push('exportCollection', 'createBibCollection', 'loadReport');
|
||||
|
@ -2626,6 +2648,8 @@ var ZoteroPane = new function()
|
|||
|
||||
// Adjust labels
|
||||
m.editSelectedCollection.setAttribute('label', Zotero.getString('pane.collections.menu.edit.savedSearch'));
|
||||
m.duplicate.setAttribute('label', Zotero.getString('pane.collections.menu.duplicate.savedSearch'));
|
||||
m.deleteCollection.setAttribute('label', Zotero.getString('pane.collections.menu.delete.savedSearch'));
|
||||
m.exportCollection.setAttribute('label', Zotero.getString('pane.collections.menu.export.savedSearch'));
|
||||
m.createBibCollection.setAttribute('label', Zotero.getString('pane.collections.menu.createBib.savedSearch'));
|
||||
m.loadReport.setAttribute('label', Zotero.getString('pane.collections.menu.generateReport.savedSearch'));
|
||||
|
@ -2693,6 +2717,7 @@ var ZoteroPane = new function()
|
|||
disable.push(
|
||||
'newSubcollection',
|
||||
'editSelectedCollection',
|
||||
'duplicate',
|
||||
'deleteCollection',
|
||||
'deleteCollectionAndItems'
|
||||
);
|
||||
|
|
|
@ -227,6 +227,7 @@
|
|||
<menuitem class="zotero-menuitem-show-duplicates" label="&zotero.toolbar.duplicate.label;"/>
|
||||
<menuitem class="zotero-menuitem-show-unfiled" label="&zotero.collections.showUnfiledItems;"/>
|
||||
<menuitem class="zotero-menuitem-edit-collection"/>
|
||||
<menuitem class="zotero-menuitem-duplicate-collection"/>
|
||||
<menuitem class="zotero-menuitem-mark-read-feed" label="&zotero.toolbar.markFeedRead.label;"/>
|
||||
<menuitem class="zotero-menuitem-edit-feed" label="&zotero.toolbar.feeds.edit;"/>
|
||||
<menuitem class="zotero-menuitem-delete-collection"/>
|
||||
|
|
|
@ -237,6 +237,7 @@ pane.collections.removeLibrary = Remove Library
|
|||
pane.collections.removeLibrary.text = Are you sure you want to permanently remove “%S” from this computer?
|
||||
|
||||
pane.collections.menu.rename.collection = Rename Collection…
|
||||
pane.collections.menu.duplicate.savedSearch = Duplicate Saved Search
|
||||
pane.collections.menu.edit.savedSearch = Edit Saved Search…
|
||||
pane.collections.menu.edit.feed = Edit Feed…
|
||||
pane.collections.menu.remove.library = Remove Library…
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue