src/main/scala/net/tz/lift/model/OptionalFieldDisplay.scala
author Tomas Zeman <tzeman@volny.cz>
Tue, 23 Apr 2013 10:36:04 +0200
changeset 108 ef4e3e0ef83f
parent 15 995184977e9b
permissions -rw-r--r--
84a94fa29a67504b Task/Project notifications
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15
995184977e9b a3e3bd30f0d19526 Contact UI
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
     1
/*
995184977e9b a3e3bd30f0d19526 Contact UI
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
     2
 * Copyright 2011 Tomas Zeman <tzeman@volny.cz>
995184977e9b a3e3bd30f0d19526 Contact UI
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
     3
 *
995184977e9b a3e3bd30f0d19526 Contact UI
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
     4
 * Licensed under the Apache License, Version 2.0 (the "License");
995184977e9b a3e3bd30f0d19526 Contact UI
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
     5
 * you may not use this file except in compliance with the License.
995184977e9b a3e3bd30f0d19526 Contact UI
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
     6
 * You may obtain a copy of the License at
995184977e9b a3e3bd30f0d19526 Contact UI
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
     7
 *
995184977e9b a3e3bd30f0d19526 Contact UI
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
     8
 *     http://www.apache.org/licenses/LICENSE-2.0
995184977e9b a3e3bd30f0d19526 Contact UI
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
     9
 *
995184977e9b a3e3bd30f0d19526 Contact UI
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    10
 * Unless required by applicable law or agreed to in writing, software
995184977e9b a3e3bd30f0d19526 Contact UI
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    11
 * distributed under the License is distributed on an "AS IS" BASIS,
995184977e9b a3e3bd30f0d19526 Contact UI
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
995184977e9b a3e3bd30f0d19526 Contact UI
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    13
 * See the License for the specific language governing permissions and
995184977e9b a3e3bd30f0d19526 Contact UI
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    14
 * limitations under the License.
995184977e9b a3e3bd30f0d19526 Contact UI
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    15
 */
995184977e9b a3e3bd30f0d19526 Contact UI
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    16
package net.tz.lift.model
995184977e9b a3e3bd30f0d19526 Contact UI
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    17
995184977e9b a3e3bd30f0d19526 Contact UI
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    18
import net.liftweb.record.OptionalTypedField
995184977e9b a3e3bd30f0d19526 Contact UI
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    19
import scala.xml.Text
995184977e9b a3e3bd30f0d19526 Contact UI
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    20
995184977e9b a3e3bd30f0d19526 Contact UI
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    21
/**
995184977e9b a3e3bd30f0d19526 Contact UI
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    22
 * Nice display of optional fields, ie. w/o Some(...)
995184977e9b a3e3bd30f0d19526 Contact UI
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    23
 */
995184977e9b a3e3bd30f0d19526 Contact UI
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    24
trait OptionalFieldDisplay { self: OptionalTypedField[_] =>
995184977e9b a3e3bd30f0d19526 Contact UI
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    25
  override def asHtml = Text(get map { _.toString } getOrElse "")
995184977e9b a3e3bd30f0d19526 Contact UI
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    26
}
995184977e9b a3e3bd30f0d19526 Contact UI
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    27
995184977e9b a3e3bd30f0d19526 Contact UI
Tomas Zeman <tzeman@volny.cz>
parents:
diff changeset
    28
// vim: set ts=2 sw=2 et: