diff --git a/components/file_metadata.templ b/components/file_metadata.templ index d8dbc31..4cafbe2 100644 --- a/components/file_metadata.templ +++ b/components/file_metadata.templ @@ -74,9 +74,213 @@ func formatFileSize(size int64) string { } } +// Dialog component for confirmation dialogs +templ FileMetadataDialog(id string, title string, message string, confirmClass string, confirmText string, action string, fileID uint, fileName string, section string) { +
+ { message } +
+| { strconv.FormatUint(uint64(file.ID), 10) } | @@ -183,11 +404,11 @@ templ FileMetadataList(ctx context.Context, data FileMetadataListData) { - | @@ -265,6 +486,140 @@ func buildPaginationURL(data FileMetadataListData, page int) string { // FileMetadataDetails renders detailed information about a file templ FileMetadataDetails(ctx context.Context, data FileMetadataDetailsData) { @LayoutWithContext("File Details", ctx) { + +
| { strconv.FormatUint(uint64(file.ID), 10) } |
@@ -499,11 +1015,11 @@ templ FileMetadataSearch(ctx context.Context, data FileMetadataSearchData) {
- |
diff --git a/internal/web/handlers/file_metadata_handlers.go b/internal/web/handlers/file_metadata_handlers.go
index 09526d8..b2ce615 100644
--- a/internal/web/handlers/file_metadata_handlers.go
+++ b/internal/web/handlers/file_metadata_handlers.go
@@ -1,6 +1,7 @@
package handlers
import (
+ "fmt"
"net/http"
"strconv"
@@ -344,6 +345,8 @@ func (h *FileMetadataHandler) SearchFileMetadata(c *gin.Context) {
func (h *FileMetadataHandler) DeleteFileMetadata(c *gin.Context) {
userID := c.GetUint("userID")
+ fmt.Println("Deleting file metadata")
+
// Get file ID from URL parameter
fileID, err := strconv.ParseUint(c.Param("id"), 10, 64)
if err != nil {
@@ -373,6 +376,16 @@ func (h *FileMetadataHandler) DeleteFileMetadata(c *gin.Context) {
return
}
- // Redirect to the file list
- c.Redirect(http.StatusFound, "/files")
+ fmt.Println("File deleted successfully")
+
+ // Check if this is an HTMX request
+ isHtmxRequest := c.GetHeader("HX-Request") == "true"
+
+ if isHtmxRequest {
+ // For HTMX requests, just return a 200 status - client will handle UI updates
+ c.Status(http.StatusOK)
+ } else {
+ // For regular browser requests, redirect to the file list
+ c.Redirect(http.StatusFound, "/files")
+ }
}