Make "subject" an alias for the "topic" operator.

(imported from commit 52c11ff48a286533906b99ed62839e6ae3e35b17)
This commit is contained in:
Jessica McKellar
2013-07-16 16:52:02 -04:00
parent 1defcf5718
commit 849b49b22d
7 changed files with 14 additions and 14 deletions

View File

@@ -39,7 +39,7 @@ $(function () {
var operators = event.filter.operators(); var operators = event.filter.operators();
var stream_operands = event.filter.operands('stream'); var stream_operands = event.filter.operands('stream');
var subject_operands = event.filter.operands('subject'); var subject_operands = event.filter.operands('topic');
var reported_operators; var reported_operators;
if (operators.length === 1) { if (operators.length === 1) {
reported_operators = operators[0][0]; reported_operators = operators[0][0];

View File

@@ -10,7 +10,7 @@ function Filter(operators) {
} }
} }
var canonical_operators = {"from": "sender"}; var canonical_operators = {"from": "sender", "subject": "topic"};
exports.canonicalize_operator = function (operator) { exports.canonicalize_operator = function (operator) {
operator = operator.toLowerCase(); operator = operator.toLowerCase();
@@ -166,7 +166,7 @@ Filter.prototype = {
} }
break; break;
case 'subject': case 'topic':
if ((message.type !== 'stream') || if ((message.type !== 'stream') ||
(message.subject.toLowerCase() !== operand)) (message.subject.toLowerCase() !== operand))
return false; return false;
@@ -294,7 +294,7 @@ exports.set_compose_defaults = function (opts) {
// Set the stream, subject, and/or PM recipient if they are // Set the stream, subject, and/or PM recipient if they are
// uniquely specified in the narrow view. // uniquely specified in the narrow view.
$.each(['stream', 'subject'], function (idx, key) { $.each(['stream', 'topic'], function (idx, key) {
if (single[key] !== undefined) if (single[key] !== undefined)
opts[key] = single[key]; opts[key] = single[key];
}); });
@@ -497,7 +497,7 @@ exports.by_subject = function (target_id, opts) {
opts = $.extend({}, {then_select_id: target_id}, opts); opts = $.extend({}, {then_select_id: target_id}, opts);
exports.activate([ exports.activate([
['stream', original.stream], ['stream', original.stream],
['subject', original.subject] ['topic', original.subject]
], opts); ], opts);
}; };
@@ -656,7 +656,7 @@ exports.narrowed_by_reply = function () {
current_filter.operands("pm-with").length === 1) || current_filter.operands("pm-with").length === 1) ||
(operators.length === 2 && (operators.length === 2 &&
current_filter.operands("stream").length === 1 && current_filter.operands("stream").length === 1 &&
current_filter.operands("subject").length === 1)); current_filter.operands("topic").length === 1));
}; };
return exports; return exports;

View File

@@ -60,8 +60,8 @@ function describe(operators) {
case 'stream': case 'stream':
return 'Narrow to stream ' + operand; return 'Narrow to stream ' + operand;
case 'subject': case 'topic':
return 'Narrow to subject ' + operand; return 'Narrow to topic ' + operand;
case 'sender': case 'sender':
return 'Narrow to sender ' + operand; return 'Narrow to sender ' + operand;

View File

@@ -190,7 +190,7 @@ exports.update_streams_sidebar = function () {
} }
var op_stream = narrow.filter().operands('stream'); var op_stream = narrow.filter().operands('stream');
var op_subject = narrow.filter().operands('subject'); var op_subject = narrow.filter().operands('topic');
var subject; var subject;
if (op_stream.length !== 0) { if (op_stream.length !== 0) {
if (op_subject.length !== 0) { if (op_subject.length !== 0) {
@@ -281,7 +281,7 @@ $(function () {
var op_stream = event.filter.operands('stream'); var op_stream = event.filter.operands('stream');
if (op_stream.length !== 0 && subs.is_subscribed(op_stream[0])) { if (op_stream.length !== 0 && subs.is_subscribed(op_stream[0])) {
var stream_li = get_filter_li('stream', op_stream[0]); var stream_li = get_filter_li('stream', op_stream[0]);
var op_subject = event.filter.operands('subject'); var op_subject = event.filter.operands('topic');
var subject; var subject;
if (op_subject.length !== 0) { if (op_subject.length !== 0) {
subject = op_subject[0]; subject = op_subject[0];

View File

@@ -68,9 +68,9 @@ function make_tab_data() {
// Third breadcrumb item for stream-subject naarrows // Third breadcrumb item for stream-subject naarrows
if (filter.has_operator("stream") && if (filter.has_operator("stream") &&
filter.has_operator("subject")) { filter.has_operator("topic")) {
stream = filter.operands("stream")[0]; stream = filter.operands("stream")[0];
var subject = filter.operands("subject")[0]; var subject = filter.operands("topic")[0];
hashed = hashchange.operators_to_hash(ops.slice(0, 2)); hashed = hashchange.operators_to_hash(ops.slice(0, 2));
tabs.push(make_tab(subject, hashed, null)); tabs.push(make_tab(subject, hashed, null));

View File

@@ -1205,7 +1205,7 @@ $(function () {
var subject = $(e.target).parents('li').attr('data-name'); var subject = $(e.target).parents('li').attr('data-name');
narrow.activate([['stream', stream], narrow.activate([['stream', stream],
['subject', subject]], ['topic', subject]],
{select_first_unread: true, trigger: 'sidebar'}); {select_first_unread: true, trigger: 'sidebar'});
e.preventDefault(); e.preventDefault();

View File

@@ -702,7 +702,7 @@ class NarrowBuilder(object):
recipient = get_recipient(Recipient.STREAM, type_id=stream.id) recipient = get_recipient(Recipient.STREAM, type_id=stream.id)
return self.pQ(recipient=recipient) return self.pQ(recipient=recipient)
def by_subject(self, operand): def by_topic(self, operand):
return self.pQ(subject__iexact=operand) return self.pQ(subject__iexact=operand)
def by_sender(self, operand): def by_sender(self, operand):