Benutzer, Ticketzuweißungen

This commit is contained in:
2026-03-23 03:12:08 +01:00
parent e75a2e5e20
commit 08391cdb6c
29 changed files with 592 additions and 111 deletions

View File

@@ -53,34 +53,39 @@ function initNewMachineCollapse() {
toggle.onclick = () => setOpen(body.hidden);
}
async function run() {
async function run(canEdit) {
const machines = await apiGet('/machines');
document.getElementById('machine-count').textContent = String(machines.length);
renderRows(machines);
const newCard = document.getElementById('machines-new-card');
if (newCard) newCard.hidden = !canEdit;
initNewMachineCollapse();
const formNew = document.getElementById('form-new-machine');
formNew.addEventListener('submit', async (e) => {
e.preventDefault();
const fd = new FormData(formNew);
const btn = formNew.querySelector('button[type="submit"]');
btn.disabled = true;
try {
const body = Object.fromEntries(fd.entries());
const created = await apiPost('/machines', {
name: body.name,
typ: body.typ,
seriennummer: body.seriennummer,
standort: body.standort,
listStatus: body.listStatus || '',
});
location.href = `/machine.html?id=${encodeURIComponent(created.id)}`;
} catch (err) {
alert(err.message || 'Anlegen fehlgeschlagen.');
btn.disabled = false;
}
});
if (canEdit) {
formNew.addEventListener('submit', async (e) => {
e.preventDefault();
const fd = new FormData(formNew);
const btn = formNew.querySelector('button[type="submit"]');
btn.disabled = true;
try {
const body = Object.fromEntries(fd.entries());
const created = await apiPost('/machines', {
name: body.name,
typ: body.typ,
seriennummer: body.seriennummer,
standort: body.standort,
listStatus: body.listStatus || '',
});
location.href = `/machine.html?id=${encodeURIComponent(created.id)}`;
} catch (err) {
alert(err.message || 'Anlegen fehlgeschlagen.');
btn.disabled = false;
}
});
}
const inp = document.getElementById('machine-filter');
const tbody = document.getElementById('machine-table-body');
@@ -95,10 +100,11 @@ async function run() {
async function init() {
const st = await guard({ activeNav: 'machines' });
if (!st) return;
const canEdit = st.user?.canEditCrm === true;
loadingEl.hidden = true;
mainEl.hidden = false;
try {
await run();
await run(canEdit);
} catch (e) {
if (isAuthRedirectError(e)) return;
showError(e.message || 'Fehler');