From 8417713aa1286789ca740d042640802d01e0a103 Mon Sep 17 00:00:00 2001 From: Lucas Vas Date: Thu, 5 Feb 2026 12:03:48 -0500 Subject: [PATCH] feat: add delete button --- src/components/multi_entry.rs | 64 ++++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 16 deletions(-) diff --git a/src/components/multi_entry.rs b/src/components/multi_entry.rs index 80d34fe..cb03016 100644 --- a/src/components/multi_entry.rs +++ b/src/components/multi_entry.rs @@ -3,6 +3,7 @@ use crate::components::ActionButton; use leptos::prelude::*; use std::collections::HashMap; use leptos::logging::log; +use leptos_icons::Icon; use uuid::Uuid; // region Helper Functions @@ -12,6 +13,13 @@ fn get_uuid_from_map(map: &HashMap) -> Option { map.get("uuid")?.as_string().unwrap_or(None) } +fn get_uuid(vt: ValueType) -> Option { + vt.as_map().ok().flatten().unwrap_or_default() + .get("uuid")? + .as_string() + .ok().flatten() +} + /// Updates an Entry within the given `Vec`. fn update_entry_list(list: &mut Vec, data: &HashMap) { if let Some(uuid) = get_uuid_from_map(&data) { @@ -115,7 +123,7 @@ pub fn MultiEntry( {description} -
+
// Render the entries } + + view! { + + } } /> @@ -191,18 +212,29 @@ fn Entry( #[prop(into)] schema: Signal>, /// The unique ID for this entry. #[prop(into)] id: Signal, + /// The function to run when the delete button is clicked. + #[prop(into)] on_delete: Callback<()>, ) -> impl IntoView { view! { -
- {move || schema - .get() - .iter() - .map(|input_type| - input_type - .clone() - .into_view(data_map.clone(), id.get()) - ) - .collect_view()} +
+ // Delete button +
+ +
+ + // Input section +
+ {move || { + schema + .get() + .iter() + .map(|input_type| input_type.clone().into_view(data_map.clone(), id.get())) + .collect_view() + }} +
} }