summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiovane <giovaneliberato@gmail.com>2015-11-11 16:45:51 -0200
committerGiovane <giovaneliberato@gmail.com>2015-11-11 16:45:51 -0200
commit8da08bab434d7ee713399edb4cba147caa6354f7 (patch)
tree883cf8386884ae600376fab089a602873e24e3b3
parent3ef5fb5dd004edcf23d55b2533c37ffafec828f4 (diff)
Propagate search query to noMailAvailablePane component #503
-rw-r--r--web-ui/app/js/dispatchers/middle_pane_dispatcher.js2
-rw-r--r--web-ui/app/js/mail_view/ui/no_mails_available_pane.js3
-rw-r--r--web-ui/app/js/services/mail_service.js2
-rw-r--r--web-ui/test/spec/dispatchers/middle_pane_dispatchers.spec.js10
4 files changed, 12 insertions, 5 deletions
diff --git a/web-ui/app/js/dispatchers/middle_pane_dispatcher.js b/web-ui/app/js/dispatchers/middle_pane_dispatcher.js
index 7a53b769..12222aec 100644
--- a/web-ui/app/js/dispatchers/middle_pane_dispatcher.js
+++ b/web-ui/app/js/dispatchers/middle_pane_dispatcher.js
@@ -57,7 +57,7 @@ define(['flight/lib/component', 'page/events', 'helpers/triggering', 'mail_view/
NoMailsAvailablePane.teardownAll();
} else {
var child_div = this.createChildDiv(this.attr.noMailsAvailablePane);
- NoMailsAvailablePane.attachTo(child_div, {tag: data.tag});
+ NoMailsAvailablePane.attachTo(child_div, {tag: data.tag, forSearch: data.forSearch});
}
};
diff --git a/web-ui/app/js/mail_view/ui/no_mails_available_pane.js b/web-ui/app/js/mail_view/ui/no_mails_available_pane.js
index 32b6bc19..624020be 100644
--- a/web-ui/app/js/mail_view/ui/no_mails_available_pane.js
+++ b/web-ui/app/js/mail_view/ui/no_mails_available_pane.js
@@ -30,7 +30,8 @@ define(
function noMailsAvailablePane() {
this.defaultAttrs({
- tag: null
+ tag: null,
+ forSearch: ''
});
this.render = function() {
diff --git a/web-ui/app/js/services/mail_service.js b/web-ui/app/js/services/mail_service.js
index 04194964..3dae9df8 100644
--- a/web-ui/app/js/services/mail_service.js
+++ b/web-ui/app/js/services/mail_service.js
@@ -222,7 +222,7 @@ define(
monitoredAjax(this, url, { dataType: 'json' })
.done(function (data) {
this.attr.numPages = Math.ceil(data.stats.total / this.attr.pageSize);
- this.trigger(document, events.mails.available, _.merge(_.merge({tag: this.attr.currentTag }), this.parseMails(data)));
+ this.trigger(document, events.mails.available, _.merge(_.merge({tag: this.attr.currentTag, forSearch: this.attr.lastQuery }), this.parseMails(data)));
}.bind(this))
.fail(function () {
this.trigger(document, events.ui.userAlerts.displayMessage, { message: i18n('Could not fetch messages') });
diff --git a/web-ui/test/spec/dispatchers/middle_pane_dispatchers.spec.js b/web-ui/test/spec/dispatchers/middle_pane_dispatchers.spec.js
index 3d55cbaa..220ad96d 100644
--- a/web-ui/test/spec/dispatchers/middle_pane_dispatchers.spec.js
+++ b/web-ui/test/spec/dispatchers/middle_pane_dispatchers.spec.js
@@ -24,10 +24,10 @@ describeComponent('dispatchers/middle_pane_dispatcher', function () {
});
describe('no emails available', function () {
- var noMailsAvailablePane;
+ var noMailsAvailablePane, attachToSpy;
beforeEach(function () {
noMailsAvailablePane = require('mail_view/ui/no_mails_available_pane');
- spyOn(noMailsAvailablePane, 'attachTo');
+ attachToSpy = spyOn(noMailsAvailablePane, 'attachTo');
spyOn(noMailsAvailablePane, 'teardownAll');
});
@@ -47,5 +47,11 @@ describeComponent('dispatchers/middle_pane_dispatcher', function () {
expect(noMailsAvailablePane.teardownAll).toHaveBeenCalled();
});
+ it('should give search information to component', function () {
+ var mail_list = { mails: [], tag: 'all', forSearch: 'search'};
+ this.component.trigger(document, Pixelated.events.mails.available, mail_list);
+
+ expect(attachToSpy.calls.mostRecent().args[1]).toEqual({tag: 'all', forSearch: 'search'});
+ });
});
});