Fix Everything search after annotations
And replace ancient 'annotation' search condition with 'annotationText'/'annotationComment'
This commit is contained in:
parent
3bd5a96560
commit
ead8c6bb45
4 changed files with 47 additions and 5 deletions
|
@ -328,7 +328,8 @@ Zotero.Search.prototype.addCondition = function (condition, operator, value, req
|
||||||
this.addCondition('creator', operator, part.text, false);
|
this.addCondition('creator', operator, part.text, false);
|
||||||
|
|
||||||
if (condition == 'quicksearch-everything') {
|
if (condition == 'quicksearch-everything') {
|
||||||
this.addCondition('annotation', operator, part.text, false);
|
this.addCondition('annotationText', operator, part.text, false);
|
||||||
|
this.addCondition('annotationComment', operator, part.text, false);
|
||||||
|
|
||||||
if (part.inQuotes) {
|
if (part.inQuotes) {
|
||||||
this.addCondition('fulltextContent', operator, part.text, false);
|
this.addCondition('fulltextContent', operator, part.text, false);
|
||||||
|
|
|
@ -490,13 +490,23 @@ Zotero.SearchConditions = new function(){
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: 'annotation',
|
name: 'annotationText',
|
||||||
operators: {
|
operators: {
|
||||||
contains: true,
|
contains: true,
|
||||||
doesNotContain: true
|
doesNotContain: true
|
||||||
},
|
},
|
||||||
table: 'annotations',
|
table: 'itemAnnotations',
|
||||||
field: 'text'
|
field: 'text',
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: 'annotationComment',
|
||||||
|
operators: {
|
||||||
|
contains: true,
|
||||||
|
doesNotContain: true
|
||||||
|
},
|
||||||
|
table: 'itemAnnotations',
|
||||||
|
field: 'comment',
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -789,7 +789,8 @@ searchConditions.dateModified = Date Modified
|
||||||
searchConditions.fulltextContent = Attachment Content
|
searchConditions.fulltextContent = Attachment Content
|
||||||
searchConditions.programmingLanguage = Programming Language
|
searchConditions.programmingLanguage = Programming Language
|
||||||
searchConditions.fileTypeID = Attachment File Type
|
searchConditions.fileTypeID = Attachment File Type
|
||||||
searchConditions.annotation = Annotation
|
searchConditions.annotationText = Annotation Text
|
||||||
|
searchConditions.annotationComment = Annotation Comment
|
||||||
|
|
||||||
fulltext.indexState.indexed = Indexed
|
fulltext.indexState.indexed = Indexed
|
||||||
fulltext.indexState.unavailable = Unknown
|
fulltext.indexState.unavailable = Unknown
|
||||||
|
|
|
@ -360,6 +360,36 @@ describe("Zotero.Search", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("annotationText", function () {
|
||||||
|
it("should return matches for annotation text", async function () {
|
||||||
|
var attachment = await importPDFAttachment();
|
||||||
|
var annotation = await createAnnotation('highlight', attachment);
|
||||||
|
var str = annotation.annotationText.substr(0, 7);
|
||||||
|
|
||||||
|
var s = new Zotero.Search();
|
||||||
|
s.libraryID = userLibraryID;
|
||||||
|
s.addCondition('joinMode', 'any');
|
||||||
|
s.addCondition('annotationText', 'contains', str);
|
||||||
|
var matches = await s.search();
|
||||||
|
assert.sameMembers(matches, [annotation.id]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("annotationComment", function () {
|
||||||
|
it("should return matches for annotation comment", async function () {
|
||||||
|
var attachment = await importPDFAttachment();
|
||||||
|
var annotation = await createAnnotation('note', attachment);
|
||||||
|
var str = annotation.annotationComment.substr(0, 7);
|
||||||
|
|
||||||
|
var s = new Zotero.Search();
|
||||||
|
s.libraryID = userLibraryID;
|
||||||
|
s.addCondition('joinMode', 'any');
|
||||||
|
s.addCondition('annotationComment', 'contains', str);
|
||||||
|
var matches = await s.search();
|
||||||
|
assert.sameMembers(matches, [annotation.id]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("fulltextWord", function () {
|
describe("fulltextWord", function () {
|
||||||
it("should return matches with full-text conditions", function* () {
|
it("should return matches with full-text conditions", function* () {
|
||||||
let s = new Zotero.Search();
|
let s = new Zotero.Search();
|
||||||
|
|
Loading…
Add table
Reference in a new issue