Handle multi-collection/search add in collectionTreeView::notify()
This commit is contained in:
parent
6c43e75d26
commit
c099bd432a
2 changed files with 49 additions and 26 deletions
|
@ -469,12 +469,11 @@ Zotero.CollectionTreeView.prototype.notify = Zotero.Promise.coroutine(function*
|
||||||
}
|
}
|
||||||
else if(action == 'add')
|
else if(action == 'add')
|
||||||
{
|
{
|
||||||
// Multiple adds not currently supported
|
// skipSelect isn't necessary if more than one object
|
||||||
let id = ids[0];
|
let selectRow = ids.length == 1 && (!extraData[ids[0]] || !extraData[ids[0]].skipSelect);
|
||||||
let selectRow = !extraData[id] || !extraData[id].skipSelect;
|
|
||||||
|
|
||||||
switch (type)
|
for (let id of ids) {
|
||||||
{
|
switch (type) {
|
||||||
case 'collection':
|
case 'collection':
|
||||||
case 'search':
|
case 'search':
|
||||||
yield this._addSortedRow(type, id);
|
yield this._addSortedRow(type, id);
|
||||||
|
@ -491,6 +490,10 @@ Zotero.CollectionTreeView.prototype.notify = Zotero.Promise.coroutine(function*
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'group':
|
case 'group':
|
||||||
|
if (ids.length != 1) {
|
||||||
|
Zotero.logError("WARNING: Multiple groups shouldn't currently be added "
|
||||||
|
+ "together in collectionTreeView::notify()")
|
||||||
|
}
|
||||||
yield this.reload();
|
yield this.reload();
|
||||||
yield this.selectByID(currentTreeRow.id);
|
yield this.selectByID(currentTreeRow.id);
|
||||||
break;
|
break;
|
||||||
|
@ -501,6 +504,7 @@ Zotero.CollectionTreeView.prototype.notify = Zotero.Promise.coroutine(function*
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var deferred = Zotero.Promise.defer();
|
var deferred = Zotero.Promise.defer();
|
||||||
this.addEventListener('select', () => deferred.resolve());
|
this.addEventListener('select', () => deferred.resolve());
|
||||||
|
|
|
@ -215,6 +215,25 @@ describe("Zotero.CollectionTreeView", function() {
|
||||||
assert.equal(aRow, bRow + 1);
|
assert.equal(aRow, bRow + 1);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
it("should add multiple collections", function* () {
|
||||||
|
var col1, col2;
|
||||||
|
yield Zotero.DB.executeTransaction(function* () {
|
||||||
|
col1 = createUnsavedDataObject('collection');
|
||||||
|
col2 = createUnsavedDataObject('collection');
|
||||||
|
yield col1.save();
|
||||||
|
yield col2.save();
|
||||||
|
});
|
||||||
|
|
||||||
|
var aRow = cv.getRowIndexByID("C" + col1.id);
|
||||||
|
var bRow = cv.getRowIndexByID("C" + col2.id);
|
||||||
|
assert.isAbove(aRow, 0);
|
||||||
|
assert.isAbove(bRow, 0);
|
||||||
|
// skipSelect is implied for multiple collections, so library should still be selected
|
||||||
|
assert.equal(cv.selection.currentIndex, 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
it("shouldn't refresh the items list when a collection is modified", function* () {
|
it("shouldn't refresh the items list when a collection is modified", function* () {
|
||||||
var collection = yield createDataObject('collection');
|
var collection = yield createDataObject('collection');
|
||||||
yield waitForItemsLoad(win);
|
yield waitForItemsLoad(win);
|
||||||
|
|
Loading…
Reference in a new issue