Permalink
Browse files

Correct calculation of the value of a menu item

  • Loading branch information...
1 parent b2e3f0a commit 7aaa028c20ab67124d64a7cd200bdee1338c840f @dpp committed Apr 13, 2012
Showing with 17 additions and 7 deletions.
  1. +4 −0 .gitignore
  2. +5 −4 src/main/scala/code/lib/MenuDude.scala
  3. +8 −3 src/main/scala/code/snippet/CurrentSearch.scala
View
@@ -1,3 +1,7 @@
.DS_Store
+*.class
+*~
+target/*
+*.db
testresults/*
*.orig
@@ -54,11 +54,12 @@ object Routing {
object Results extends SearchRoute {
/* /search/[searchId]/results */
- lazy val searchMenu = Menu.param[Search](
+ lazy val menu = Menu.param[Search](
"results", "Results",
- s => Full(s).map(_.trim).filter(_.length > 0).flatMap{println("setting");CurrentSearch(_)},
- s => s.id.toString) / "search" / * / "results"
- lazy val menu = searchMenu >> CalcValue{() => println("getting"); CurrentSearch() } >> TemplateBox(() => Templates(List("results")))
+ s => Full(s).map(_.trim).filter(_.length > 0).flatMap(CurrentSearch(_)),
+ s => s.id.toString) / "search" / * / "results" >>
+ CalcValue(() => Search.menu.currentValue) >>
+ TemplateBox(() => Templates("results" :: Nil))
}
}
@@ -2,6 +2,7 @@ package code.snippet
import net.liftweb._
+import common._
import util._
import Helpers._
import net.liftweb.http.TransientRequestVar
@@ -11,12 +12,16 @@ import code.model.Search
import code.lib.Routing
+object Results {
+ def render = "*" #> CurrentSearch.get.map(_.toString)
+}
+
trait CurrentSearch
-object CurrentSearch extends TransientRequestVar[Box[Search]](None) with CurrentSearch {
+object CurrentSearch extends TransientRequestVar[Box[Search]](Empty) with CurrentSearch {
- def apply() = get
- def apply(maybeId:String) = setIsUnset(Option(Search(UUID.fromString(maybeId))))
+ def apply(): Box[Search] = get
+ def apply(maybeId:String): Box[Search] = setIsUnset(Full(Search(UUID.fromString(maybeId))))
/**
* Gets the current search id

0 comments on commit 7aaa028

Please sign in to comment.