mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
search: Display invalid operand suggestion for has operator.
`has` operator uses predefined categories. This commit displays an invalid operand message if the operand does not fall in to any of these categories and the `has` operator is not at the last. e.g. `has:abc sender:abc@zulipchat.com` will have `invalid abc operand for has operator, sent by abc@zulipchat.com` as a prefix for all its suggestions.
This commit is contained in:
committed by
Tim Abbott
parent
2945062b79
commit
1b07b32ec1
@@ -553,6 +553,7 @@ Filter.operator_to_prefix = function (operator, negated) {
|
||||
case 'near':
|
||||
return verb + 'messages around';
|
||||
|
||||
// Note: We hack around using this in "describe" below.
|
||||
case 'has':
|
||||
return verb + 'messages with one or more';
|
||||
|
||||
@@ -623,6 +624,14 @@ function describe_unescaped(operators) {
|
||||
}
|
||||
return operand + ' messages';
|
||||
}
|
||||
if (canonicalized_operator ==='has') {
|
||||
// search_suggestion.get_suggestions takes care that this message will
|
||||
// only be shown if the `has` operator is not at the last.
|
||||
var valid_has_operands = ['image', 'images', 'link', 'links', 'attachment', 'attachments'];
|
||||
if (valid_has_operands.indexOf(operand) === -1) {
|
||||
return 'invalid ' + operand + ' operand for has operator';
|
||||
}
|
||||
}
|
||||
var prefix_for_operator = Filter.operator_to_prefix(canonicalized_operator,
|
||||
elem.negated);
|
||||
if (prefix_for_operator !== '') {
|
||||
|
||||
Reference in New Issue
Block a user