lila/app/templating/TeamHelper.scala

30 lines
777 B
Scala
Raw Normal View History

2013-04-03 15:43:21 -06:00
package lila.app
package templating
import scalatags.Text.all.Tag
2013-04-03 15:43:21 -06:00
import controllers.routes
2013-12-27 15:12:20 -07:00
import lila.api.Context
2019-04-09 03:13:16 -06:00
import lila.app.ui.ScalatagsTemplate._
2013-12-27 15:12:20 -07:00
2019-12-04 23:52:53 -07:00
trait TeamHelper { self: HasEnv =>
2013-04-03 15:43:21 -06:00
2013-04-09 12:58:34 -06:00
def myTeam(teamId: String)(implicit ctx: Context): Boolean =
ctx.userId.?? { env.team.api.syncBelongsTo(teamId, _) }
2013-04-03 15:43:21 -06:00
2020-05-30 11:20:40 -06:00
def teamIdToName(id: String): String = env.team.getTeamName(id).getOrElse(id)
2013-04-03 15:43:21 -06:00
def teamLink(id: String, withIcon: Boolean = true): Tag =
teamLink(id, teamIdToName(id), withIcon)
def teamLink(id: String, name: Frag, withIcon: Boolean): Tag =
2019-12-13 07:30:20 -07:00
a(
href := routes.Team.show(id),
dataIcon := withIcon.option(""),
2019-12-13 07:30:20 -07:00
cls := withIcon option "text"
)(name)
2013-04-03 15:43:21 -06:00
2013-04-09 12:58:34 -06:00
def teamForumUrl(id: String) = routes.ForumCateg.show("team-" + id)
}