From b196cbdd1c1e5c5b48746f7dd9d92625de9c97b1 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Thu, 30 Dec 2021 21:56:03 +0100 Subject: [PATCH] Adjust ban script to work when unbanning --- app/javascript/legacy/moderation/ban.coffee | 29 +++++++++++---------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/app/javascript/legacy/moderation/ban.coffee b/app/javascript/legacy/moderation/ban.coffee index e37296de..934fcd3e 100644 --- a/app/javascript/legacy/moderation/ban.coffee +++ b/app/javascript/legacy/moderation/ban.coffee @@ -6,18 +6,19 @@ load = -> banCheckbox = modalForm.querySelector('[name="ban"][type="checkbox"]') permabanCheckbox = modalForm.querySelector('[name="permaban"][type="checkbox"]') - banCheckbox.addEventListener "change", (event) -> - $t = $ this - if $t.is(":checked") - $("#ban-controls").show() - else - $("#ban-controls").hide() - permabanCheckbox.addEventListener "change", (event) -> - $t = $ this - if $t.is(":checked") - $("#ban-controls-time").hide() - else - $("#ban-controls-time").show() + if banCheckbox + banCheckbox.addEventListener "change", (event) -> + $t = $ this + if $t.is(":checked") + $("#ban-controls").show() + else + $("#ban-controls").hide() + permabanCheckbox.addEventListener "change", (event) -> + $t = $ this + if $t.is(":checked") + $("#ban-controls-time").hide() + else + $("#ban-controls-time").show() modalForm.addEventListener "submit", (event) -> event.preventDefault(); @@ -29,11 +30,11 @@ load = -> "0" data = { - ban: checktostr banCheckbox + ban: banCheckbox ? checktostr banCheckbox : false user: modalForm.elements["user"].value } - if banCheckbox.checked + if banCheckbox && banCheckbox.checked data.reason = modalForm.elements["reason"].value.trim() unless permabanCheckbox.checked data.duration = modalForm.elements["duration"].value.trim()