fix file deletion
This commit is contained in:
parent
9b49a8f088
commit
5f00e88c68
4 changed files with 18 additions and 5 deletions
|
@ -1183,13 +1183,14 @@ export class EventAuth {
|
||||||
// Add delete handler
|
// Add delete handler
|
||||||
const deleteButton = fileItem.querySelector('.text-error');
|
const deleteButton = fileItem.querySelector('.text-error');
|
||||||
if (deleteButton) {
|
if (deleteButton) {
|
||||||
deleteButton.addEventListener('click', async () => {
|
deleteButton.addEventListener('click', async (e) => {
|
||||||
|
e.preventDefault(); // Prevent any form submission
|
||||||
if (confirm('Are you sure you want to remove this file?')) {
|
if (confirm('Are you sure you want to remove this file?')) {
|
||||||
try {
|
try {
|
||||||
const fileToRemove = deleteButton.getAttribute('data-file');
|
const fileToRemove = deleteButton.getAttribute('data-file');
|
||||||
if (!fileToRemove) throw new Error('File not found');
|
if (!fileToRemove) throw new Error('File not found');
|
||||||
|
|
||||||
// Get the current event data to ensure we have the latest state
|
// Get the current event data
|
||||||
const currentEvent = await this.pb.collection('events').getOne(event.id);
|
const currentEvent = await this.pb.collection('events').getOne(event.id);
|
||||||
|
|
||||||
// Filter out the file to be removed
|
// Filter out the file to be removed
|
||||||
|
@ -1200,14 +1201,14 @@ export class EventAuth {
|
||||||
files: updatedFiles
|
files: updatedFiles
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update the event.files array in memory
|
// Update the local event object
|
||||||
event.files = updatedFiles;
|
event.files = updatedFiles;
|
||||||
|
|
||||||
// Remove the file item from the UI
|
// Remove the file item from the UI
|
||||||
fileItem.remove();
|
fileItem.remove();
|
||||||
|
|
||||||
// If no files left, show the "No files" message
|
// If no files left, show the "No files" message
|
||||||
if (updatedFiles.length === 0) {
|
if (!event.files || event.files.length === 0) {
|
||||||
currentFiles.innerHTML = '<span class="text-sm opacity-50">No files</span>';
|
currentFiles.innerHTML = '<span class="text-sm opacity-50">No files</span>';
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
@ -10,7 +10,12 @@ const { editor_title, form } = config.ui.tables.events;
|
||||||
<dialog id="eventEditor" class="modal">
|
<dialog id="eventEditor" class="modal">
|
||||||
<div class="modal-box w-11/12 max-w-4xl">
|
<div class="modal-box w-11/12 max-w-4xl">
|
||||||
<h3 class="font-bold text-lg mb-6">{editor_title}</h3>
|
<h3 class="font-bold text-lg mb-6">{editor_title}</h3>
|
||||||
<form class="space-y-6" id="eventForm" novalidate>
|
<form
|
||||||
|
class="space-y-6"
|
||||||
|
id="eventForm"
|
||||||
|
novalidate
|
||||||
|
onsubmit="event.preventDefault();"
|
||||||
|
>
|
||||||
<!-- Basic Info Section -->
|
<!-- Basic Info Section -->
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||||
<div class="form-control">
|
<div class="form-control">
|
||||||
|
|
0
src/components/reimbursement/Reimbursement.astro
Normal file
0
src/components/reimbursement/Reimbursement.astro
Normal file
7
src/pages/reimbursement.astro
Normal file
7
src/pages/reimbursement.astro
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
import Layout from "../layouts/Layout.astro";
|
||||||
|
---
|
||||||
|
|
||||||
|
<Layout>
|
||||||
|
<h1>Reimbursement</h1>
|
||||||
|
</Layout>
|
Loading…
Reference in a new issue