Restore "Delete All Automatic Tags" menu option for tag selector. Closes #1660
This commit is contained in:
parent
d01038b13b
commit
72fb67d15b
3 changed files with 72 additions and 0 deletions
|
@ -389,6 +389,43 @@ Zotero.TagSelector = class TagSelectorContainer extends React.Component {
|
|||
this.props.onSelection(this.selectedTags);
|
||||
}
|
||||
}
|
||||
|
||||
async deleteAutomatic() {
|
||||
var num = (await Zotero.Tags.getAutomaticInLibrary(this.libraryID)).length;
|
||||
if (!num) {
|
||||
return;
|
||||
}
|
||||
|
||||
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(Components.interfaces.nsIPromptService);
|
||||
var confirmed = ps.confirm(
|
||||
window,
|
||||
Zotero.getString('pane.tagSelector.deleteAutomatic.title'),
|
||||
Zotero.getString(
|
||||
'pane.tagSelector.deleteAutomatic.message',
|
||||
new Intl.NumberFormat().format(num),
|
||||
num
|
||||
)
|
||||
+ "\n\n"
|
||||
+ Zotero.getString('general.actionCannotBeUndone')
|
||||
);
|
||||
if (confirmed) {
|
||||
Zotero.showZoteroPaneProgressMeter(null, true);
|
||||
try {
|
||||
await Zotero.Tags.removeAutomaticFromLibrary(
|
||||
this.libraryID,
|
||||
(progress, progressMax) => {
|
||||
Zotero.updateZoteroPaneProgressMeter(
|
||||
Math.round(progress / progressMax * 100)
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
finally {
|
||||
Zotero.hideZoteroPaneOverlays();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get label() {
|
||||
let count = this.selectedTags.size;
|
||||
|
|
|
@ -54,5 +54,9 @@
|
|||
type="checkbox"
|
||||
oncommand="ZoteroPane.tagSelector.toggleDisplayAllTags(); event.stopPropagation();"
|
||||
/>
|
||||
<menuitem id="delete-automatic-tags" label="&zotero.tagSelector.deleteAutomaticInLibrary;" type="checkbox"
|
||||
oncommand="ZoteroPane.tagSelector.deleteAutomatic();
|
||||
this.setAttribute('checked', false);
|
||||
event.stopPropagation();"/>
|
||||
</menupopup>
|
||||
</overlay>
|
|
@ -533,4 +533,35 @@ describe("Tag Selector", function () {
|
|||
assert.notInclude(getRegularTags(), tag);
|
||||
})
|
||||
});
|
||||
|
||||
describe("#deleteAutomatic()", function() {
|
||||
it('should delete automatic tags', async function() {
|
||||
await selectLibrary(win);
|
||||
var item = createUnsavedDataObject('item');
|
||||
item.setTags([
|
||||
{
|
||||
tag: "automatic",
|
||||
type: 1
|
||||
},
|
||||
{
|
||||
tag: 'manual'
|
||||
}
|
||||
]);
|
||||
var promise = waitForTagSelector(win);
|
||||
await item.saveTx();
|
||||
await promise;
|
||||
|
||||
assert.include(getRegularTags(), "automatic");
|
||||
assert.include(getRegularTags(), "manual");
|
||||
|
||||
var dialogPromise = waitForDialog();
|
||||
var tagSelectorPromise = waitForTagSelector(win);
|
||||
tagSelector.deleteAutomatic();
|
||||
await dialogPromise;
|
||||
await tagSelectorPromise;
|
||||
|
||||
assert.include(getRegularTags(), 'manual');
|
||||
assert.notInclude(getRegularTags(), 'automatic');
|
||||
});
|
||||
});
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue