From 382a4c278518b99f218efe0b3a9069b23dc5b31f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Mon, 16 Aug 2021 11:26:49 -0400 Subject: [PATCH] feat: #9705, use radio buttons for flag reasons --- public/language/en-GB/flags.json | 3 --- public/src/modules/flags.js | 37 ++++++++++++++------------------ 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/public/language/en-GB/flags.json b/public/language/en-GB/flags.json index bec69fc1a8..5bd46b6b1d 100644 --- a/public/language/en-GB/flags.json +++ b/public/language/en-GB/flags.json @@ -77,9 +77,6 @@ "modal-reason-custom": "Reason for reporting this content...", "modal-submit": "Submit Report", "modal-submit-success": "Content has been flagged for moderation.", - "modal-submit-confirm": "Confirm Submission", - "modal-submit-confirm-text": "You have a custom reason specified already. Are you sure you wish to submit via quick-report?", - "modal-submit-confirm-text-help": "Submitting a quick report will overwrite any custom reasons defined.", "bulk-actions": "Bulk Actions", "bulk-resolve": "Resolve Flag(s)", diff --git a/public/src/modules/flags.js b/public/src/modules/flags.js index 244589a3a2..fb6a171d9a 100644 --- a/public/src/modules/flags.js +++ b/public/src/modules/flags.js @@ -17,33 +17,28 @@ define('flags', ['hooks', 'components', 'api'], function (hooks, components, api flagCommit = flagModal.find('#flag-post-commit'); flagReason = flagModal.find('#flag-reason-custom'); - // Quick-report buttons - flagModal.on('click', '.flag-reason', function () { - var reportText = $(this).text(); - - if (flagReason.val().length === 0) { - return createFlag(data.type, data.id, reportText); + flagModal.on('click', 'input[name="flag-reason"]', function () { + if ($(this).attr('id') === 'flag-reason-other') { + flagReason.removeAttr('disabled'); + if (!flagReason.val().length) { + flagCommit.attr('disabled', true); + } + } else { + flagReason.attr('disabled', true); + flagCommit.removeAttr('disabled'); } - - // Custom reason has text, confirm submission - bootbox.confirm({ - title: '[[flags:modal-submit-confirm]]', - message: '

[[flags:modal-submit-confirm-text]]

[[flags:modal-submit-confirm-text-help]]

', - callback: function (result) { - if (result) { - createFlag(data.type, data.id, reportText); - } - }, - }); }); - // Custom reason report submission flagCommit.on('click', function () { - createFlag(data.type, data.id, flagModal.find('#flag-reason-custom').val()); + var selected = $('input[name="flag-reason"]:checked'); + var reason = selected.val(); + if (selected.attr('id') === 'flag-reason-other') { + reason = flagReason.val(); + } + createFlag(data.type, data.id, reason); }); - flagModal.on('click', '.toggle-custom', function () { - flagReason.prop('disabled', false); + flagModal.on('click', '#flag-reason-other', function () { flagReason.focus(); });