Fixed: Show an error message after a failed Trakt search

This commit is contained in:
Mark McDowall 2014-11-01 22:46:45 -07:00
parent e6494ba229
commit c159a378a0
3 changed files with 43 additions and 3 deletions

View File

@ -1,15 +1,16 @@
'use strict'; 'use strict';
define( define(
[ [
'underscore',
'vent', 'vent',
'marionette', 'marionette',
'AddSeries/AddSeriesCollection', 'AddSeries/AddSeriesCollection',
'AddSeries/SearchResultCollectionView', 'AddSeries/SearchResultCollectionView',
'AddSeries/EmptyView', 'AddSeries/EmptyView',
'AddSeries/NotFoundView', 'AddSeries/NotFoundView',
'Shared/LoadingView', 'AddSeries/ErrorView',
'underscore' 'Shared/LoadingView'
], function (vent, Marionette, AddSeriesCollection, SearchResultCollectionView, EmptyView, NotFoundView, LoadingView, _) { ], function (_, vent, Marionette, AddSeriesCollection, SearchResultCollectionView, EmptyView, NotFoundView, ErrorView, LoadingView) {
return Marionette.Layout.extend({ return Marionette.Layout.extend({
template: 'AddSeries/AddSeriesViewTemplate', template: 'AddSeries/AddSeriesViewTemplate',
@ -83,6 +84,7 @@ define(
}, },
search: function (options) { search: function (options) {
var self = this;
this.collection.reset(); this.collection.reset();
@ -96,6 +98,10 @@ define(
data: { term: options.term } data: { term: options.term }
}); });
this.currentSearchPromise.fail(function () {
self._showError();
});
return this.currentSearchPromise; return this.currentSearchPromise;
}, },
@ -155,6 +161,13 @@ define(
else { else {
this._clearResults(); this._clearResults();
} }
},
_showError: function () {
if (!this.isClosed) {
this.ui.searchBar.show();
this.searchResult.show(new ErrorView({term: this.collection.term}));
}
} }
}); });
}); });

View File

@ -0,0 +1,20 @@
'use strict';
define(
[
'marionette'
], function (Marionette) {
return Marionette.CompositeView.extend({
template: 'AddSeries/ErrorViewTemplate',
initialize: function (options) {
this.options = options;
},
templateHelpers: function () {
return this.options;
}
});
});

View File

@ -0,0 +1,7 @@
<div class="text-center col-md-12">
<h3>
There was an error searching for '{{term}}'.
</h3>
If the series title contains non-alphanumeric characters try removing them, otherwise try your search again later.
</div>