forked from excid3/simple_discussion
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into markdown-syntax-extensions
- Loading branch information
Showing
14 changed files
with
210 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
app/views/simple_discussion/forum_posts/_report_post_modal_form.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<div class="modal fade" id="reportPostModal" tabindex="-1" role="dialog" aria-labelledby="reportSpamModalLabel" aria-hidden="true"> | ||
<div class="modal-dialog modal-dialog-centered" role="document"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<h5 class="modal-title" id="reportSpamModalLabel">Report Post as Spam</h5> | ||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
<div class="modal-body"> | ||
<%= form_with id:"reportPostForm", url: simple_discussion.forum_thread_path(forum_thread), method: :post, local: true do |f| %> | ||
<% if @spam_report && @spam_report.errors.any? %> | ||
<div class="alert alert-danger" role="alert"> | ||
<% @spam_report.errors.full_messages.each do |message| %> | ||
<li><%= message %></li> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
<div class="form-group"> | ||
<%= f.collection_radio_buttons :reason, SpamReport.reasons.keys, :to_s, :humanize, include_hidden: false do |b| %> | ||
<div class="form-check"> | ||
<%= b.radio_button(class: "form-check-input toggle-reason", required: true) %> | ||
<%= b.label(class: "form-check-label") %> | ||
</div> | ||
<% end %> | ||
</div> | ||
<div class="form-group" id="details-group" style="display: none;"> | ||
<%= f.label :details, "Reason in detail (if others)" %> | ||
<%= f.text_area :details, class: "form-control", rows: 2, id: "details-input" %> | ||
<div class="invalid-feedback">Please provide details for 'Other' reason.</div> | ||
</div> | ||
<%= f.submit "Report", class: "btn btn-danger" %> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
$(document).ready(function() { | ||
const $detailsGroup = $('#details-group'); | ||
const $detailsInput = $('#details-input'); | ||
const $form = $('#reportPostForm'); | ||
|
||
$('.toggle-reason').change(function() { | ||
if ($(this).val() === 'others') { | ||
$detailsGroup.show(); | ||
$detailsInput.attr('required', true); | ||
} else { | ||
$detailsGroup.hide(); | ||
$detailsInput.removeAttr('required'); | ||
} | ||
}); | ||
|
||
$form.on('submit', function(e) { | ||
if ($('input[name="reason"]:checked').val() === 'others' && $detailsInput.val().trim() === '') { | ||
e.preventDefault(); | ||
$detailsInput.addClass('is-invalid'); | ||
} else { | ||
$detailsInput.removeClass('is-invalid'); | ||
} | ||
}); | ||
|
||
$detailsInput.on('input', function() { | ||
$(this).removeClass('is-invalid'); | ||
}); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
member do | ||
put :solved | ||
put :unsolved | ||
post :report_spam | ||
post :report_post | ||
end | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,6 @@ class User < ApplicationRecord | |
:recoverable, :rememberable, :validatable | ||
|
||
def moderator? | ||
true | ||
moderator | ||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
test/dummy/db/migrate/20240813072347_add_moderator_to_users.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddModeratorToUsers < ActiveRecord::Migration[7.0] | ||
def change | ||
add_column :users, :moderator, :boolean, default: false | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.