{# A post's flag control (crate::moderation::flag_post): a menu of reasons
that swaps itself for "Flagged" once sent. `post` has id, can_flag and
flagged; `flag_reasons` the (key, label) pairs; `flag_error` why the
last attempt was refused. #}
<span id="flag-{{ post.id }}" class="inline-flex items-center">
{% if post.flagged %}
<span class="btn btn-ghost btn-xs btn-disabled text-error/70" title="You flagged this post; staff will review it"><i class="fas fa-flag mr-1"></i>Flagged</span>
{% elif post.can_flag %}
<details class="dropdown dropdown-end">
<summary class="btn btn-ghost btn-xs list-none" title="Flag this post for staff"><i class="far fa-flag mr-1 opacity-60"></i>Flag</summary>
<form method="post" action="/p/{{ post.id }}/flag"
hx-post="/p/{{ post.id }}/flag" hx-target="#flag-{{ post.id }}" hx-select="unset" hx-swap="outerHTML"
class="dropdown-content z-20 mt-1 w-64 space-y-2 rounded-box border border-base-300 bg-base-100 p-3 text-left shadow-lg">
<p class="text-xs font-semibold">Why should staff look at this?</p>
{% for key, label in flag_reasons %}
<label class="flex items-center gap-2 text-sm">
<input type="radio" name="reason" value="{{ key }}" class="radio radio-xs" {% if loop.first %}checked{% endif %}> {{ label }}
</label>
{% endfor %}
<textarea name="note" rows="2" maxlength="1000" class="textarea textarea-bordered textarea-xs w-full" placeholder="Anything staff should know (optional)"></textarea>
<div class="flex justify-end"><button type="submit" class="btn btn-error btn-xs"><i class="fas fa-flag mr-1"></i>Flag</button></div>
</form>
</details>
{% endif %}
{% if flag_error %}<span class="text-xs text-error ml-1" role="alert">{{ flag_error }}</span>{% endif %}
</span>
neiam
/recourse
public · Issues · Pulls · Labels · Forks · Compare · Actions running · Badges · Packages
⭐
Log in to mark this repository.
1.8 KiB · text
History
3d71adc