Skip to content

Commit

Permalink
Merge pull request #93 from tyreepace/master
Browse files Browse the repository at this point in the history
Search and go
  • Loading branch information
oldfartdeveloper committed May 20, 2013
2 parents 0d1772b + 8a9e669 commit c2e1be8
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 27 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/app.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ YJ.reopen(
YJ.User.createRecord(name: name, email: email)
)

YJ.searchTerm = Em.Object.create(term: null)
YJ.searchPhrase = ''

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
YJ.TermsIndexController = Ember.ArrayController.extend(
# The place to hold the letter used to filter by the first letter
searchLetter: null
searchPhrase: null
content: []
sortProperties: ['name']
isDefined: null
Expand All @@ -27,16 +28,17 @@ YJ.TermsIndexController = Ember.ArrayController.extend(
)

filtered: (->
noSearch = @get('searchLetter') is null
noSearchLetter = @get('searchLetter') is null
noDefined = @get('isDefined') is null
#noSearchPhrase = @get('searchPhrase') is null
arranged = @get('arrangedContent')
myself = @
arranged.filter (item, index, arranged) ->
if noSearch && noDefined
if noSearchLetter && noDefined
true
else if !noSearch && noDefined
else if !noSearchLetter && noDefined
myself.filterSearchLetter(item)
else if noSearch && !noDefined
else if noSearchLetter && !noDefined
myself.filterIsDefined(item)
else
myself.filterIsDefined(item) && myself.filterSearchLetter(item)
Expand All @@ -48,4 +50,6 @@ YJ.TermsIndexController = Ember.ArrayController.extend(
filterIsDefined: (item) ->
item.get('isDefined') == @get('isDefined')

computeSearchResults: ->
@set('content', YJ.Term.find({search: @get('searchPhrase')}))
)
2 changes: 0 additions & 2 deletions app/assets/javascripts/router.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ YJ.Router.map ->
path: "/"
@resource 'terms', ->
@route "index"
@route "search"
path: '/search/:search_term'
@resource 'term'
path: '/:term_id'
, ->
Expand Down
10 changes: 6 additions & 4 deletions app/assets/javascripts/routes/route.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ Ember.Route.reopen(
# else
# me.transitionTo('home')

toSearch: ((event) ->
searchTerm = YJ.get('searchTerm').term
console.log("Search is " + searchTerm)
@transitionTo('terms.search', searchTerm)
toSearch: ( ->
searchPhrase = YJ.get('searchPhrase')
console.log("Search is " + searchPhrase)
controller = @controllerFor('termsIndex')
controller.set('searchPhrase', searchPhrase)
controller.computeSearchResults()
)

alert: (alert) ->
Expand Down
15 changes: 0 additions & 15 deletions app/assets/javascripts/routes/terms/terms_search_route.js.coffee

This file was deleted.

2 changes: 1 addition & 1 deletion app/assets/javascripts/templates/navbar.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{{#linkTo terms class="brand"}} YourJargon {{/linkTo}}

<form class="navbar-search pull-left">
{{view Ember.TextField valueBinding="YJ.searchTerm.term"}}
{{view Ember.TextField valueBinding="YJ.searchPhrase"}}
</form>

<ul class="nav pull-left">
Expand Down

0 comments on commit c2e1be8

Please sign in to comment.