2013-04-03 15:43:21 -06:00
|
|
|
package lila.app
|
|
|
|
package templating
|
|
|
|
|
2020-04-05 09:01:12 -06:00
|
|
|
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 =
|
2020-04-08 19:33:05 -06:00
|
|
|
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
|
|
|
|
2020-04-05 09:01:12 -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("f"),
|
|
|
|
cls := withIcon option "text"
|
2020-04-05 09:01:12 -06:00
|
|
|
)(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)
|
|
|
|
}
|