{% extends "root.html" %}
{% block content %}
<div class="space-y-4 text-left max-w-xl">
<div class="text-sm opacity-70">
<a href="/admin/categories" class="link link-hover">Manage categories</a> /
{% if category %}Edit{% else %}New{% endif %}
</div>
<h1 class="text-3xl font-bold">
{% if category %}Edit category{% else %}New category{% endif %}
</h1>
{% if error %}
<div class="alert alert-error"><i class="fas fa-triangle-exclamation"></i><span>{{ error }}</span></div>
{% endif %}
<form class="card bg-base-200 border border-base-300 p-4 space-y-3"
method="post"
action="{% if category %}/admin/categories/{{ category.id }}{% else %}/admin/categories{% endif %}">
<div class="form-control">
<label class="label"><span class="label-text">Name</span></label>
<input type="text" name="name" required maxlength="100" class="input input-bordered w-full"
value="{{ category.name if category else '' }}" autofocus/>
</div>
<div class="form-control">
<label class="label"><span class="label-text">Slug <span class="opacity-60">(blank = derive from name)</span></span></label>
<input type="text" name="slug" maxlength="120" class="input input-bordered w-full"
value="{{ category.slug if category else '' }}" placeholder="auto"/>
</div>
<div class="form-control">
<label class="label"><span class="label-text">Description</span></label>
<textarea name="description" rows="3" class="textarea textarea-bordered w-full">{{ category.description if category and category.description else '' }}</textarea>
</div>
<div class="form-control">
<label class="label"><span class="label-text">Parent category</span></label>
<select name="parent_id" class="select select-bordered w-full">
<option value="">— None (top level) —</option>
{% for p in parents %}
<option value="{{ p.id }}" {% if selected_parent and p.id == selected_parent %}selected{% endif %}>
{% for _ in range(p.depth - 1) %}— {% endfor %}{{ p.name }}
</option>
{% endfor %}
</select>
<span class="label-text-alt opacity-60 mt-1">Up to 3 levels of nesting.</span>
</div>
<div class="form-control">
<label class="label"><span class="label-text">Visibility</span></label>
<select name="min_trust_level" class="select select-bordered w-full">
{% set cur = current_min_trust %}
<option value="public" {% if cur is none %}selected{% endif %}>Public — anyone can read</option>
<option value="0" {% if cur == 0 %}selected{% endif %}>Logged-in users</option>
<option value="1" {% if cur == 1 %}selected{% endif %}>Trust level 1+ (Basic)</option>
<option value="2" {% if cur == 2 %}selected{% endif %}>Trust level 2+ (Member)</option>
<option value="3" {% if cur == 3 %}selected{% endif %}>Trust level 3+ (Regular)</option>
<option value="4" {% if cur == 4 %}selected{% endif %}>Trust level 4 (Leader)</option>
</select>
<span class="label-text-alt opacity-60 mt-1">Also requires ancestor categories to be visible. Staff always see everything.</span>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
<div class="form-control">
<label class="label"><span class="label-text">Who can start topics</span></label>
<select name="topic_rule" class="select select-bordered w-full">
{% if creating %}<option value="inherit" {% if topic_rule == "inherit" %}selected{% endif %}>Same as the parent (anyone, at the top level)</option>{% endif %}
{% for v, label in rule_options %}<option value="{{ v }}" {% if topic_rule == v %}selected{% endif %}>{{ label }}</option>{% endfor %}
</select>
</div>
<div class="form-control">
<label class="label"><span class="label-text">Who can reply and react</span></label>
<select name="reply_rule" class="select select-bordered w-full">
{% if creating %}<option value="inherit" {% if reply_rule == "inherit" %}selected{% endif %}>Same as the parent (anyone, at the top level)</option>{% endif %}
{% for v, label in rule_options %}<option value="{{ v }}" {% if reply_rule == v %}selected{% endif %}>{{ label }}</option>{% endfor %}
</select>
</div>
<div class="form-control sm:col-span-2" data-reactions>
<label class="label"><span class="label-text">Reactions</span></label>
<select name="reactions" class="select select-bordered w-full">
{% if creating %}<option value="inherit" {% if reactions == "inherit" %}selected{% endif %}>Same as the parent (all, at the top level)</option>{% endif %}
<option value="all" {% if reactions == "all" %}selected{% endif %}>All reactions</option>
<option value="some" {% if reactions == "some" %}selected{% endif %}>Only the ones ticked below</option>
<option value="none" {% if reactions == "none" %}selected{% endif %}>No reactions</option>
</select>
<div class="mt-2 flex flex-wrap gap-3">
{% for key, emoji, active in reaction_choices %}
<label class="label cursor-pointer gap-1 py-0">
<input type="checkbox" name="rk_{{ key }}" class="checkbox checkbox-sm" {% if key in reaction_keys %}checked{% endif %}>
<span class="label-text"><span class="emoji-tint">{{ emoji }}</span> {{ key }}{% if not active %} <span class="opacity-50">(inactive)</span>{% endif %}</span>
</label>
{% endfor %}
</div>
<span class="label-text-alt opacity-60 mt-1">The ticks count only with "Only the ones ticked". Off hides reactions here and refuses new ones; existing ones are kept and come back if you turn them on again.</span>
</div>
<span class="label-text-alt opacity-60 sm:col-span-2">Posting rules apply on top of visibility: "staff only" topics with open replies make an announcements forum; read at TL1 and post at TL3 makes a read-only window. Not inherited by subcategories (a new one starts with its parent's). Staff can always post.</span>
</div>
<div class="grid grid-cols-2 gap-3">
<div class="form-control">
<label class="label"><span class="label-text">Color</span></label>
<input type="color" name="color" class="input input-bordered h-12 w-full p-1"
value="{{ category.color if category else default_color }}"/>
</div>
<div class="form-control">
<label class="label"><span class="label-text">Position</span></label>
<input type="number" name="position" class="input input-bordered w-full"
value="{{ category.position if category else 0 }}"/>
</div>
</div>
<div class="flex justify-end gap-2">
<a href="/admin/categories" class="btn btn-ghost btn-sm">Cancel</a>
<button type="submit" class="btn btn-primary btn-sm">
{% if category %}Save changes{% else %}Create category{% endif %}
</button>
</div>
</form>
</div>
{% endblock %}
neiam
/recourse
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
Log in to mark this repository.
6.9 KiB · text
History
263b40b