Match parent attachments for annotation tags

Expose annotation tags in tag selector and match parent attachments when
filtering/searching

This also fixes searching for annotation text or comments when using
Everything quick search.

This is temporary until we display annotations in the items list
directly.
This commit is contained in:
Dan Stillman 2022-08-16 20:49:07 -04:00
parent eca253d4a3
commit c3ee588bfe
4 changed files with 115 additions and 24 deletions

View file

@ -218,6 +218,23 @@ describe("Zotero.Search", function() {
});
});
describe("tag", function () {
// TEMP
it("should match parent attachments for annotation tags", async function () {
var attachment = await importPDFAttachment();
var annotation = await createAnnotation('highlight', attachment);
var tag = Zotero.Utilities.randomString();
annotation.addTag(tag);
await annotation.saveTx();
var s = new Zotero.Search();
s.libraryID = userLibraryID;
s.addCondition('tag', 'is', tag);
var matches = await s.search();
assert.sameMembers(matches, [attachment.id]);
});
});
describe("dateAdded", function () {
it("should handle 'today'", async function () {
var item = await createDataObject('item');
@ -371,7 +388,8 @@ describe("Zotero.Search", function() {
s.addCondition('joinMode', 'any');
s.addCondition('annotationText', 'contains', str);
var matches = await s.search();
assert.sameMembers(matches, [annotation.id]);
// TEMP: Match parent attachment
assert.sameMembers(matches, [attachment.id]);
});
});
@ -386,7 +404,8 @@ describe("Zotero.Search", function() {
s.addCondition('joinMode', 'any');
s.addCondition('annotationComment', 'contains', str);
var matches = await s.search();
assert.sameMembers(matches, [annotation.id]);
// TEMP: Match parent attachment
assert.sameMembers(matches, [attachment.id]);
});
});
@ -525,6 +544,40 @@ describe("Zotero.Search", function() {
assert.notInclude(matches, item2.id);
});
});
describe("Quick search", function () {
describe("All Fields & Tags", function () {
it("should match parent attachment for annotation tag", async function () {
var attachment = await importPDFAttachment();
var annotation = await createAnnotation('highlight', attachment);
var tag = Zotero.Utilities.randomString();
annotation.addTag(tag);
await annotation.saveTx();
var s = new Zotero.Search();
s.libraryID = userLibraryID;
s.addCondition('quicksearch-fields', 'contains', tag);
var matches = await s.search();
// TEMP: Match parent attachment
assert.sameMembers(matches, [attachment.id]);
});
})
describe("Everything", function () {
it("should match parent attachment for annotation comment", async function () {
var attachment = await importPDFAttachment();
var annotation = await createAnnotation('highlight', attachment);
var comment = annotation.annotationComment;
var s = new Zotero.Search();
s.libraryID = userLibraryID;
s.addCondition('quicksearch-everything', 'contains', comment);
var matches = await s.search();
// TEMP: Match parent attachment
assert.sameMembers(matches, [attachment.id]);
});
});
});
});
});