Support has:attachment/has:image/has:link searches.

This commit finishes up support for has:* searches by adding
the front-end pieces, specifically the part that "has" operators
will not be applied locally.  It also implements basic
descriptions for search suggestions and canonicalization
of operands from plural to singular.

(imported from commit a3285bc33d06d76b5a2b403ebcdd911b4cc03980)
This commit is contained in:
Steve Howell
2014-03-05 13:19:21 -05:00
parent 82a935080d
commit 8efe4c0a1b
2 changed files with 29 additions and 1 deletions

View File

@@ -144,6 +144,11 @@ Filter.canonicalize_term = function (opts) {
operator = Filter.canonicalize_operator(operator);
switch (operator) {
case 'has':
// images -> image, etc.
operand = operand.replace(/s$/, '');
break;
case 'stream':
operand = stream_data.get_name(operand);
break;
@@ -318,7 +323,7 @@ Filter.prototype = {
},
can_apply_locally: function Filter_can_apply_locally() {
return ! this.is_search();
return (!this.is_search()) && (!this.has_operator('has'));
},
_canonicalize_operators: function Filter__canonicalize_operators(operators_mixed_case) {
@@ -367,6 +372,9 @@ Filter.operator_to_prefix = function (operator, negated) {
case 'near':
return verb + 'messages around';
case 'has':
return verb + 'messages with one or more';
case 'id':
return verb + 'message ID';