fix add existing series.

This commit is contained in:
Keivan Beigi 2013-09-18 12:43:37 -07:00
parent 42efef0bb2
commit 904061c2f0
3 changed files with 17 additions and 11 deletions

View File

@ -1,14 +1,17 @@
{{#if folder.path}} {{#if folder.path}}
<div class="row well unmapped-folder-path"> <div class="row unmapped-folder-path">
<div class="span11"> <div class="span11">
{{folder.path}} {{folder.path}}
</div> </div>
</div> </div>{{/if}}
{{/if}}
<div class="row x-search-bar"> <div class="row x-search-bar">
<div class="input-prepend nz-input-large add-series-search span11"> <div class="input-prepend nz-input-large add-series-search span11">
<i class="add-on icon-search"/> <i class="add-on icon-search"/>
{{#if folder}}
<input type="text" class="input-block-level x-series-search" value="{{folder.name}}">
{{else}}
<input type="text" class="input-block-level x-series-search" placeholder="Start typing the name of series you want to add ..."> <input type="text" class="input-block-level x-series-search" placeholder="Start typing the name of series you want to add ...">
{{/if}}
</div> </div>
</div> </div>
<div class="row"> <div class="row">
@ -17,4 +20,4 @@
<div class="btn btn-block text-center new-series-loadmore x-load-more" style="display: none;"> <div class="btn btn-block text-center new-series-loadmore x-load-more" style="display: none;">
<i class="icon-angle-down"/> <i class="icon-angle-down"/>
more more
</div> </div>{{debug}}

View File

@ -60,10 +60,10 @@ define(
_onLoadMore: function () { _onLoadMore: function () {
var showingAll = this.resultCollectionView.showMore(); var showingAll = this.resultCollectionView.showMore();
this.ui.searchBar.show();
if (showingAll) { if (showingAll) {
this.ui.loadMore.hide(); this.ui.loadMore.hide();
this.ui.searchBar.show();
} }
}, },
@ -94,7 +94,7 @@ define(
this.collection.reset(); this.collection.reset();
if (!options.term || options.term === this.collection.term) { if (!options.term || options.term === this.collection.term) {
return; return $.Deferred().resolve();
} }
this.searchResult.show(new LoadingView()); this.searchResult.show(new LoadingView());
@ -102,6 +102,8 @@ define(
this.currentSearchPromise = this.collection.fetch({ this.currentSearchPromise = this.collection.fetch({
data: { term: options.term } data: { term: options.term }
}); });
return this.currentSearchPromise;
}, },
_showResults: function () { _showResults: function () {

View File

@ -20,17 +20,18 @@ define(
}, },
_showAndSearch: function (index) { _showAndSearch: function (index) {
var self = this;
var model = this.collection.at(index); var model = this.collection.at(index);
if (model) { if (model) {
var self = this;
var currentIndex = index; var currentIndex = index;
var folderName = model.get('folder').name; var folderName = model.get('folder').name;
this.addItemView(model, this.getItemView(), index); this.addItemView(model, this.getItemView(), index);
$.when(this.children.findByModel(model).search({term: folderName})).then(function () { this.children.findByModel(model)
self._showAndSearch(currentIndex + 1); .search({term: folderName})
}); .always((function () {
self._showAndSearch(currentIndex + 1);
}));
} }
}, },