lila/app/views/team/bits.scala

84 lines
2.4 KiB
Scala
Raw Normal View History

2019-04-17 08:52:54 -06:00
package views.html.team
2019-02-10 18:43:30 -07:00
import scala.util.chaining._
2019-02-10 18:43:30 -07:00
import lila.api.Context
import lila.app.templating.Environment._
import lila.app.ui.ScalatagsTemplate._
import controllers.routes
object bits {
2020-02-10 09:25:44 -07:00
import trans.team._
2020-04-26 00:17:45 -06:00
def link(teamId: lila.team.Team.ID): Frag =
2020-04-26 12:25:40 -06:00
a(href := routes.Team.show(teamId))(teamIdToName(teamId))
def link(team: lila.team.Team): Frag =
a(href := routes.Team.show(team.id))(team.name)
2020-04-26 00:17:45 -06:00
2020-05-05 22:11:15 -06:00
def menu(currentTab: Option[String])(implicit ctx: Context) =
~currentTab pipe { tab =>
st.nav(cls := "page-menu__menu subnav")(
(ctx.teamNbRequests > 0) option
a(cls := tab.active("requests"), href := routes.Team.requests)(
2020-05-05 22:11:15 -06:00
xJoinRequests.pluralSame(ctx.teamNbRequests)
),
ctx.isAuth option
a(cls := tab.active("mine"), href := routes.Team.mine)(
2020-05-05 22:11:15 -06:00
myTeams()
),
ctx.isAuth option
a(cls := tab.active("leader"), href := routes.Team.leader)(
2020-05-05 22:11:15 -06:00
"Leader teams"
),
a(cls := tab.active("all"), href := routes.Team.all())(
allTeams()
),
2020-05-05 22:11:15 -06:00
ctx.isAuth option
a(cls := tab.active("form"), href := routes.Team.form)(
2020-05-05 22:11:15 -06:00
newTeam()
)
)
}
2019-02-10 18:43:30 -07:00
2021-02-16 08:21:31 -07:00
private[team] def teamTr(t: lila.team.Team)(implicit ctx: Context) = {
val isMine = myTeam(t.id)
2020-05-05 22:11:15 -06:00
tr(cls := "paginated")(
td(cls := "subject")(
a(
dataIcon := "",
2020-05-05 22:11:15 -06:00
cls := List(
"team-name text" -> true,
2021-02-16 08:21:31 -07:00
"mine" -> isMine
2020-05-05 22:11:15 -06:00
),
href := routes.Team.show(t.id)
2021-02-16 08:21:31 -07:00
)(
t.name,
ctx.userId.exists(t.leaders.contains) option em("leader")
),
2020-05-05 22:11:15 -06:00
shorten(t.description, 200)
),
td(cls := "info")(
2021-02-16 08:21:31 -07:00
p(nbMembers.plural(t.nbMembers, t.nbMembers.localize)),
isMine option form(action := routes.Team.quit(t.id), method := "post")(
submitButton(cls := "button button-empty button-red button-thin confirm team__quit")(quitTeam.txt())
)
2020-05-05 22:11:15 -06:00
)
2019-02-10 18:43:30 -07:00
)
2021-02-16 08:21:31 -07:00
}
2019-02-10 18:43:30 -07:00
2020-04-25 18:52:13 -06:00
private[team] def layout(
title: String,
openGraph: Option[lila.app.ui.OpenGraph] = None,
moreJs: Frag = emptyFrag
2020-04-28 12:24:49 -06:00
)(body: Frag)(implicit ctx: Context) =
2019-02-11 08:04:31 -07:00
views.html.base.layout(
2019-02-10 18:43:30 -07:00
title = title,
2019-04-21 08:33:50 -06:00
moreCss = cssTag("team"),
2020-04-25 18:52:13 -06:00
moreJs = frag(infiniteScrollTag, moreJs),
2019-04-11 04:05:52 -06:00
openGraph = openGraph
2019-02-10 18:43:30 -07:00
)(body)
}