feat: add AJAX functionality to delete project updates and announcements

This commit is contained in:
Ümit Tunç
2026-07-30 17:39:05 +03:00
parent cc750fcb1e
commit dcda744b4a
3 changed files with 74 additions and 3 deletions
+46 -3
View File
@@ -679,9 +679,15 @@ gantt
<h3 class="text-sm font-bold text-slate-900 dark:text-white">
{{ $update->title }}
</h3>
<span class="text-[11px] font-semibold text-slate-400">
{{ $update->created_at->format('d.m.Y H:i') }}
</span>
<div class="flex items-center gap-3">
<span class="text-[11px] font-semibold text-slate-400">
{{ $update->created_at->format('d.m.Y H:i') }}
</span>
<button onclick="deleteUpdateAjax({{ $update->id }}, this)" title="Duyuruyu Sil" class="px-2 py-1 rounded-lg bg-red-50 hover:bg-red-100 text-red-600 dark:bg-red-950/40 dark:hover:bg-red-900/60 dark:text-red-400 font-bold text-xs transition-all flex items-center gap-1 border border-red-200 dark:border-red-800/40">
<i data-lucide="trash-2" class="w-3.5 h-3.5"></i>
<span>Sil</span>
</button>
</div>
</div>
<p class="text-xs text-slate-600 dark:text-slate-300 leading-relaxed whitespace-pre-line">
@@ -972,6 +978,43 @@ gantt
});
}
// AJAX Delete Announcement / Update
function deleteUpdateAjax(updateId, btnEl) {
if (!confirm('Bu duyuruyu silmek istediğinize emin misiniz?')) return;
fetch('{{ route("projects.admin.delete-update", $project->slug) }}', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content'),
'Accept': 'application/json',
'X-Requested-With': 'XMLHttpRequest'
},
body: JSON.stringify({
update_id: updateId
})
})
.then(res => res.json())
.then(data => {
if (data.success) {
const card = btnEl.closest('.relative.group');
if (card) {
card.style.transition = 'all 0.3s ease';
card.style.opacity = '0';
card.style.transform = 'scale(0.95)';
setTimeout(() => card.remove(), 300);
}
showToast(data.message, 'success');
} else {
showToast('Duyuru silinemedi.', 'error');
}
})
.catch(err => {
console.error('AJAX Error:', err);
showToast('Bağlantı hatası.', 'error');
});
}
// Dynamic UI Updates
function updateProgressUI(pct) {
const valEl = document.getElementById('progress-percent-val');