Search by specific creator type (#2353)

Author, editor, or book author.
This commit is contained in:
Abe Jellinek 2022-02-16 22:06:14 -08:00 committed by GitHub
parent 924d29ff7e
commit 91cdc5610b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 0 deletions

View file

@ -1332,6 +1332,15 @@ Zotero.Search.prototype._buildQuery = Zotero.Promise.coroutine(function* () {
openParens++;
break;
case 'author':
case 'editor':
case 'bookAuthor': {
let creatorTypeID = Zotero.CreatorTypes.getID(condition.name);
condSQL += `creatorTypeID = ${creatorTypeID} AND creatorID IN (SELECT creatorID FROM creators WHERE `;
openParens++;
break;
}
case 'childNote':
condSQL += "itemID IN (SELECT parentItemID FROM "
+ "itemNotes WHERE ";

View file

@ -399,6 +399,42 @@ Zotero.SearchConditions = new function(){
special: true
},
{
name: 'author',
operators: {
is: true,
isNot: true,
contains: true,
doesNotContain: true
},
table: 'itemCreators',
field: "TRIM(firstName || ' ' || lastName)"
},
{
name: 'editor',
operators: {
is: true,
isNot: true,
contains: true,
doesNotContain: true
},
table: 'itemCreators',
field: "TRIM(firstName || ' ' || lastName)"
},
{
name: 'bookAuthor',
operators: {
is: true,
isNot: true,
contains: true,
doesNotContain: true
},
table: 'itemCreators',
field: "TRIM(firstName || ' ' || lastName)"
},
{
name: 'field',
operators: {
@ -669,6 +705,9 @@ Zotero.SearchConditions = new function(){
if (str == 'itemType') {
str = 'itemTypeID';
}
else if (['author', 'editor', 'bookAuthor'].includes(str)) {
return Zotero.CreatorTypes.getLocalizedString(str);
}
try {
return Zotero.getString('searchConditions.' + str)