Fix various issues with note pane tags box
This commit is contained in:
parent
3de5ed1332
commit
3179a2f0e7
|
@ -416,6 +416,12 @@
|
||||||
var x = this.boxObject.screenX;
|
var x = this.boxObject.screenX;
|
||||||
var y = this.boxObject.screenY;
|
var y = this.boxObject.screenY;
|
||||||
this.id('tagsPopup').openPopupAtScreen(x, y, false);
|
this.id('tagsPopup').openPopupAtScreen(x, y, false);
|
||||||
|
|
||||||
|
// If editable and no existing tags, open new empty row
|
||||||
|
var tagsBox = this.id('tags');
|
||||||
|
if (tagsBox.mode == 'edit' && tagsBox.count == 0) {
|
||||||
|
this.id('tags').new();
|
||||||
|
}
|
||||||
]]></body>
|
]]></body>
|
||||||
</method>
|
</method>
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._item = val;
|
this._item = val;
|
||||||
|
this._lastTabIndex = false;
|
||||||
this.reload();
|
this.reload();
|
||||||
]]>
|
]]>
|
||||||
</setter>
|
</setter>
|
||||||
|
@ -95,13 +96,15 @@
|
||||||
|
|
||||||
if (this.item) {
|
if (this.item) {
|
||||||
var tags = this.item.getTags();
|
var tags = this.item.getTags();
|
||||||
if (tags) {
|
|
||||||
for(var i = 0; i < tags.length; i++)
|
// Sort tags alphabetically
|
||||||
{
|
var collation = Zotero.getLocaleCollation();
|
||||||
r = r + tags[i].tag + ", ";
|
tags.sort((a, b) => collation.compareString(1, a.tag, b.tag));
|
||||||
}
|
|
||||||
r = r.substr(0,r.length-2);
|
for (let i = 0; i < tags.length; i++) {
|
||||||
|
r = r + tags[i].tag + ", ";
|
||||||
}
|
}
|
||||||
|
r = r.substr(0,r.length-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
|
@ -725,6 +728,14 @@
|
||||||
<method name="new">
|
<method name="new">
|
||||||
<body>
|
<body>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
|
var rowsElement = this.id('tagRows');
|
||||||
|
var rows = rowsElement.childNodes;
|
||||||
|
|
||||||
|
// Don't add new row if there already is one
|
||||||
|
if (rows.length > this.count) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var row = this.addDynamicRow();
|
var row = this.addDynamicRow();
|
||||||
row.firstChild.nextSibling.click();
|
row.firstChild.nextSibling.click();
|
||||||
return row;
|
return row;
|
||||||
|
|
54
test/tests/noteeditorTest.js
Normal file
54
test/tests/noteeditorTest.js
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
describe("Note Editor", function () {
|
||||||
|
var win, zp;
|
||||||
|
|
||||||
|
before(function* () {
|
||||||
|
win = yield loadZoteroPane();
|
||||||
|
zp = win.ZoteroPane;
|
||||||
|
});
|
||||||
|
|
||||||
|
after(function () {
|
||||||
|
win.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("Tags box", function () {
|
||||||
|
it("should open new row for editing if no tags", function* () {
|
||||||
|
var note = yield createDataObject('item', { itemType: 'note' });
|
||||||
|
var noteEditor = win.document.getElementById('zotero-note-editor');
|
||||||
|
var linksBox = noteEditor._id('links-box');
|
||||||
|
linksBox.tagsClick();
|
||||||
|
var tagsBox = linksBox.id('tagsPopup').firstChild;
|
||||||
|
var tagRows = tagsBox.id('tagRows');
|
||||||
|
assert.equal(tagRows.childNodes.length, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should only open one new row for editing", function* () {
|
||||||
|
var note = yield createDataObject('item', { itemType: 'note' });
|
||||||
|
var noteEditor = win.document.getElementById('zotero-note-editor');
|
||||||
|
var linksBox = noteEditor._id('links-box');
|
||||||
|
linksBox.tagsClick();
|
||||||
|
// Close and reopen
|
||||||
|
linksBox.id('tagsPopup').hidePopup();
|
||||||
|
linksBox.tagsClick();
|
||||||
|
|
||||||
|
// Should still be only one empty row
|
||||||
|
var tagsBox = linksBox.id('tagsPopup').firstChild;
|
||||||
|
var tagRows = tagsBox.id('tagRows');
|
||||||
|
assert.equal(tagRows.childNodes.length, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should show tags in alphabetical order", function* () {
|
||||||
|
var note = new Zotero.Item('note');
|
||||||
|
note.addTag('B');
|
||||||
|
yield note.saveTx();
|
||||||
|
note.addTag('A');
|
||||||
|
note.addTag('C');
|
||||||
|
yield note.saveTx();
|
||||||
|
|
||||||
|
var noteEditor = win.document.getElementById('zotero-note-editor');
|
||||||
|
var linksBox = noteEditor._id('links-box');
|
||||||
|
assert.equal(linksBox.id('tags').summary, "A, B, C");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user