diff --git a/src/UI/AddSeries/AddSeriesView.js b/src/UI/AddSeries/AddSeriesView.js index 5fd2c8d9f..04132578a 100644 --- a/src/UI/AddSeries/AddSeriesView.js +++ b/src/UI/AddSeries/AddSeriesView.js @@ -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})); + } } }); }); diff --git a/src/UI/AddSeries/ErrorView.js b/src/UI/AddSeries/ErrorView.js new file mode 100644 index 000000000..71b899165 --- /dev/null +++ b/src/UI/AddSeries/ErrorView.js @@ -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; + } + + }); + }); diff --git a/src/UI/AddSeries/ErrorViewTemplate.hbs b/src/UI/AddSeries/ErrorViewTemplate.hbs new file mode 100644 index 000000000..862d5e058 --- /dev/null +++ b/src/UI/AddSeries/ErrorViewTemplate.hbs @@ -0,0 +1,7 @@ +
+

+ There was an error searching for '{{term}}'. +

+ + If the series title contains non-alphanumeric characters try removing them, otherwise try your search again later. +