Fixed: Show an error message after a failed Trakt search

pull/132/head
Mark McDowall 10 years ago
parent e6494ba229
commit c159a378a0

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

@ -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;
}
});
});

@ -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>
Loading…
Cancel
Save