Fix selection of new items
This commit is contained in:
parent
2bd246e2ea
commit
31af26af08
|
@ -2050,6 +2050,7 @@ var ZoteroPane = new function()
|
|||
var self = this;
|
||||
var deferred = Zotero.Promise.defer();
|
||||
this.collectionsView.addEventListener('load', function () {
|
||||
Zotero.spawn(function* () {
|
||||
try {
|
||||
self.addEventListener('itemsLoaded', function () {
|
||||
Zotero.spawn(function* () {
|
||||
|
@ -2087,6 +2088,7 @@ var ZoteroPane = new function()
|
|||
catch (e) {
|
||||
deferred.reject(e);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
// open Zotero pane
|
||||
|
@ -3069,15 +3071,27 @@ var ZoteroPane = new function()
|
|||
}
|
||||
|
||||
/**
|
||||
* @return {Promise}
|
||||
* @return {Promise<Integer|null|false>} - The id of the new note in non-popup mode, null in
|
||||
* popup mode (where a note isn't created immediately), or false if library isn't editable
|
||||
*/
|
||||
this.newNote = Zotero.Promise.coroutine(function* (popup, parentKey, text, citeURI) {
|
||||
if (!this.canEdit()) {
|
||||
this.displayCannotEditLibraryMessage();
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (popup) {
|
||||
// TODO: _text_
|
||||
var c = this.getSelectedCollection();
|
||||
if (c) {
|
||||
this.openNoteWindow(null, c.id, parentKey);
|
||||
}
|
||||
else {
|
||||
this.openNoteWindow(null, null, parentKey);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!popup) {
|
||||
if (!text) {
|
||||
text = '';
|
||||
}
|
||||
|
@ -3092,7 +3106,6 @@ var ZoteroPane = new function()
|
|||
var item = new Zotero.Item('note');
|
||||
item.libraryID = this.getSelectedLibraryID();
|
||||
item.setNote(text);
|
||||
Zotero.debug(parentKey);
|
||||
if (parentKey) {
|
||||
item.parentKey = parentKey;
|
||||
}
|
||||
|
@ -3105,18 +3118,8 @@ var ZoteroPane = new function()
|
|||
yield this.selectItem(itemID);
|
||||
|
||||
document.getElementById('zotero-note-editor').focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: _text_
|
||||
var c = this.getSelectedCollection();
|
||||
if (c) {
|
||||
this.openNoteWindow(null, c.id, parentKey);
|
||||
}
|
||||
else {
|
||||
this.openNoteWindow(null, null, parentKey);
|
||||
}
|
||||
}
|
||||
|
||||
return itemID;
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -35,6 +35,16 @@ describe("ZoteroPane", function() {
|
|||
})
|
||||
});
|
||||
|
||||
describe("#newNote()", function () {
|
||||
it("should create a child note and select it", function* () {
|
||||
var item = yield createDataObject('item');
|
||||
var noteID = yield zp.newNote(false, item.key, "Test");
|
||||
var selected = zp.itemsView.getSelectedItems(true);
|
||||
assert.lengthOf(selected, 1);
|
||||
assert.equal(selected, noteID);
|
||||
})
|
||||
})
|
||||
|
||||
describe("#itemSelected()", function () {
|
||||
it.skip("should update the item count", function* () {
|
||||
var collection = new Zotero.Collection;
|
||||
|
|
Loading…
Reference in New Issue
Block a user