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 self = this;
|
||||||
var deferred = Zotero.Promise.defer();
|
var deferred = Zotero.Promise.defer();
|
||||||
this.collectionsView.addEventListener('load', function () {
|
this.collectionsView.addEventListener('load', function () {
|
||||||
|
Zotero.spawn(function* () {
|
||||||
try {
|
try {
|
||||||
self.addEventListener('itemsLoaded', function () {
|
self.addEventListener('itemsLoaded', function () {
|
||||||
Zotero.spawn(function* () {
|
Zotero.spawn(function* () {
|
||||||
|
@ -2087,6 +2088,7 @@ var ZoteroPane = new function()
|
||||||
catch (e) {
|
catch (e) {
|
||||||
deferred.reject(e);
|
deferred.reject(e);
|
||||||
}
|
}
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
// open Zotero pane
|
// 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) {
|
this.newNote = Zotero.Promise.coroutine(function* (popup, parentKey, text, citeURI) {
|
||||||
if (!this.canEdit()) {
|
if (!this.canEdit()) {
|
||||||
this.displayCannotEditLibraryMessage();
|
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) {
|
if (!text) {
|
||||||
text = '';
|
text = '';
|
||||||
}
|
}
|
||||||
|
@ -3092,7 +3106,6 @@ var ZoteroPane = new function()
|
||||||
var item = new Zotero.Item('note');
|
var item = new Zotero.Item('note');
|
||||||
item.libraryID = this.getSelectedLibraryID();
|
item.libraryID = this.getSelectedLibraryID();
|
||||||
item.setNote(text);
|
item.setNote(text);
|
||||||
Zotero.debug(parentKey);
|
|
||||||
if (parentKey) {
|
if (parentKey) {
|
||||||
item.parentKey = parentKey;
|
item.parentKey = parentKey;
|
||||||
}
|
}
|
||||||
|
@ -3105,18 +3118,8 @@ var ZoteroPane = new function()
|
||||||
yield this.selectItem(itemID);
|
yield this.selectItem(itemID);
|
||||||
|
|
||||||
document.getElementById('zotero-note-editor').focus();
|
document.getElementById('zotero-note-editor').focus();
|
||||||
}
|
|
||||||
else
|
return itemID;
|
||||||
{
|
|
||||||
// TODO: _text_
|
|
||||||
var c = this.getSelectedCollection();
|
|
||||||
if (c) {
|
|
||||||
this.openNoteWindow(null, c.id, parentKey);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.openNoteWindow(null, null, parentKey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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 () {
|
describe("#itemSelected()", function () {
|
||||||
it.skip("should update the item count", function* () {
|
it.skip("should update the item count", function* () {
|
||||||
var collection = new Zotero.Collection;
|
var collection = new Zotero.Collection;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user