Add ticket status setter and prevent draft text loss
- Set ticket state (Offen / In Bearbeitung / Warten auf Schließen / Geschlossen) from the ticket detail page via a live PUT to Zammad; pending-close gets a default pending time and the change is synced back so it isn't flagged as an external change - Replace the disruptive meta-refresh with a JS auto-refresh that pauses while a text field has unsent content or focus - Persist reply/new-ticket drafts to localStorage and restore them after a reload or accidental navigation Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
// Allgemeines Verhalten: Entwurf-Speicherung + ungefährlicher Auto-Refresh.
|
||||
(function () {
|
||||
// --- 1) Entwürfe sichern (überlebt Reload / versehentliches Wegnavigieren) ---
|
||||
function draftKey(el) {
|
||||
return "episupport-draft:" + location.pathname + ":" + (el.name || el.id || "x");
|
||||
}
|
||||
var drafts = document.querySelectorAll("[data-draft]");
|
||||
drafts.forEach(function (el) {
|
||||
try {
|
||||
var saved = localStorage.getItem(draftKey(el));
|
||||
if (saved && !el.value) el.value = saved;
|
||||
} catch (e) {}
|
||||
el.addEventListener("input", function () {
|
||||
try {
|
||||
if (el.value) localStorage.setItem(draftKey(el), el.value);
|
||||
else localStorage.removeItem(draftKey(el));
|
||||
} catch (e) {}
|
||||
});
|
||||
});
|
||||
// Beim Absenden die zugehörigen Entwürfe löschen
|
||||
document.querySelectorAll("form").forEach(function (form) {
|
||||
form.addEventListener("submit", function () {
|
||||
form.querySelectorAll("[data-draft]").forEach(function (el) {
|
||||
try { localStorage.removeItem(draftKey(el)); } catch (e) {}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// --- 2) Auto-Refresh, aber NIE während des Tippens/ungesendeten Texts ---
|
||||
var INTERVAL = 120000; // 2 Minuten
|
||||
function hasUnsavedInput() {
|
||||
var a = document.activeElement;
|
||||
if (a && /^(TEXTAREA|INPUT|SELECT)$/.test(a.tagName)) return true;
|
||||
var fields = document.querySelectorAll("textarea, input[type=text], input:not([type])");
|
||||
for (var i = 0; i < fields.length; i++) {
|
||||
if ((fields[i].value || "").trim() !== "") return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
setInterval(function () {
|
||||
if (!hasUnsavedInput()) location.reload();
|
||||
}, INTERVAL);
|
||||
})();
|
||||
@@ -136,6 +136,10 @@ table.tickets tr.row-unseen td:first-child { box-shadow: inset 3px 0 0 var(--acc
|
||||
.state-new { background: #fff3d6; color: #8a6300; }
|
||||
[class^="state-"].state-pending\ reminder, .state-pending { background: #e6f0fd; color: #1c54a8; }
|
||||
|
||||
.state-form { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: 0 1.1rem 1rem; }
|
||||
.state-form label { font-size: .85rem; font-weight: 600; color: #44525e; }
|
||||
.state-form select { font: inherit; padding: .4rem .55rem; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
|
||||
|
||||
.meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: .4rem 2rem; padding: 1rem 1.1rem; margin: 0; }
|
||||
.meta div { display: flex; justify-content: space-between; border-bottom: 1px dotted var(--line); padding: .25rem 0; }
|
||||
.meta dt { color: var(--muted); margin: 0; }
|
||||
|
||||
Reference in New Issue
Block a user