Better contact form

This commit is contained in:
2025-06-05 21:05:15 +02:00
parent f65265b4a5
commit 57fa221d47
6 changed files with 106 additions and 120 deletions

View File

@@ -113,37 +113,45 @@
{% endif %}
</div>
<div class="flex flex-col space-y-4">
<div class="flex items-center space-x-4">
<div class="flex items-center relative group">
{% set is_last_admin = current_user.is_admin and total_admins <= 1 %}
{{ form.is_admin(
class="h-4 w-4 focus:ring-blue-500 border-gray-300 rounded",
style="accent-color: #16767b;",
disabled=is_last_admin and form.is_admin.data
) }}
{{ form.is_admin.label(class="ml-2 block text-sm text-gray-900") }}
{% if is_last_admin and form.is_admin.data %}
<input type="hidden" name="is_admin" value="y">
{% endif %}
<div class="absolute left-0 bottom-full mb-2 hidden group-hover:block bg-gray-800 text-white text-xs rounded py-1 px-2 w-48">
Admin users have full access to manage contacts and system settings.
</div>
</div>
<div class="flex items-center relative group">
{{ form.is_manager(
class="h-4 w-4 focus:ring-blue-500 border-gray-300 rounded",
style="accent-color: #16767b;"
) }}
{{ form.is_manager.label(class="ml-2 block text-sm text-gray-900") }}
<div class="absolute left-0 bottom-full mb-2 hidden group-hover:block bg-gray-800 text-white text-xs rounded py-1 px-2 w-48">
Manager users have similar permissions to admins but with some restrictions.
</div>
<!-- Role Selection Section -->
<div class="bg-gray-50 p-4 rounded-lg border border-gray-200">
<h4 class="text-lg font-medium text-gray-900 mb-4">Role Selection</h4>
<div class="space-y-3">
{% for value, label in form.role.choices %}
<div class="flex items-center">
<input type="radio"
name="{{ form.role.name }}"
value="{{ value }}"
id="role_{{ value }}"
class="h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300"
{% if form.role.data == value %}checked{% endif %}
{% if value == 'admin' and current_user.is_admin and total_admins <= 1 and form.role.data == 'admin' %}disabled{% endif %}>
<label for="role_{{ value }}" class="ml-3 block text-sm font-medium text-gray-700">
{{ label }}
<span class="text-gray-500 text-xs block mt-0.5">
{% if value == 'admin' %}
Full access to all contacts, rooms and conversations. Can manage system settings and website customization.
{% elif value == 'manager' %}
Can create and manage rooms and conversations. Can view all contacts. Only limited access to system settings.
{% else %}
Basic user access.
{% endif %}
</span>
</label>
</div>
{% endfor %}
{% if form.role.errors %}
{% for error in form.role.errors %}
<p class="mt-1 text-sm text-red-600">{{ error }}</p>
{% endfor %}
{% endif %}
</div>
{% if form.is_admin.errors %}
</div>
<div class="flex flex-col space-y-4">
{% if form.role.errors %}
<div class="p-3 bg-red-50 border border-red-200 rounded-lg">
{% for error in form.is_admin.errors %}
{% for error in form.role.errors %}
<p class="text-sm text-red-700">{{ error }}</p>
{% endfor %}
</div>