05/22 Enhance codes and fix bugs

This commit is contained in:
2026-05-22 11:53:41 -04:00
parent d6d9b5e9dc
commit 3511ac2b56
13 changed files with 891 additions and 47 deletions
+9 -4
View File
@@ -60,7 +60,7 @@
{% for days, colour, icon, label, hint in options %}
<div class="col-6 col-lg-3">
<form method="POST" action="{{ url_for('admin.activity_logs') }}"
onsubmit="return confirmCleanup({{ days }}, {{ counts_by_retention[days] }})">
onsubmit="return confirmCleanup(this, {{ days }}, {{ counts_by_retention[days] }})">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<input type="hidden" name="days" value="{{ days }}"/>
<button type="submit" class="btn btn-sm w-100 d-flex flex-column align-items-center py-3 gap-1"
@@ -170,12 +170,17 @@
</div>
<script>
function confirmCleanup(days, count) {
function confirmCleanup(form, days, count) {
if (count === 0) return false;
return confirm(
confirmModal(
'Clean Up Activity Logs',
'Delete ' + count.toLocaleString() + ' log entr' + (count === 1 ? 'y' : 'ies') +
' older than ' + days + ' days?\n\nThis cannot be undone.'
' older than ' + days + ' days? This action cannot be undone.',
'Delete Logs',
'btn-danger',
() => { form._confirmed = true; form.submit(); }
);
return false;
}
</script>
{% endblock %}
+1 -1
View File
@@ -44,7 +44,7 @@
class="btn btn-secondary btn-sm"><i class="bi bi-pencil"></i></a>
<form method="POST"
action="{{ url_for('admin.canned_response_delete', item_id=item.id) }}"
onsubmit="return confirm('Delete this quick reply?')">
data-confirm="Delete this quick reply?" data-confirm-title="Delete Quick Reply" data-confirm-ok="Delete">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<button type="submit" class="btn btn-sm btn-outline-danger"><i class="bi bi-trash"></i></button>
</form>
+5 -6
View File
@@ -369,12 +369,10 @@ function loadExistingAtts() {
}
function deleteAtt(attId, deleteUrl, filename) {
if (!confirm('Delete "' + filename + '"?')) return;
const row = document.getElementById('att-row-' + attId);
if (row) { row.style.opacity = '0.4'; row.style.pointerEvents = 'none'; }
fetch(deleteUrl, { method: 'POST', credentials: 'same-origin', headers: { 'X-CSRFToken': document.querySelector('meta[name="csrf-token"]').content } })
confirmModal('Delete Attachment', 'Delete "' + filename + '"? This cannot be undone.', 'Delete', 'btn-danger', () => {
const row = document.getElementById('att-row-' + attId);
if (row) { row.style.opacity = '0.4'; row.style.pointerEvents = 'none'; }
fetch(deleteUrl, { method: 'POST', credentials: 'same-origin', headers: { 'X-CSRFToken': document.querySelector('meta[name="csrf-token"]').content } })
.then(r => r.json())
.then(data => {
if (data.ok) {
@@ -395,6 +393,7 @@ function deleteAtt(attId, deleteUrl, filename) {
if (row) { row.style.opacity = ''; row.style.pointerEvents = ''; }
alert('Network error. Please try again.');
});
});
}
// Load existing attachments on page load (only for edit mode)
+1 -1
View File
@@ -110,7 +110,7 @@
</button>
{% endif %}
</form>
<form method="POST" action="{{ url_for('admin.kb_delete', article_id=art.id) }}" onsubmit="return confirm('Delete this article?');" style="margin:0;">
<form method="POST" action="{{ url_for('admin.kb_delete', article_id=art.id) }}" data-confirm="Delete this article? This cannot be undone." data-confirm-title="Delete Article" data-confirm-ok="Delete" style="margin:0;">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<button type="submit" class="btn btn-sm" style="background:rgba(248,113,113,.1);border:1px solid rgba(248,113,113,.2);color:var(--danger);" title="Delete"><i class="bi bi-trash"></i></button>
</form>
+12 -9
View File
@@ -368,7 +368,8 @@
{% if survey_enabled %}
<button type="submit" name="survey_enabled" value="0"
class="btn btn-sm btn-outline-danger"
onclick="return confirm('Disable satisfaction surveys? No survey emails will be sent when tickets are resolved.')">
data-confirm="Disable satisfaction surveys? No survey emails will be sent when tickets are resolved."
data-confirm-title="Disable Satisfaction Surveys" data-confirm-ok="Disable">
<i class="bi bi-toggle-on me-1"></i>Disable
</button>
{% else %}
@@ -416,7 +417,8 @@
{% if registration_enabled %}
<button type="submit" name="registration_enabled" value="0"
class="btn btn-sm btn-outline-danger"
onclick="return confirm('Disable self-registration? New users will not be able to sign up independently.')">
data-confirm="Disable self-registration? New users will not be able to sign up independently."
data-confirm-title="Disable Self-Registration" data-confirm-ok="Disable">
<i class="bi bi-toggle-on me-1"></i>Disable
</button>
{% else %}
@@ -461,13 +463,14 @@ function syncColorPicker(val) {
}
function removeLogo() {
if (!confirm('Remove the current logo?')) return;
document.getElementById('remove-logo-input').value = '1';
const initials = document.getElementById('logo-initials').value.substring(0, 2).toUpperCase();
document.getElementById('logo-preview-wrap').innerHTML =
`<span id="logo-preview-initials" style="font-family:'Space Mono',monospace;font-weight:700;font-size:18px;color:#fff;">${initials}</span>`;
const row = document.getElementById('remove-logo-row');
if (row) row.style.display = 'none';
confirmModal('Remove Logo', 'Remove the current logo? The initials fallback will be displayed instead.', 'Remove', 'btn-danger', () => {
document.getElementById('remove-logo-input').value = '1';
const initials = document.getElementById('logo-initials').value.substring(0, 2).toUpperCase();
document.getElementById('logo-preview-wrap').innerHTML =
`<span id="logo-preview-initials" style="font-family:'Space Mono',monospace;font-weight:700;font-size:18px;color:#fff;">${initials}</span>`;
const row = document.getElementById('remove-logo-row');
if (row) row.style.display = 'none';
});
}
</script>
{% endblock %}
+2 -1
View File
@@ -55,7 +55,8 @@
<a href="{{ url_for('admin.ticket_template_edit', tmpl_id=t.id) }}"
class="btn btn-secondary btn-sm" title="Edit"><i class="bi bi-pencil"></i></a>
<form method="POST" action="{{ url_for('admin.ticket_template_delete', tmpl_id=t.id) }}"
onsubmit="return confirm('Delete template &quot;{{ t.name }}&quot;?');" style="margin:0;">
data-confirm="Delete template {{ t.name }}? This cannot be undone."
data-confirm-title="Delete Template" data-confirm-ok="Delete" style="margin:0;">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<button type="submit" class="btn btn-sm"
style="background:rgba(248,113,113,.1);border:1px solid rgba(248,113,113,.2);color:var(--danger);"
+2 -1
View File
@@ -60,7 +60,8 @@
</a>
{% if u.id != current_user.id and u.is_active %}
<form method="POST" action="{{ url_for('admin.delete_user', user_id=u.id) }}"
onsubmit="return confirm('Deactivate {{ u.full_name }}?');">
data-confirm="Deactivate {{ u.full_name }}? They will no longer be able to log in."
data-confirm-title="Deactivate User" data-confirm-ok="Deactivate" data-confirm-class="btn-warning">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/> <button type="submit" class="btn btn-sm" style="background:rgba(248,113,113,.1);border:1px solid rgba(248,113,113,.2);color:var(--danger);">
<i class="bi bi-person-dash"></i>
</button>