commit a01f2765e4cc5387c1380011059c17e84e1c8d91
parent 249f9c6495ae717da9768972311d9e98b1aaf102
Author: Dan Stillman <dstillman@zotero.org>
Date: Mon, 23 Jan 2017 08:25:12 -0500
Fix quick search and quick format bar (broken in 9b247ebba7c)
As evidenced by majorly failing tests
Diffstat:
2 files changed, 9 insertions(+), 17 deletions(-)
diff --git a/chrome/content/zotero/xpcom/data/search.js b/chrome/content/zotero/xpcom/data/search.js
@@ -302,8 +302,8 @@ Zotero.Search.prototype.addCondition = function (condition, operator, value, req
for (let part of parts) {
this.addCondition('blockStart');
- // If search string is 8 characters, see if this is a item key
- if (operator == 'contains' && part.text.length == 8) {
+ // Allow searching for exact object key
+ if (operator == 'contains' && Zotero.Utilities.isValidObjectKey(part.text)) {
this.addCondition('key', 'is', part.text, false);
}
@@ -935,7 +935,7 @@ Zotero.Search.prototype._buildQuery = Zotero.Promise.coroutine(function* () {
// For conditions with an inline filter using 'is'/'isNot', combine with last condition
// if the same
if (lastCondition
- && name == lastCondition.name
+ && (!lastCondition.alias || name == lastCondition.alias)
&& condition.operator.startsWith('is')
&& condition.operator == lastCondition.operator
&& conditionData.inlineFilter) {
@@ -947,7 +947,7 @@ Zotero.Search.prototype._buildQuery = Zotero.Promise.coroutine(function* () {
}
lastCondition = {
- name,
+ name: conditionData.name,
alias: conditionData.name != name ? name : false,
table: conditionData.table,
field: conditionData.field,
@@ -1491,11 +1491,10 @@ Zotero.Search.prototype._buildQuery = Zotero.Promise.coroutine(function* () {
if (val) {
values.push(val);
}
- else {
- Zotero.logError(`${val} is not a valid `
- + `'${condition.field}' value -- skipping`);
- continue;
- }
+ }
+
+ if (!values.length) {
+ continue;
}
condSQL += values.length > 1
diff --git a/chrome/content/zotero/xpcom/data/searchConditions.js b/chrome/content/zotero/xpcom/data/searchConditions.js
@@ -452,14 +452,7 @@ Zotero.SearchConditions = new function(){
special: true,
noLoad: true,
inlineFilter: function (val) {
- try {
- val = Zotero.DataObjectUtilities.checkKey(val);
- if (val) return `'${val}'`;
- }
- catch (e) {
- Zotero.logError(e);
- }
- return false;
+ return Zotero.Utilities.isValidObjectKey(val) ? val : false;
}
},