lila/app/views/streamer/edit.scala

250 lines
9.2 KiB
Scala
Raw Normal View History

2019-04-16 09:09:06 -06:00
package views.html.streamer
import controllers.routes
2019-04-16 09:09:06 -06:00
import play.api.data.Form
import lila.api.Context
import lila.app.templating.Environment._
import lila.app.ui.ScalatagsTemplate._
import lila.common.String.html.richText
2020-02-09 13:37:40 -07:00
object edit extends Context.ToLang {
import trans.streamer._
2019-04-16 09:09:06 -06:00
def apply(
2019-12-13 07:30:20 -07:00
s: lila.streamer.Streamer.WithUserAndStream,
form: Form[_],
2021-01-07 08:37:07 -07:00
modData: Option[((List[lila.mod.Modlog], List[lila.user.Note]), List[lila.streamer.Streamer])]
2019-04-16 09:09:06 -06:00
)(implicit ctx: Context) = {
views.html.base.layout(
2020-02-09 13:37:40 -07:00
title = s"${s.user.titleUsername} ${lichessStreamer.txt()}",
2020-09-13 04:05:05 -06:00
moreCss = cssTag("streamer.form")
2019-04-16 09:09:06 -06:00
) {
2019-12-13 07:30:20 -07:00
main(cls := "page-menu")(
bits.menu("edit", s.withoutStream.some),
div(cls := "page-menu__content box streamer-edit")(
if (ctx.is(s.user))
div(cls := "streamer-header")(
2019-04-16 09:09:06 -06:00
if (s.streamer.hasPicture)
2021-06-10 11:55:30 -06:00
a(
targetBlank,
cls := "picture-edit",
href := routes.Streamer.picture,
title := changePicture.txt()
)(
2019-12-13 07:30:20 -07:00
bits.pic(s.streamer, s.user)
)
else
div(cls := "picture-create")(
ctx.is(s.user) option
a(targetBlank, cls := "button", href := routes.Streamer.picture)(
2020-02-09 13:37:40 -07:00
uploadPicture()
2019-12-13 07:30:20 -07:00
)
),
2019-04-16 09:09:06 -06:00
div(cls := "overview")(
h1(s.streamer.name),
2020-02-09 13:37:40 -07:00
bits.rules
2019-04-16 09:09:06 -06:00
)
)
else views.html.streamer.header(s),
2019-12-13 07:30:20 -07:00
div(cls := "box__pad") {
val granted = s.streamer.approval.granted
frag(
(ctx.is(s.user) && s.streamer.listed.value) option div(
cls := s"status is${granted ?? "-green"}",
dataIcon := (if (granted) "E" else "")
)(
2020-07-02 11:26:31 -06:00
if (granted)
frag(
approved(),
s.streamer.approval.tier > 0 option frag(
br,
strong("You have been selected for frontpage featuring!"),
p(
"Note that we can only show a limited number of streams on the homepage, ",
"so yours may not always appear."
)
)
)
2019-12-13 07:30:20 -07:00
else
frag(
2020-02-09 13:37:40 -07:00
if (s.streamer.approval.requested) pendingReview()
2019-12-13 07:30:20 -07:00
else
frag(
if (s.streamer.completeEnough)
2020-02-09 13:37:40 -07:00
whenReady(
postForm(action := routes.Streamer.approvalRequest)(
2020-02-09 13:37:40 -07:00
button(tpe := "submit", cls := "button", (!ctx.is(s.user)) option disabled)(
requestReview()
2019-12-13 07:30:20 -07:00
)
2019-04-16 09:09:06 -06:00
)
)
2020-02-09 13:37:40 -07:00
else pleaseFillIn()
2019-04-16 09:09:06 -06:00
)
2019-12-13 07:30:20 -07:00
)
),
ctx.is(s.user) option div(cls := "status")(
2020-02-09 13:37:40 -07:00
anotherLanguage(
a(href := "https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes")(
"2-letter ISO 639-1 code"
)
)
2019-12-13 07:30:20 -07:00
),
2021-01-07 08:37:07 -07:00
modData.map { case ((log, notes), same) =>
2020-09-21 01:28:28 -06:00
div(cls := "mod_log status")(
strong(cls := "text", dataIcon := "!")(
"Moderation history",
log.isEmpty option ": nothing to show."
),
log.nonEmpty option ul(
log.map { e =>
li(
userIdLink(e.mod.some, withTitle = false),
" ",
b(e.showAction),
" ",
e.details,
" ",
momentFromNow(e.date)
)
}
),
br,
strong(cls := "text", dataIcon := "!")(
"Moderator notes",
notes.isEmpty option ": nothing to show."
),
notes.nonEmpty option ul(
notes.map { note =>
(isGranted(_.Admin) || !note.dox) option
li(
p(cls := "meta")(userIdLink(note.from.some), " ", momentFromNow(note.date)),
p(cls := "text")(richText(note.text))
)
2020-09-21 01:28:28 -06:00
}
2021-01-07 08:37:07 -07:00
),
br,
strong(cls := "text", dataIcon := "!")(
"Streamers with same Twitch or YouTube",
same.isEmpty option ": nothing to show."
),
same.nonEmpty option table(cls := "slist")(
same.map { s =>
tr(
td(userIdLink(s.userId.some)),
td(s.name),
td(s.twitch.map(t => a(href := s"https://twitch.tv/${t.userId}")(t.userId))),
td(
s.youTube.map(t =>
a(href := s"https://youtube.com/channel/${t.channelId}")(t.channelId)
)
),
td(momentFromNow(s.createdAt))
)
}
2019-04-16 09:09:06 -06:00
)
2020-09-21 01:28:28 -06:00
)
2019-12-13 07:30:20 -07:00
},
postForm(
cls := "form3",
action := s"${routes.Streamer.edit}${!ctx.is(s.user) ?? s"?u=${s.user.id}"}"
2019-12-13 07:30:20 -07:00
)(
isGranted(_.Streamers) option div(cls := "mod")(
2019-04-16 09:09:06 -06:00
form3.split(
2019-12-13 07:30:20 -07:00
form3.checkbox(
form("approval.granted"),
2020-02-09 13:37:40 -07:00
frag("Publish on the streamers list"),
2019-12-13 07:30:20 -07:00
half = true
),
form3.checkbox(
form("approval.requested"),
2020-02-09 13:37:40 -07:00
frag("Active approval request"),
2019-12-13 07:30:20 -07:00
half = true
)
2019-04-16 09:09:06 -06:00
),
form3.split(
2019-12-13 07:30:20 -07:00
form3.checkbox(
form("approval.chat"),
2020-02-09 13:37:40 -07:00
frag("Embed stream chat too"),
2019-12-13 07:30:20 -07:00
half = true
),
if (granted)
2020-06-30 14:12:42 -06:00
form3.group(
form("approval.tier"),
raw("Homepage tier"),
help =
frag("Higher tier has more chance to hit homepage. Set to zero to unfeature.").some,
2019-12-13 07:30:20 -07:00
half = true
2020-06-30 14:12:42 -06:00
)(form3.select(_, lila.streamer.Streamer.tierChoices))
2019-12-13 07:30:20 -07:00
else
form3.checkbox(
form("approval.ignored"),
2020-02-09 13:37:40 -07:00
frag("Ignore further approval requests"),
2019-12-13 07:30:20 -07:00
half = true
)
2019-04-16 09:09:06 -06:00
),
2020-05-23 09:35:39 -06:00
form3.actions(
form3
.submit("Approve and next")(
cls := "button-green",
name := "approval.quick",
value := "approve"
),
form3.submit("Decline and next", icon = "L".some)(
cls := "button-red",
name := "approval.quick",
value := "decline"
),
form3.submit(trans.apply())
)
2019-12-13 07:30:20 -07:00
),
form3.globalError(form),
2019-12-13 07:30:20 -07:00
form3.split(
form3.group(
form("twitch"),
2020-02-09 13:37:40 -07:00
twitchUsername(),
help = optionalOrEmpty().some,
2019-12-13 07:30:20 -07:00
half = true
)(form3.input(_)),
form3.group(
form("youTube"),
2020-02-09 13:37:40 -07:00
youtubeChannel(),
help = optionalOrEmpty().some,
2019-12-13 07:30:20 -07:00
half = true
)(form3.input(_))
),
form3.split(
form3.group(
form("name"),
2020-02-09 13:37:40 -07:00
streamerName(),
help = keepItShort(25).some,
2019-12-13 07:30:20 -07:00
half = true
)(form3.input(_)),
form3.checkbox(
form("listed"),
2020-02-09 13:37:40 -07:00
visibility(),
help = whenApproved().some,
2019-12-13 07:30:20 -07:00
half = true
2019-04-16 09:09:06 -06:00
)
2019-12-13 07:30:20 -07:00
),
form3.group(
form("headline"),
2020-02-09 13:37:40 -07:00
headline(),
help = tellUsAboutTheStream().some
2019-12-13 07:30:20 -07:00
)(form3.input(_)),
2020-02-09 13:37:40 -07:00
form3.group(form("description"), longDescription())(form3.textarea(_)(rows := 10)),
2019-12-13 07:30:20 -07:00
form3.actions(
2020-02-09 13:37:40 -07:00
a(href := routes.Streamer.show(s.user.username))(trans.cancel()),
2019-12-13 07:30:20 -07:00
form3.submit(trans.apply())
2019-04-16 09:09:06 -06:00
)
)
2019-12-13 07:30:20 -07:00
)
}
2019-04-16 09:09:06 -06:00
)
2019-12-13 07:30:20 -07:00
)
}
2019-04-16 09:09:06 -06:00
}
}