feat: harden dashboard editing and translations
This commit is contained in:
@@ -91,5 +91,6 @@
|
||||
{% endif %}
|
||||
{% block content %}{% endblock %}
|
||||
</main>
|
||||
{% block modals %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -85,82 +85,6 @@
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% if can_change %}
|
||||
<div class="fixed inset-0 z-40 hidden items-center justify-center bg-slate-900/80 p-4"
|
||||
data-edit-panel="{{ claim.id }}"
|
||||
data-edit-backdrop="{{ claim.id }}"
|
||||
aria-hidden="true"
|
||||
role="dialog"
|
||||
aria-modal="true">
|
||||
<div class="w-full max-w-2xl rounded-3xl bg-white p-6 text-left shadow-2xl">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<p class="text-xs font-semibold uppercase tracking-wide text-gray-500">{% trans "Redigera utlägg" %}</p>
|
||||
<h3 class="text-xl font-semibold text-gray-900">{{ claim.full_name }}</h3>
|
||||
</div>
|
||||
<button type="button"
|
||||
class="rounded-full bg-gray-100 px-3 py-1 text-xs font-semibold text-gray-600 transition hover:bg-gray-200"
|
||||
onclick="claimsCloseEdit('{{ claim.id }}'); return false;">
|
||||
{% trans "Stäng" %}
|
||||
</button>
|
||||
</div>
|
||||
<form method="post" class="mt-4 space-y-4">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="action_type" value="edit">
|
||||
<input type="hidden" name="edit_claim_id" value="{{ claim.id }}">
|
||||
<div class="grid gap-4 md:grid-cols-2">
|
||||
<label class="text-sm font-medium text-gray-700">
|
||||
{% trans "Namn" %}
|
||||
<input type="text" name="full_name" value="{{ claim.full_name }}" class="mt-1 w-full rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 focus:border-brand-600 focus:outline-none focus:ring-2 focus:ring-brand-600" required>
|
||||
</label>
|
||||
<label class="text-sm font-medium text-gray-700">
|
||||
{% trans "E-post" %}
|
||||
<input type="email" name="email" value="{{ claim.email }}" class="mt-1 w-full rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 focus:border-brand-600 focus:outline-none focus:ring-2 focus:ring-brand-600" required>
|
||||
</label>
|
||||
<label class="text-sm font-medium text-gray-700">
|
||||
{% trans "Kontonummer" %}
|
||||
<input type="text" name="account_number" value="{{ claim.account_number }}" class="mt-1 w-full rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 focus:border-brand-600 focus:outline-none focus:ring-2 focus:ring-brand-600" required>
|
||||
</label>
|
||||
<label class="text-sm font-medium text-gray-700">
|
||||
{% trans "Belopp" %}
|
||||
<input type="number" step="0.01" name="amount" value="{{ claim.amount }}" class="mt-1 w-full rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 focus:border-brand-600 focus:outline-none focus:ring-2 focus:ring-brand-600" required>
|
||||
</label>
|
||||
<label class="text-sm font-medium text-gray-700">
|
||||
{% trans "Valuta" %}
|
||||
<select name="currency" class="mt-1 w-full rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 focus:border-brand-600 focus:outline-none focus:ring-2 focus:ring-brand-600">
|
||||
{% for value, label in currency_choices %}
|
||||
<option value="{{ value }}"{% if claim.currency == value %} selected{% endif %}>{{ label }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</label>
|
||||
<label class="text-sm font-medium text-gray-700">
|
||||
{% trans "Evenemang/Projekt" %}
|
||||
<select name="project" class="mt-1 w-full rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 focus:border-brand-600 focus:outline-none focus:ring-2 focus:ring-brand-600">
|
||||
<option value="">{% trans "Ingen" %}</option>
|
||||
{% for project in project_options %}
|
||||
<option value="{{ project.id }}"{% if claim.project and project.id == claim.project.id %} selected{% endif %}>{{ project }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label class="text-sm font-medium text-gray-700" for="edit-description-{{ claim.id }}">{% trans "Beskrivning" %}</label>
|
||||
<textarea id="edit-description-{{ claim.id }}" name="description" rows="4" class="mt-1 w-full rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 focus:border-brand-600 focus:outline-none focus:ring-2 focus:ring-brand-600">{{ claim.description }}</textarea>
|
||||
</div>
|
||||
<div class="flex items-center justify-end gap-3">
|
||||
<button type="button"
|
||||
class="rounded-full border border-gray-300 px-4 py-2 text-sm font-semibold text-gray-600 transition hover:bg-gray-100"
|
||||
onclick="claimsCloseEdit('{{ claim.id }}'); return false;">
|
||||
{% trans "Avbryt" %}
|
||||
</button>
|
||||
<button type="submit" class="rounded-full bg-brand-600 px-4 py-2 text-sm font-semibold text-white transition hover:bg-brand-700">
|
||||
{% trans "Spara ändringar" %}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</section>
|
||||
|
||||
<div class="space-y-6" data-claim-list>
|
||||
@@ -211,7 +135,7 @@
|
||||
<span class="text-xs text-gray-500">{% trans "Ej markerad som betald" %}</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if can_change %}
|
||||
{% if can_change and claim.status == 'pending' %}
|
||||
<button type="button"
|
||||
data-open-edit="{{ claim.id }}"
|
||||
class="rounded-full border border-gray-300 px-3 py-1 text-xs font-semibold text-gray-700 transition hover:bg-gray-100">
|
||||
@@ -344,15 +268,6 @@
|
||||
<label class="block text-sm font-medium text-gray-700">{% trans "Kommentar" %}</label>
|
||||
<textarea name="decision_note" rows="3" class="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 focus:border-brand-600 focus:outline-none focus:ring-2 focus:ring-brand-600">{{ claim.decision_note }}</textarea>
|
||||
|
||||
<label class="block text-sm font-medium text-gray-700">{% trans "Evenemang/Projekt" %}</label>
|
||||
<select name="project" class="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 focus:border-brand-600 focus:outline-none focus:ring-2 focus:ring-brand-600">
|
||||
<option value="">{% trans "Behåll nuvarande" %}</option>
|
||||
{% for project in project_options %}
|
||||
<option value="{{ project.id }}"{% if claim.project and project.id == claim.project.id %} selected{% endif %}>{{ project }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<p class="text-xs text-gray-500">{% trans "Justera projekt om underlaget skickats in mot fel evenemang." %}</p>
|
||||
|
||||
<input type="hidden" name="action_type" value="decision">
|
||||
<button type="submit" class="w-full rounded-full bg-brand-600 px-4 py-2 text-sm font-semibold text-white transition hover:bg-brand-700">
|
||||
{% trans "Uppdatera beslut" %}
|
||||
@@ -432,18 +347,33 @@
|
||||
</section>
|
||||
<script>
|
||||
(function () {
|
||||
function lockBodyScroll() {
|
||||
document.body.classList.add("overflow-hidden");
|
||||
}
|
||||
|
||||
function unlockBodyScrollIfNeeded() {
|
||||
const anyOpen = Array.from(document.querySelectorAll("[data-edit-panel]")).some(
|
||||
(panel) => !panel.classList.contains("hidden")
|
||||
);
|
||||
if (!anyOpen) {
|
||||
document.body.classList.remove("overflow-hidden");
|
||||
}
|
||||
}
|
||||
|
||||
function openPanel(id) {
|
||||
const panel = document.querySelector(`[data-edit-panel="${id}"]`);
|
||||
if (!panel) return;
|
||||
panel.classList.remove("hidden");
|
||||
panel.classList.add("flex");
|
||||
panel.setAttribute("aria-hidden", "false");
|
||||
lockBodyScroll();
|
||||
}
|
||||
|
||||
function closePanelElement(panel) {
|
||||
panel.classList.add("hidden");
|
||||
panel.classList.remove("flex");
|
||||
panel.setAttribute("aria-hidden", "true");
|
||||
unlockBodyScrollIfNeeded();
|
||||
}
|
||||
|
||||
document.addEventListener("click", (event) => {
|
||||
@@ -553,3 +483,87 @@
|
||||
})();
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
{% block modals %}
|
||||
{{ block.super }}
|
||||
{% if can_change %}
|
||||
{% for claim in claims %}
|
||||
{% if claim.status == 'pending' %}
|
||||
<div class="fixed inset-0 z-40 hidden items-center justify-center bg-slate-900/80 p-4"
|
||||
data-edit-panel="{{ claim.id }}"
|
||||
data-edit-backdrop="{{ claim.id }}"
|
||||
aria-hidden="true"
|
||||
role="dialog"
|
||||
aria-modal="true">
|
||||
<div class="w-full max-w-2xl rounded-3xl bg-white p-6 text-left shadow-2xl">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<p class="text-xs font-semibold uppercase tracking-wide text-gray-500">{% trans "Redigera utlägg" %}</p>
|
||||
<h3 class="text-xl font-semibold text-gray-900">{{ claim.full_name }}</h3>
|
||||
</div>
|
||||
<button type="button"
|
||||
data-close-edit
|
||||
class="rounded-full bg-gray-100 px-3 py-1 text-xs font-semibold text-gray-600 transition hover:bg-gray-200">
|
||||
{% trans "Stäng" %}
|
||||
</button>
|
||||
</div>
|
||||
<form method="post" class="mt-4 space-y-4">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="action_type" value="edit">
|
||||
<input type="hidden" name="edit_claim_id" value="{{ claim.id }}">
|
||||
<div class="grid gap-4 md:grid-cols-2">
|
||||
<label class="text-sm font-medium text-gray-700">
|
||||
{% trans "Namn" %}
|
||||
<input type="text" name="full_name" value="{{ claim.full_name }}" class="mt-1 w-full rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 focus:border-brand-600 focus:outline-none focus:ring-2 focus:ring-brand-600" required>
|
||||
</label>
|
||||
<label class="text-sm font-medium text-gray-700">
|
||||
{% trans "E-post" %}
|
||||
<input type="email" name="email" value="{{ claim.email }}" class="mt-1 w-full rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 focus:border-brand-600 focus:outline-none focus:ring-2 focus:ring-brand-600" required>
|
||||
</label>
|
||||
<label class="text-sm font-medium text-gray-700">
|
||||
{% trans "Kontonummer" %}
|
||||
<input type="text" name="account_number" value="{{ claim.account_number }}" class="mt-1 w-full rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 focus:border-brand-600 focus:outline-none focus:ring-2 focus:ring-brand-600" required>
|
||||
</label>
|
||||
<label class="text-sm font-medium text-gray-700">
|
||||
{% trans "Belopp" %}
|
||||
<input type="number" step="0.01" name="amount" value="{{ claim.amount }}" class="mt-1 w-full rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 focus:border-brand-600 focus:outline-none focus:ring-2 focus:ring-brand-600" required>
|
||||
</label>
|
||||
<label class="text-sm font-medium text-gray-700">
|
||||
{% trans "Valuta" %}
|
||||
<select name="currency" class="mt-1 w-full rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 focus:border-brand-600 focus:outline-none focus:ring-2 focus:ring-brand-600">
|
||||
{% for value, label in currency_choices %}
|
||||
<option value="{{ value }}"{% if claim.currency == value %} selected{% endif %}>{{ label }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</label>
|
||||
<label class="text-sm font-medium text-gray-700">
|
||||
{% trans "Evenemang/Projekt" %}
|
||||
<select name="project" class="mt-1 w-full rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 focus:border-brand-600 focus:outline-none focus:ring-2 focus:ring-brand-600">
|
||||
<option value="">{% trans "Ingen" %}</option>
|
||||
{% for project in project_options %}
|
||||
<option value="{{ project.id }}"{% if claim.project and project.id == claim.project.id %} selected{% endif %}>{{ project }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label class="text-sm font-medium text-gray-700" for="edit-description-{{ claim.id }}">{% trans "Beskrivning" %}</label>
|
||||
<textarea id="edit-description-{{ claim.id }}" name="description" rows="4" class="mt-1 w-full rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 focus:border-brand-600 focus:outline-none focus:ring-2 focus:ring-brand-600">{{ claim.description }}</textarea>
|
||||
</div>
|
||||
<div class="flex items-center justify-end gap-3">
|
||||
<button type="button"
|
||||
data-close-edit
|
||||
class="rounded-full border border-gray-300 px-4 py-2 text-sm font-semibold text-gray-600 transition hover:bg-gray-100">
|
||||
{% trans "Avbryt" %}
|
||||
</button>
|
||||
<button type="submit" class="rounded-full bg-brand-600 px-4 py-2 text-sm font-semibold text-white transition hover:bg-brand-700">
|
||||
{% trans "Spara ändringar" %}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user