Skip to content

Commit

Permalink
feat: #9705, use radio buttons for flag reasons
Browse files Browse the repository at this point in the history
  • Loading branch information
barisusakli committed Aug 16, 2021
1 parent ffdf61b commit 382a4c2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
3 changes: 0 additions & 3 deletions public/language/en-GB/flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
37 changes: 16 additions & 21 deletions public/src/modules/flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '<p>[[flags:modal-submit-confirm-text]]</p><p class="help-block">[[flags:modal-submit-confirm-text-help]]</p>',
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();
});

Expand Down

0 comments on commit 382a4c2

Please sign in to comment.