src/main/scala/net/tz/lift/snippet/Panel.scala
changeset 22 94ed9cfdb123
parent 21 641c7190c566
child 33 ee222d6d87d4
equal deleted inserted replaced
21:641c7190c566 22:94ed9cfdb123
    13  * See the License for the specific language governing permissions and
    13  * See the License for the specific language governing permissions and
    14  * limitations under the License.
    14  * limitations under the License.
    15  */
    15  */
    16 package net.tz.lift.snippet
    16 package net.tz.lift.snippet
    17 
    17 
    18 import net.liftweb.mapper.MappedField
    18 import net.liftweb.util.BaseField
    19 import scala.xml.{NodeSeq, Text}
    19 import scala.xml.{NodeSeq, Text}
    20 
    20 
    21 object AttrRow {
    21 object AttrRow {
    22   def apply(name: => NodeSeq, value: => NodeSeq) =  new AttrRow(name, value,
    22   def apply(name: => NodeSeq, value: => NodeSeq) =  new AttrRow(name, value,
    23     "attr-name", "attr-value")
    23     "attr-name", "attr-value")
    24   def apply(f: MappedField[_, _]) = new AttrRow(Text(f.displayName), f.asHtml,
    24   def apply(f: BaseField) = new AttrRow(Text(f.displayName), f.asHtml,
    25     "attr-name", "attr-value")
    25     "attr-name", "attr-value")
    26   def formRow(name: => NodeSeq, input: => NodeSeq) = new AttrRow(name, input,
    26   def formRow(name: => NodeSeq, input: => NodeSeq) = new AttrRow(name, input,
    27     "form-name", "form-value")
    27     "form-name", "form-value")
    28   def submitRow(button: => NodeSeq) = new SpanRow(button)
    28   def submitRow(button: => NodeSeq) = new SpanRow(button)
    29 }
    29 }
    40   override def apply(): NodeSeq = <tr><td colspan="2">{value}</td></tr>
    40   override def apply(): NodeSeq = <tr><td colspan="2">{value}</td></tr>
    41 }
    41 }
    42 
    42 
    43 object Panel {
    43 object Panel {
    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[BaseField]) =
    46     new Panel(fields.map(AttrRow(_)))
    46     new Panel(fields.map(AttrRow(_)))
    47 }
    47 }
    48 
    48 
    49 class Panel(attrs: => Iterable[AttrRow]) extends CssTr {
    49 class Panel(attrs: => Iterable[AttrRow]) extends CssTr {
    50   def apply(in: NodeSeq): NodeSeq = <table>{attrs.map(_())}</table>
    50   def apply(in: NodeSeq): NodeSeq = <table>{attrs.map(_())}</table>