lila/app/views/relation/actions.scala

79 lines
2.4 KiB
Scala
Raw Normal View History

2018-12-04 04:47:02 -07:00
package views.html.relation
import lila.api.Context
import lila.app.templating.Environment._
2018-12-04 06:16:52 -07:00
import lila.app.ui.ScalatagsTemplate._
2018-12-04 04:47:02 -07:00
import controllers.routes
object actions {
private val dataHoverText = data("hover-text")
2018-12-04 04:47:02 -07:00
def apply(
2019-12-13 07:30:20 -07:00
userId: lila.user.User.ID,
relation: Option[lila.relation.Relation],
followable: Boolean,
blocked: Boolean,
signup: Boolean = false
2018-12-04 04:47:02 -07:00
)(implicit ctx: Context) =
2019-04-03 21:32:39 -06:00
div(cls := "relation-actions btn-rack")(
2018-12-04 04:47:02 -07:00
ctx.userId map { myId =>
(myId != userId) ?? frag(
!blocked option frag(
a(
titleOrText(trans.challenge.challengeToPlay.txt()),
href := s"${routes.Lobby.home}?user=$userId#friend",
2019-03-30 03:37:50 -06:00
cls := "btn-rack__btn",
dataIcon := ""
2018-12-04 04:47:02 -07:00
),
a(
2019-07-25 06:53:24 -06:00
titleOrText(trans.composeMessage.txt()),
2020-01-27 16:04:22 -07:00
href := routes.Msg.convo(userId),
2019-03-30 03:37:50 -06:00
cls := "btn-rack__btn",
dataIcon := ""
2018-12-04 04:47:02 -07:00
)
),
relation match {
2019-12-13 07:30:20 -07:00
case None =>
frag(
followable && !blocked option a(
cls := "btn-rack__btn relation-button",
href := routes.Relation.follow(userId),
titleOrText(trans.follow.txt()),
dataIcon := ""
2019-12-13 07:30:20 -07:00
),
a(
cls := "btn-rack__btn relation-button",
href := routes.Relation.block(userId),
titleOrText(trans.block.txt()),
dataIcon := ""
2019-12-13 07:30:20 -07:00
)
)
case Some(true) =>
2018-12-04 04:47:02 -07:00
a(
dataIcon := "",
2019-12-13 07:30:20 -07:00
cls := "btn-rack__btn relation-button text hover-text",
href := routes.Relation.unfollow(userId),
titleOrText(trans.following.txt()),
dataHoverText := trans.unfollow.txt()
)
case Some(false) =>
a(
dataIcon := "",
2019-12-13 07:30:20 -07:00
cls := "btn-rack__btn relation-button text hover-text",
href := routes.Relation.unblock(userId),
titleOrText(trans.blocked.txt()),
dataHoverText := trans.unblock.txt()
)
2018-12-04 04:47:02 -07:00
}
)
} getOrElse {
signup option frag(
trans.youNeedAnAccountToDoThat(),
a(href := routes.Auth.login, cls := "signup")(trans.signUp())
2018-12-04 04:47:02 -07:00
)
}
)
}