display incomplete profile name
This commit is contained in:
parent
3f457b39f4
commit
fa81c4fd8b
|
@ -9,7 +9,10 @@ case class Profile(
|
|||
firstName: Option[String] = None,
|
||||
lastName: Option[String] = None) {
|
||||
|
||||
def nonEmptyRealName = (ne(firstName) |@| ne(lastName)) apply { _ + " " + _ }
|
||||
def nonEmptyRealName = List(ne(firstName), ne(lastName)).flatten match {
|
||||
case Nil ⇒ none
|
||||
case names ⇒ (names mkString " ").some
|
||||
}
|
||||
|
||||
def countryInfo = country flatMap Countries.info
|
||||
|
||||
|
@ -17,10 +20,6 @@ case class Profile(
|
|||
|
||||
def nonEmptyBio = ne(bio)
|
||||
|
||||
def nonEmpty = List(
|
||||
firstName, lastName, bio, country
|
||||
).flatten.nonEmpty option this
|
||||
|
||||
private def ne(str: Option[String]) = str filter (_.nonEmpty)
|
||||
}
|
||||
|
||||
|
|
|
@ -68,10 +68,7 @@ object UserRepo {
|
|||
|
||||
def setProfile(id: ID, profile: Profile): Funit = {
|
||||
import tube.profileTube
|
||||
profile.nonEmpty match {
|
||||
case Some(p) => $update($select(id), $set("profile" -> p))
|
||||
case None => $update($select(id), $unset("profile"))
|
||||
}
|
||||
$update($select(id), $set("profile" -> profile))
|
||||
}
|
||||
|
||||
val enabledSelect = Json.obj("enabled" -> true)
|
||||
|
|
Loading…
Reference in a new issue