lila/app/views/team/admin.scala

118 lines
3.5 KiB
Scala
Raw Normal View History

2019-04-17 08:52:54 -06:00
package views.html.team
2020-09-22 02:42:04 -06:00
import controllers.routes
import play.api.data.Form
2019-04-17 08:52:54 -06:00
import lila.api.Context
import lila.app.templating.Environment._
import lila.app.ui.ScalatagsTemplate._
object admin {
2020-02-10 09:25:44 -07:00
import trans.team._
def leaders(t: lila.team.Team, form: Form[_])(implicit ctx: Context) = {
val title = s"${t.name}${trans.team.teamLeaders.txt()}"
views.html.base.layout(
title = title,
moreCss = frag(cssTag("team"), cssTag("tagify")),
2020-09-12 10:54:21 -06:00
moreJs = jsModule("team.admin")
) {
2019-04-17 08:52:54 -06:00
main(cls := "page-menu page-small")(
bits.menu(none),
div(cls := "page-menu__content box box-pad")(
h1(title),
2020-07-05 08:43:59 -06:00
p(
"Only invite leaders that you fully trust. Team leaders can kick members and other leaders out of the team."
),
postForm(cls := "leaders", action := routes.Team.leaders(t.id))(
2020-04-30 11:48:39 -06:00
form3.group(form("leaders"), frag(usersWhoCanManageThisTeam()))(
form3.textarea(_)(rows := 2)
),
form3.actions(
a(href := routes.Team.show(t.id))(trans.cancel()),
form3.submit(trans.save())
)
2019-04-17 08:52:54 -06:00
)
)
)
}
}
def kick(t: lila.team.Team, userIds: Iterable[lila.user.User.ID])(implicit ctx: Context) = {
2020-04-28 10:13:01 -06:00
val title = s"${t.name}${kickSomeone.txt()}"
2019-04-17 08:52:54 -06:00
bits.layout(title = title) {
main(cls := "page-menu page-small")(
bits.menu(none),
div(cls := "page-menu__content box box-pad")(
h1(title),
2020-02-10 09:25:44 -07:00
p(whoToKick()),
2019-12-13 07:30:20 -07:00
br,
br,
2019-08-02 01:54:15 -06:00
postForm(cls := "kick", action := routes.Team.kick(t.id))(
2019-04-17 08:52:54 -06:00
userIds.toList.sorted.map { userId =>
button(name := "userId", cls := "button button-empty button-no-upper confirm", value := userId)(
usernameOrId(userId)
)
}
)
)
)
}
}
2020-05-05 22:11:15 -06:00
def pmAll(t: lila.team.Team, form: Form[_], tours: List[lila.tournament.Tournament])(implicit
ctx: Context
) = {
2020-04-30 11:48:39 -06:00
val title = s"${t.name}${messageAllMembers.txt()}"
views.html.base.layout(
title = title,
moreCss = cssTag("team"),
2020-09-04 08:10:30 -06:00
moreJs = embedJsUnsafeLoadThen("""
2020-09-22 02:42:04 -06:00
$('.copy-url-button').on('click', function(e) {
$('#form3-message').val($('#form3-message').val() + $(e.target).data('copyurl') + '\n')
})""")
) {
main(cls := "page-menu page-small")(
bits.menu(none),
div(cls := "page-menu__content box box-pad")(
h1(title),
2020-09-22 02:42:04 -06:00
p(messageAllMembersLongDescription()),
tours.nonEmpty option div(cls := "tournaments")(
2020-04-30 11:48:39 -06:00
p(youWayWantToLinkOneOfTheseTournaments()),
p(
ul(
tours.map { t =>
li(
tournamentLink(t),
" ",
momentFromNow(t.startsAt),
2020-04-06 02:43:33 -06:00
" ",
a(
dataIcon := "",
cls := "text copy-url-button",
data.copyurl := s"${netConfig.domain}${routes.Tournament.show(t.id).url}"
2020-04-06 04:13:33 -06:00
)
)
}
)
),
br
),
postForm(cls := "form3", action := routes.Team.pmAllSubmit(t.id))(
form3.group(form("message"), trans.message())(form3.textarea(_)(rows := 10)),
form3.actions(
a(href := routes.Team.show(t.slug))(trans.cancel()),
form3.submit(trans.send())
)
)
)
)
}
}
2019-04-17 08:52:54 -06:00
}