44 def apply(attrs: Iterable[AttrRow]) = new Panel(attrs) |
44 def apply(attrs: Iterable[AttrRow]) = new Panel(attrs) |
45 def fromFields(fields: Iterable[MappedField[_,_]]) = |
45 def fromFields(fields: Iterable[MappedField[_,_]]) = |
46 new Panel(fields.map(AttrRow(_))) |
46 new Panel(fields.map(AttrRow(_))) |
47 } |
47 } |
48 |
48 |
49 class Panel(attrs: => Iterable[AttrRow]) extends Function1[NodeSeq, NodeSeq] |
49 class Panel(attrs: => Iterable[AttrRow]) extends CssTr { |
50 { |
|
51 def apply(in: NodeSeq): NodeSeq = <table>{attrs.map(_())}</table> |
50 def apply(in: NodeSeq): NodeSeq = <table>{attrs.map(_())}</table> |
52 def &(other: Function1[NodeSeq, NodeSeq]) = new Function1[NodeSeq, NodeSeq] { |
51 def &(other: Function1[NodeSeq, NodeSeq]) = new Function1[NodeSeq, NodeSeq] { |
53 def apply(in: NodeSeq): NodeSeq = List(Panel.this, other) flatMap (_(in)) |
52 def apply(in: NodeSeq): NodeSeq = List(Panel.this, other) flatMap (_(in)) |
54 } |
53 } |
55 } |
54 } |
56 |
55 |
|
56 import net.liftweb.http.TemplateFinder |
|
57 import net.liftweb.util.Helpers._ // CSS transforms |
|
58 |
|
59 /** |
|
60 * A panel using template in <code>/templates-hidden/panel</code> for |
|
61 * values rendering. |
|
62 */ |
|
63 class TplPanel(cells: List[(NodeSeq, NodeSeq)]) extends CssTr { |
|
64 def apply(in: NodeSeq): NodeSeq = TemplateFinder.findAnyTemplate( |
|
65 List("templates-hidden", "panel")) map { xml => |
|
66 (".row *" #> cells.map { r => |
|
67 ".n *" #> r._1 & |
|
68 ".v *" #> r._2 |
|
69 })(xml) |
|
70 } openOr NodeSeq.Empty |
|
71 } |
|
72 |
57 // vim: set ts=2 sw=2 et: |
73 // vim: set ts=2 sw=2 et: |