Statistik-Bereich um Tab für Projekte/Baugruppen erweitern

This commit is contained in:
Marcel Diegelmann 2026-02-12 12:46:59 +01:00
parent 74513b748d
commit d67e93064c
18 changed files with 754 additions and 1 deletions

View file

@ -0,0 +1,45 @@
import { Controller } from '@hotwired/stimulus';
export default class extends Controller {
static values = {
url: String,
confirmMsg: String,
successMsg: String,
errorMsg: String
}
static targets = ["count"]
async cleanup(event) {
event.preventDefault();
if (!confirm(this.confirmMsgValue)) {
return;
}
try {
const response = await fetch(this.urlValue, {
method: 'POST',
headers: {
'X-Requested-With': 'XMLHttpRequest'
}
});
if (response.ok) {
const data = await response.json();
alert(this.successMsgValue.replace('%count%', data.count));
// Update the count displayed in the UI
if (this.hasCountTarget) {
this.countTarget.innerText = '0';
}
// Reload page to reflect changes if needed, or just let the user see 0
window.location.reload();
} else {
alert(this.errorMsgValue);
}
} catch (error) {
console.error('Cleanup failed:', error);
alert(this.errorMsgValue);
}
}
}