Fix search
This commit is contained in:
parent
00653e9420
commit
09f27d47be
|
@ -50,6 +50,8 @@ var sortCallback = function(repo1, repo2) {
|
|||
|
||||
|
||||
var Controller = Ember.Controller.extend({
|
||||
ajax: Ember.inject.service(),
|
||||
|
||||
actions: {
|
||||
activate: function(name) {
|
||||
return this.activate(name);
|
||||
|
@ -174,7 +176,7 @@ var Controller = Ember.Controller.extend({
|
|||
viewSearch(phrase) {
|
||||
this.set('search', phrase);
|
||||
this.set('isLoaded', false);
|
||||
Repo.search(this.store, phrase).then( (reposRecordArray) => {
|
||||
Repo.search(this.store, this.get('ajax'), phrase).then( (reposRecordArray) => {
|
||||
this.set('isLoaded', true);
|
||||
this.set('_repos', reposRecordArray);
|
||||
});
|
||||
|
|
|
@ -140,17 +140,20 @@ Repo.reopenClass
|
|||
|
||||
promise
|
||||
|
||||
search: (store, query) ->
|
||||
promise = store.query('repo', search: query, orderBy: 'name')
|
||||
search: (store, ajax, query) ->
|
||||
queryString = $.param(search: query, orderBy: 'name', limit: 5)
|
||||
promise = ajax.ajax("/repos?#{queryString}", 'get')
|
||||
result = Ember.ArrayProxy.create(content: [])
|
||||
|
||||
promise.then ->
|
||||
result.pushObjects(promise.get('content').toArray())
|
||||
result.set('isLoaded', true)
|
||||
promise.then (data, status, xhr) ->
|
||||
promises = data.repos.map (repoData) ->
|
||||
store.findRecord('repo', repoData.id).then (record) ->
|
||||
result.pushObject(record)
|
||||
result.set('isLoaded', true)
|
||||
record
|
||||
|
||||
result
|
||||
|
||||
promise
|
||||
Ember.RSVP.allSettled(promises).then ->
|
||||
result
|
||||
|
||||
withLastBuild: (store) ->
|
||||
repos = store.filter('repo', {}, (build) ->
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
`import TravisRoute from 'travis/routes/basic'`
|
||||
|
||||
Route = TravisRoute.extend()
|
||||
Route = TravisRoute.extend
|
||||
setupController: (controller)->
|
||||
@container.lookup('controller:repos').activate('owned')
|
||||
|
||||
`export default Route`
|
||||
|
|
|
@ -14,6 +14,6 @@ Route = TravisRoute.extend
|
|||
|
||||
setupController: (controller)->
|
||||
# TODO: this is redundant with repositories and recent routes
|
||||
@container.lookup('controller:repos').activate('owned')
|
||||
#@container.lookup('controller:repos').activate('owned')
|
||||
|
||||
`export default Route`
|
||||
|
|
|
@ -11,6 +11,7 @@ Route = TravisRoute.extend
|
|||
@render 'repo', into: 'main'
|
||||
|
||||
setupController: (controller, model) ->
|
||||
@container.lookup('controller:repos').activate('owned')
|
||||
# TODO: if repo is just a data hash with id and slug load it
|
||||
# as incomplete record
|
||||
model = @get('store').find('repo', model.id) if model && !model.get
|
||||
|
|
Loading…
Reference in New Issue
Block a user