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