honor inquiry next toggle
parent
bcaca218d7
commit
4d8ca36d40
|
@ -20,7 +20,7 @@ object Mod extends LilaController {
|
|||
private def modLogApi = Env.mod.logApi
|
||||
private def assessApi = Env.mod.assessApi
|
||||
|
||||
def engine(username: String, v: Boolean) = Secure(_.MarkEngine) { implicit ctx => me =>
|
||||
def engine(username: String, v: Boolean) = SecureBody(_.MarkEngine) { implicit ctx => me =>
|
||||
withSuspect(username) { sus =>
|
||||
for {
|
||||
inquiry <- Env.report.api.inquiries ofModId me.id
|
||||
|
@ -46,7 +46,7 @@ object Mod extends LilaController {
|
|||
}
|
||||
}
|
||||
|
||||
def troll(username: String, v: Boolean) = Secure(_.MarkTroll) { implicit ctx => me =>
|
||||
def troll(username: String, v: Boolean) = SecureBody(_.MarkTroll) { implicit ctx => me =>
|
||||
withSuspect(username) { prev =>
|
||||
for {
|
||||
inquiry <- Env.report.api.inquiries ofModId me.id
|
||||
|
@ -56,7 +56,7 @@ object Mod extends LilaController {
|
|||
}
|
||||
}
|
||||
|
||||
def warn(username: String, subject: String) = Secure(_.ModMessage) { implicit ctx => me =>
|
||||
def warn(username: String, subject: String) = SecureBody(_.ModMessage) { implicit ctx => me =>
|
||||
lila.message.ModPreset.bySubject(subject).fold(notFound) { preset =>
|
||||
withSuspect(username) { sus =>
|
||||
for {
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package controllers
|
||||
|
||||
import play.api.mvc.AnyContentAsFormUrlEncoded
|
||||
|
||||
import views._
|
||||
|
||||
import lila.api.Context
|
||||
import lila.api.{ Context, BodyContext }
|
||||
import lila.app._
|
||||
import lila.report.{ Room, Report => ReportModel, Mod => AsMod, Suspect }
|
||||
import lila.user.{ UserRepo, User => UserModel }
|
||||
|
@ -42,20 +44,27 @@ object Report extends LilaController {
|
|||
case _ => routes.User.show(inquiry.user).url + "?mod"
|
||||
})
|
||||
|
||||
protected[controllers] def onInquiryClose(inquiry: Option[ReportModel], me: UserModel) = inquiry match {
|
||||
case None => Redirect(routes.Report.list).fuccess
|
||||
case Some(prev) =>
|
||||
def redirectToList = Redirect(routes.Report.listWithFilter(prev.room.key))
|
||||
api.next(prev.room) flatMap {
|
||||
_.fold(redirectToList.fuccess) { report =>
|
||||
api.inquiries.toggle(AsMod(me), report.id) map {
|
||||
_.fold(redirectToList)(onInquiryStart)
|
||||
protected[controllers] def onInquiryClose(inquiry: Option[ReportModel], me: UserModel)(implicit ctx: BodyContext[_]) = {
|
||||
val autoNext = ctx.body.body match {
|
||||
case AnyContentAsFormUrlEncoded(data) => data.get("next").exists(_.headOption contains "1")
|
||||
case _ => false
|
||||
}
|
||||
inquiry match {
|
||||
case None => Redirect(routes.Report.list).fuccess
|
||||
case Some(prev) =>
|
||||
def redirectToList = Redirect(routes.Report.listWithFilter(prev.room.key))
|
||||
if (!autoNext) Redirect(s"${routes.User.show(prev.user)}?mod").fuccess
|
||||
else api.next(prev.room) flatMap {
|
||||
_.fold(redirectToList.fuccess) { report =>
|
||||
api.inquiries.toggle(AsMod(me), report.id) map {
|
||||
_.fold(redirectToList)(onInquiryStart)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def process(id: String) = Secure(_.SeeReport) { implicit ctx => me =>
|
||||
def process(id: String) = SecureBody(_.SeeReport) { implicit ctx => me =>
|
||||
Env.report.api.inquiries ofModId me.id flatMap { inquiry =>
|
||||
api.process(AsMod(me), id) >> onInquiryClose(inquiry, me)
|
||||
}
|
||||
|
|
|
@ -14,6 +14,10 @@
|
|||
</div>
|
||||
}
|
||||
|
||||
@autoNextInput = {
|
||||
<input class="auto-next" type="hidden" name="next" value="1" />
|
||||
}
|
||||
|
||||
<div id="inquiry">
|
||||
<i title="Costello the Inquiry Octopus" class="costello"></i>
|
||||
<div class="meat">
|
||||
|
@ -63,6 +67,7 @@
|
|||
@lila.message.ModPreset.all.map { preset =>
|
||||
<form method="post" action="@routes.Mod.warn(in.user.username, preset.subject)">
|
||||
<input class="fbt" type="submit" value="@preset.subject" />
|
||||
@autoNextInput
|
||||
</form>
|
||||
}
|
||||
<form method="get" action="@routes.Message.form">
|
||||
|
@ -75,16 +80,19 @@
|
|||
@if(isGranted(_.MarkEngine)) {
|
||||
<form method="post" action="@routes.Mod.engine(in.user.username, !in.user.engine)" data-hint="Mark as cheat" class="hint--bottom-left">
|
||||
<button data-icon="n" class="fbt icon@when(in.user.engine, " active")" type="submit"></button>
|
||||
@autoNextInput
|
||||
</form>
|
||||
}
|
||||
@if(isGranted(_.MarkBooster)) {
|
||||
<form method="post" action="@routes.Mod.booster(in.user.username, !in.user.booster)" data-hint="Marks as booster or sandbagger" class="hint--bottom-left">
|
||||
<button data-icon="9" class="fbt icon@when(in.user.booster, " active")" type="submit"></button>
|
||||
@autoNextInput
|
||||
</form>
|
||||
}
|
||||
@if(isGranted(_.MarkTroll)) {
|
||||
<form method="post" action="@routes.Mod.troll(in.user.username, !in.user.troll)" data-hint="@if(in.user.troll){En}else{Dis}able communication features for this user." class="hint--bottom-left">
|
||||
<button data-icon="c" class="fbt icon@when(in.user.troll, " active")" type="submit"></button>
|
||||
@autoNextInput
|
||||
</form>
|
||||
}
|
||||
<div class="dropper">
|
||||
|
@ -95,6 +103,7 @@
|
|||
</form>
|
||||
<form method="post" action="@routes.Report.xfiles(in.report.id)">
|
||||
<input class="fbt@when(in.report.room.key == "xfiles", " active")" type="submit" value="Move to X-Files" />
|
||||
@autoNextInput
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -110,6 +119,7 @@
|
|||
}
|
||||
<form action="@routes.Report.process(in.report.id)" method="post" data-hint="Dismiss this report as processed." class="process hint--bottom-left">
|
||||
<button type="submit" data-icon="E" class="fbt"></button>
|
||||
@autoNextInput
|
||||
</form>
|
||||
<form action="@routes.Report.inquiry(in.report.id)" method="post" data-hint="Cancel the inquiry, re-instore the report" class="cancel hint--bottom-left">
|
||||
<button type="submit" data-icon="L" class="fbt"></button>
|
||||
|
|
|
@ -9,10 +9,14 @@ $(function() {
|
|||
|
||||
var nextStore = lichess.storage.make('inquiry-auto-next');
|
||||
|
||||
if (!nextStore.get()) $('#inquiry .switcher input').attr('checked', false);
|
||||
if (!nextStore.get()) {
|
||||
$('#inquiry .switcher input').attr('checked', false);
|
||||
$('#inquiry input.auto-next').val('0');
|
||||
}
|
||||
|
||||
$('#inquiry .switcher input').on('change', function() {
|
||||
if (nextStore.get()) nextStore.remove();
|
||||
else nextStore.set(1);
|
||||
$('#inquiry input.auto-next').val(nextStore.get() || '0');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue