"feat: Update database schema for myp.db and calendar template"
This commit is contained in:
parent
0b5a1f874d
commit
5c5b055c46
Binary file not shown.
Binary file not shown.
@ -1018,8 +1018,20 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
const formData = new FormData(e.target);
|
||||
const data = Object.fromEntries(formData);
|
||||
|
||||
// Lade-Indikator anzeigen
|
||||
const submitButton = this.querySelector('button[type="submit"]');
|
||||
const originalText = submitButton.textContent;
|
||||
submitButton.disabled = true;
|
||||
submitButton.innerHTML = `
|
||||
<svg class="animate-spin -ml-1 mr-3 h-4 w-4 text-white inline" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
|
||||
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
||||
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
||||
</svg>
|
||||
Wird erstellt...
|
||||
`;
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/calendar/events', {
|
||||
const response = await fetch('/api/calendar/event', {
|
||||
method: data.eventId ? 'PUT' : 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@ -1028,19 +1040,77 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
body: JSON.stringify(data)
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
if (response.ok) {
|
||||
calendar.refetchEvents();
|
||||
closeEventModal();
|
||||
document.getElementById('eventForm').reset();
|
||||
hideSmartRecommendation();
|
||||
|
||||
// Erfolgreiche Erstellung anzeigen
|
||||
if (result.message) {
|
||||
showSuccessNotification(result.message);
|
||||
} else {
|
||||
showSuccessNotification('Auftrag erfolgreich erstellt!');
|
||||
}
|
||||
} else {
|
||||
alert('Fehler beim Speichern des Events');
|
||||
throw new Error(result.error || 'Fehler beim Speichern des Events');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error:', error);
|
||||
alert('Fehler beim Speichern des Events');
|
||||
showErrorNotification(error.message || 'Fehler beim Speichern des Events');
|
||||
} finally {
|
||||
submitButton.disabled = false;
|
||||
submitButton.innerHTML = originalText;
|
||||
}
|
||||
});
|
||||
|
||||
function showSuccessNotification(message) {
|
||||
// Einfache Toast-Benachrichtigung
|
||||
const toast = document.createElement('div');
|
||||
toast.className = 'fixed top-4 right-4 bg-gradient-to-r from-green-500 to-green-600 text-white px-6 py-4 rounded-lg shadow-xl z-50 transform transition-all duration-300 translate-x-full';
|
||||
toast.innerHTML = `
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="w-6 h-6 bg-white/20 rounded-full flex items-center justify-center">
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/>
|
||||
</svg>
|
||||
</div>
|
||||
<span class="font-medium">${message}</span>
|
||||
</div>
|
||||
`;
|
||||
|
||||
document.body.appendChild(toast);
|
||||
setTimeout(() => toast.classList.remove('translate-x-full'), 100);
|
||||
setTimeout(() => {
|
||||
toast.classList.add('translate-x-full');
|
||||
setTimeout(() => toast.remove(), 300);
|
||||
}, 4000);
|
||||
}
|
||||
|
||||
function showErrorNotification(message) {
|
||||
const toast = document.createElement('div');
|
||||
toast.className = 'fixed top-4 right-4 bg-gradient-to-r from-red-500 to-red-600 text-white px-6 py-4 rounded-lg shadow-xl z-50 transform transition-all duration-300 translate-x-full';
|
||||
toast.innerHTML = `
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="w-6 h-6 bg-white/20 rounded-full flex items-center justify-center">
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
|
||||
</svg>
|
||||
</div>
|
||||
<span class="font-medium">${message}</span>
|
||||
</div>
|
||||
`;
|
||||
|
||||
document.body.appendChild(toast);
|
||||
setTimeout(() => toast.classList.remove('translate-x-full'), 100);
|
||||
setTimeout(() => {
|
||||
toast.classList.add('translate-x-full');
|
||||
setTimeout(() => toast.remove(), 300);
|
||||
}, 4000);
|
||||
}
|
||||
|
||||
// Global Functions
|
||||
window.refreshCalendar = function() {
|
||||
calendar.refetchEvents();
|
||||
|
Loading…
x
Reference in New Issue
Block a user