Files
formeleon/templates/admin/forms/list.html
T

132 lines
6.1 KiB
HTML

{# ==============================================================================
Formeleon - Multi-tenant Form Generator
Author: Björn Runden <br@runden.net>
Template: admin/forms/list.html
Description: List all forms with filtering and management options.
============================================================================== #}
{% extends "base.html" %}
{% block title %}Forms - Formeleon{% endblock %}
{% block content %}
<div class="container">
<div class="row mb-4">
<div class="col-12 d-flex justify-content-between align-items-center">
<h1><i class="bi bi-file-earmark-text"></i> Forms</h1>
<div>
{% if user %}
<a href="{{ url_for('admin.create_form') }}" class="btn btn-primary">
<i class="bi bi-plus"></i> Create Form
</a>
{% endif %}
</div>
</div>
</div>
{% if forms %}
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header bg-light d-flex justify-content-between align-items-center">
<h5><i class="bi bi-list"></i> All Forms ({{ forms|length }})</h5>
<div class="input-group" style="width: 300px;">
<input type="text" class="form-control" id="searchInput" placeholder="Search forms...">
<button class="btn btn-outline-secondary" type="button">
<i class="bi bi-search"></i>
</button>
</div>
</div>
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead class="table-light">
<tr>
<th>Name</th>
<th>Tenant</th>
<th>ID</th>
<th>Status</th>
<th>Submissions</th>
<th>Created</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for form in forms %}
<tr>
<td>{{ form.name }}</td>
<td>{{ form.tenant.name if form.tenant else 'N/A' }}</td>
<td><code>{{ form.id }}</code></td>
<td>
<span class="badge bg-{{ 'success' if form.is_active else 'secondary' }}">
{{ 'Active' if form.is_active else 'Inactive' }}
</span>
</td>
<td>{{ form.submissions|length }}</td>
<td>{{ form.created_at.strftime('%Y-%m-%d') if form.created_at else 'N/A' }}</td>
<td>
<div class="btn-group btn-group-sm" role="group">
<a href="{{ url_for('admin.view_form', form_id=form.id) }}" class="btn btn-outline-secondary" title="View">
<i class="bi bi-eye"></i>
</a>
{% if is_admin or (user and form.tenant and user in form.tenant.users) %}
<a href="{{ url_for('admin.view_form', form_id=form.id) }}" class="btn btn-outline-primary" title="Edit">
<i class="bi bi-pencil"></i>
</a>
<form action="{{ url_for('admin.delete_form', form_id=form.id) }}" method="POST"
onsubmit="return confirm('Are you sure you want to delete this form? This action cannot be undone.');">
<button type="submit" class="btn btn-outline-danger" title="Delete">
<i class="bi bi-trash"></i>
</button>
</form>
{% endif %}
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
{% else %}
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body text-center py-5">
<i class="bi bi-file-earmark-text display-4 text-muted mb-3"></i>
<h3>No Forms</h3>
<p class="text-muted">No forms have been created yet.</p>
{% if user %}
<a href="{{ url_for('admin.create_form') }}" class="btn btn-primary">
<i class="bi bi-plus"></i> Create First Form
</a>
{% endif %}
</div>
</div>
</div>
</div>
{% endif %}
</div>
{% endblock %}
{% block extra_js %}
<script>
// Search functionality
$(document).ready(function() {
$('#searchInput').on('input', function() {
const searchTerm = $(this).val().toLowerCase();
const table = $(this).closest('.card').find('table tbody tr');
table.each(function() {
const text = $(this).text().toLowerCase();
const visible = text.includes(searchTerm);
$(this).toggle(visible);
});
});
});
</script>
{% endblock %}