Fix updating of tag selector after filtering the middle pane
Adds a 'refresh' event to libraryTreeView
This commit is contained in:
parent
820755e152
commit
edb53c31df
4 changed files with 51 additions and 2 deletions
|
@ -426,6 +426,8 @@ Zotero.ItemTreeView.prototype.refresh = Zotero.serial(Zotero.Promise.coroutine(f
|
|||
this.selection.selectEventsSuppressed = false;
|
||||
}
|
||||
|
||||
yield this.runListeners('refresh');
|
||||
|
||||
setTimeout(function () {
|
||||
resolve();
|
||||
});
|
||||
|
|
|
@ -33,7 +33,7 @@ Zotero.LibraryTreeView = function () {
|
|||
Zotero.debug("Creating " + this.type + "s view with id " + this.id);
|
||||
|
||||
//
|
||||
// Create .on(Load|Select).addListener() methods
|
||||
// Create .on(Load|Select|Refresh).addListener() methods
|
||||
//
|
||||
var _createEventBinding = function (event, alwaysOnce) {
|
||||
return alwaysOnce
|
||||
|
@ -47,6 +47,7 @@ Zotero.LibraryTreeView = function () {
|
|||
|
||||
this.onLoad = _createEventBinding('load', true);
|
||||
this.onSelect = _createEventBinding('select');
|
||||
this.onRefresh = _createEventBinding('refresh');
|
||||
};
|
||||
|
||||
Zotero.LibraryTreeView.prototype = {
|
||||
|
|
|
@ -1238,7 +1238,7 @@ var ZoteroPane = new function()
|
|||
Zotero.Prefs.clear('lastViewedFolder');
|
||||
ZoteroPane_Local.displayErrorMessage();
|
||||
};
|
||||
this.itemsView.onLoad.addListener(() => this.setTagScope());
|
||||
this.itemsView.onRefresh.addListener(() => this.setTagScope());
|
||||
if (this.tagSelectorShown()) {
|
||||
let tagSelector = document.getElementById('zotero-tag-selector')
|
||||
let handler = function () {
|
||||
|
|
|
@ -53,6 +53,52 @@ describe("Tag Selector", function () {
|
|||
win.close();
|
||||
});
|
||||
|
||||
describe("#refresh()", function () {
|
||||
it("should remove tags not on matching items on tag click", function* () {
|
||||
var collection = yield createDataObject('collection');
|
||||
var item1 = createUnsavedDataObject('item', { collections: [collection.id] });
|
||||
item1.setTags([
|
||||
{
|
||||
tag: "A"
|
||||
}
|
||||
]);
|
||||
var item2 = createUnsavedDataObject('item', { collections: [collection.id] });
|
||||
item2.setTags([
|
||||
{
|
||||
tag: "A"
|
||||
},
|
||||
{
|
||||
tag: "B"
|
||||
}
|
||||
]);
|
||||
var item3 = createUnsavedDataObject('item', { collections: [collection.id] });
|
||||
item3.setTags([
|
||||
{
|
||||
tag: "C"
|
||||
}
|
||||
]);
|
||||
var promise = waitForTagSelector(win);
|
||||
yield Zotero.DB.executeTransaction(function* () {
|
||||
yield item1.save();
|
||||
yield item2.save();
|
||||
yield item3.save();
|
||||
});
|
||||
yield promise;
|
||||
|
||||
var tagSelector = doc.getElementById('zotero-tag-selector');
|
||||
var buttons = tagSelector.id('tags-box').getElementsByTagName('button');
|
||||
var spy = sinon.spy(win.ZoteroPane, "updateTagFilter");
|
||||
buttons[0].click();
|
||||
|
||||
yield spy.returnValues[0];
|
||||
|
||||
spy.restore();
|
||||
|
||||
var tags = getRegularTags();
|
||||
assert.sameMembers(tags, ['A', 'B']);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#notify()", function () {
|
||||
it("should add a tag when added to an item in the library root", function* () {
|
||||
var promise, tagSelector;
|
||||
|
|
Loading…
Add table
Reference in a new issue