fix(trash): add missing display fields to TrashedItemDto
Add category, icon_class, and icon_special_class fields to TrashedItemDto to fix trash view rendering issues. The frontend expects these fields to properly display file type information, icons, and deletion dates. - category: Human-readable file category (e.g., "Image", "Document") - icon_class: FontAwesome icon class for the file type - icon_special_class: Special CSS class for icon styling Fixes #107
This commit is contained in:
@@ -11,6 +11,12 @@ pub struct TrashedItemDto {
|
|||||||
pub original_path: String,
|
pub original_path: String,
|
||||||
pub trashed_at: DateTime<Utc>,
|
pub trashed_at: DateTime<Utc>,
|
||||||
pub days_until_deletion: i64,
|
pub days_until_deletion: i64,
|
||||||
|
/// Human-readable category (e.g., "Image", "Folder", "Document")
|
||||||
|
pub category: String,
|
||||||
|
/// FontAwesome icon class for the file type
|
||||||
|
pub icon_class: String,
|
||||||
|
/// Special CSS class for icon styling (e.g., "image-icon", "pdf-icon")
|
||||||
|
pub icon_special_class: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Request to move an item to trash
|
/// Request to move an item to trash
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ use std::sync::Arc;
|
|||||||
use tracing::{debug, error, info, instrument, warn};
|
use tracing::{debug, error, info, instrument, warn};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use crate::application::dtos::display_helpers::{
|
||||||
|
category_for, icon_class_for, icon_special_class_for,
|
||||||
|
};
|
||||||
use crate::application::dtos::trash_dto::TrashedItemDto;
|
use crate::application::dtos::trash_dto::TrashedItemDto;
|
||||||
use crate::application::ports::storage_ports::{FileReadPort, FileWritePort};
|
use crate::application::ports::storage_ports::{FileReadPort, FileWritePort};
|
||||||
use crate::application::ports::trash_ports::TrashUseCase;
|
use crate::application::ports::trash_ports::TrashUseCase;
|
||||||
@@ -72,6 +75,23 @@ impl TrashService {
|
|||||||
// Calculate days_until_deletion before moving item fields
|
// Calculate days_until_deletion before moving item fields
|
||||||
let days_until_deletion = item.days_until_deletion();
|
let days_until_deletion = item.days_until_deletion();
|
||||||
|
|
||||||
|
// Determine display fields based on item type
|
||||||
|
let (category, icon_class, icon_special_class) = match item.item_type() {
|
||||||
|
TrashedItemType::Folder => (
|
||||||
|
"Folder".to_string(),
|
||||||
|
"fas fa-folder".to_string(),
|
||||||
|
"folder-icon".to_string(),
|
||||||
|
),
|
||||||
|
TrashedItemType::File => {
|
||||||
|
let name = item.name();
|
||||||
|
// Use empty MIME type to leverage extension fallback
|
||||||
|
let category = category_for(name, "").to_string();
|
||||||
|
let icon_class = icon_class_for(name, "").to_string();
|
||||||
|
let icon_special_class = icon_special_class_for(name, "").to_string();
|
||||||
|
(category, icon_class, icon_special_class)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
TrashedItemDto {
|
TrashedItemDto {
|
||||||
id: item.id().to_string(),
|
id: item.id().to_string(),
|
||||||
original_id: item.original_id().to_string(),
|
original_id: item.original_id().to_string(),
|
||||||
@@ -83,6 +103,9 @@ impl TrashService {
|
|||||||
original_path: item.original_path().to_string(),
|
original_path: item.original_path().to_string(),
|
||||||
trashed_at: item.trashed_at(),
|
trashed_at: item.trashed_at(),
|
||||||
days_until_deletion,
|
days_until_deletion,
|
||||||
|
category,
|
||||||
|
icon_class,
|
||||||
|
icon_special_class,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,11 +62,32 @@ where
|
|||||||
FoR: FolderRepository,
|
FoR: FolderRepository,
|
||||||
{
|
{
|
||||||
async fn get_trash_items(&self, user_id: Uuid) -> Result<Vec<TrashedItemDto>> {
|
async fn get_trash_items(&self, user_id: Uuid) -> Result<Vec<TrashedItemDto>> {
|
||||||
|
use crate::application::dtos::display_helpers::{
|
||||||
|
category_for, icon_class_for, icon_special_class_for,
|
||||||
|
};
|
||||||
|
|
||||||
let items = self.trash_repository.get_trash_items(&user_id).await?;
|
let items = self.trash_repository.get_trash_items(&user_id).await?;
|
||||||
Ok(items
|
Ok(items
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|item| {
|
.map(|item| {
|
||||||
let days_until_deletion = item.days_until_deletion();
|
let days_until_deletion = item.days_until_deletion();
|
||||||
|
|
||||||
|
// Determine display fields based on item type
|
||||||
|
let (category, icon_class, icon_special_class) = match item.item_type() {
|
||||||
|
TrashedItemType::Folder => (
|
||||||
|
"Folder".to_string(),
|
||||||
|
"fas fa-folder".to_string(),
|
||||||
|
"folder-icon".to_string(),
|
||||||
|
),
|
||||||
|
TrashedItemType::File => {
|
||||||
|
let name = item.name();
|
||||||
|
let category = category_for(name, "").to_string();
|
||||||
|
let icon_class = icon_class_for(name, "").to_string();
|
||||||
|
let icon_special_class = icon_special_class_for(name, "").to_string();
|
||||||
|
(category, icon_class, icon_special_class)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
TrashedItemDto {
|
TrashedItemDto {
|
||||||
id: item.id().to_string(),
|
id: item.id().to_string(),
|
||||||
original_id: item.original_id().to_string(),
|
original_id: item.original_id().to_string(),
|
||||||
@@ -78,6 +99,9 @@ where
|
|||||||
original_path: item.original_path().to_string(),
|
original_path: item.original_path().to_string(),
|
||||||
trashed_at: item.trashed_at(),
|
trashed_at: item.trashed_at(),
|
||||||
days_until_deletion,
|
days_until_deletion,
|
||||||
|
category,
|
||||||
|
icon_class,
|
||||||
|
icon_special_class,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect())
|
.collect())
|
||||||
|
|||||||
Reference in New Issue
Block a user