Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update to make it work with Lift 2.3-RC4

  • Loading branch information...
commit a32cd12d66461bfa308e73c8397aae71e3b1e655 1 parent 35b6112
@jeppenejsum authored
View
2  project/build/LiftProject.scala
@@ -1,7 +1,7 @@
import sbt._
class LiftProject(info: ProjectInfo) extends DefaultWebProject(info) {
- val liftVersion = "2.3-SNAPSHOT"
+ val liftVersion = "2.3-RC4"
// uncomment the following if you want to use the snapshot repo
val scalatoolsSnapshot = ScalaToolsSnapshots
View
4 src/main/scala/bootstrap/liftweb/Boot.scala
@@ -42,7 +42,9 @@ class Boot {
def m1:Menu = Menu.i("Home") / "index" >> User.AddUserMenusAfter
def m2:Menu = Menu.i("MenuTest") / "menutest"
- def menu:List[Menu] = m1::m2:: code.snippet.Orders.menus:::code.snippet.LineItems.menus
+ def menu:List[Menu] = m1::m2::
+ code.snippet.LineItems.menus:::
+ code.snippet.Orders.menus
// Build SiteMap
def sitemap = SiteMap(menu:_*)
View
26 src/main/scala/code/snippet/Order.scala
@@ -15,23 +15,23 @@ case class LineItem(order: Order, id: String)
object Orders {
def parse(id: String): Box[Order] = {
println("Parse order "+id)
- if (id == "notfound") Empty else Full(Order(id))
+ if (id == "notfound" || id == "new") Empty else Full(Order(id))
}
def encode(o: Order): String = o.id;
- def menus: List[Menu] = List(editOp, listOp, createOp, lineItemsOp)
+ def menus: List[Menu] = List(createOp, editOp, listOp, lineItemsOp, createLineItemOp)
// This works :-)
def listOp = Menu.i("listorder") / "orders" >> Loc.Template(() => <span>List orders</span>)
- // This cannot find the snippet (my guess is because it's a Loc[Unit] and the snippet only works for Loc[Order])
- def createOp = Menu.i("neworder") / "orders" / "new" >> Loc.CalcValue(() => Full(Order("newly created"))) >> Loc.Template(() => <lift:OrderSnippet.edit/>)
+ // To make this work, parse needs to return Empty when called with new
+ def createOp = Menu.i("neworder") / "orders" / "new"
- // Parse never seems be called
- def editOp = Menu.param[Order]("editorder", "editorder", parse _, encode _) / "orders" / * >> Loc.ValueTemplate({o:Box[Order] => <lift:OrderSnippet.edit/>})
+ def editOp = Menu.param[Order]("editorder", "editorder", parse _, encode _) / "orders" / * >> Loc.ValueTemplate({o:Box[Order] => <lift:OrderSnippets.edit/>})
- // Never seems to call parse
- def lineItemsOp = Menu.param[Order]("lineitems", "lineitems", parse _, encode _) / "orders" / * / "lineitems" >> Loc.ValueTemplate({o:Box[Order] => <lift:OrderSnippet.lineItems/>})
+ def lineItemsOp = Menu.param[Order]("lineitems", "lineitems", parse _, encode _) / "orders" / * / "lineitems" >> Loc.ValueTemplate({o:Box[Order] => <lift:OrderSnippets.lineItems/>})
+
+ def createLineItemOp = Menu.param[Order]("newlineitem", "newlineitem", parse _, encode _) / "orders" / * / "lineitems" / "new" >> Loc.ValueTemplate({o:Box[Order] => <span>New line item for order {o.open_!.id}</span>})
}
object LineItems {
@@ -39,7 +39,7 @@ object LineItems {
println("Parse line "+ids)
val order = Order(ids.head)
val li = LineItem(order, ids.drop(1).head)
- Full((order, li))
+ if (ids(1) == "notfound") Empty else Full((order, li))
}
def encode(item: (Order,LineItem)): List[String] = {
@@ -47,18 +47,14 @@ object LineItems {
List(order.id, li.id)
}
- def menus: List[Menu] = List(/*createOp, */editOp);
-
- // Cannot figure out correct type signature here:
- // Loc probably needs to be (Order, LineItem), but only Order can be looked up, LineItem will be created
- //def createOp = Menu.param[Order]("newlineitem") / "orders" / * / "lineitems" / "new" >> Loc.CalcValue(() => Full(....) >> Loc.Template(() => <lift:LineItemSnippets.edit/>)
+ def menus: List[Menu] = List(editOp);
// Parse never seems to be called
def editOp = Menu.params[(Order, LineItem)]("editlineitem", "editlineitem", parse _, encode _) / "orders" / * / "lineitems" / * >> Loc.ValueTemplate({o:Box[(Order,LineItem)] => <lift:LineItemSnippets.edit/>})
}
class OrderSnippets(order: Order) {
- def edit(in: NodeSeq): NodeSeq = <span>Edit order with id {order.id}</span>
+ def edit(in: NodeSeq): NodeSeq = <span>Edit order with id {order.id} Create new line item <a href={Orders.createLineItemOp.calcHref(order)}>here</a></span>
def lineItems(in: NodeSeq): NodeSeq = <span>Showing line items for order with id {order.id}</span>
}
View
1  src/main/webapp/orders/new.html
@@ -0,0 +1 @@
+<span>The new order template</span>
Please sign in to comment.
Something went wrong with that request. Please try again.