}
}
diff --git a/src/components/multi_entry.rs b/src/components/multi_entry.rs
index 41ad518..4bebba6 100644
--- a/src/components/multi_entry.rs
+++ b/src/components/multi_entry.rs
@@ -2,6 +2,7 @@ use crate::common::{InputType, ValueType};
use crate::components::ActionButton;
use leptos::prelude::*;
use std::collections::HashMap;
+use leptos::logging::log;
use uuid::Uuid;
// region Helper Functions
@@ -69,7 +70,7 @@ pub fn MultiEntry(
#[prop(optional, into)] description: Signal,
/// The data member that contains the list of entries within the `data_map`.
#[prop(into)]
- data_member: String,
+ data_member: Signal,
/// The data map that contains all the information. Data is found within this map using the
/// component's `data_member` input.
#[prop()]
@@ -80,26 +81,31 @@ pub fn MultiEntry(
) -> impl IntoView {
// Make the values within the list reactive. Each of these values should be a ValueType::Map,
// so we can pass these directly to the application.
- let data_reactive = RwSignal::new(
- data_map
- .get_untracked()
- .get(&data_member)
- .unwrap_or(&ValueType::List(None))
- .as_list().ok().flatten()
- .unwrap_or(Vec::new())
- );
-
- // This effect updates the data_map with any new values from the data_reactive list, every time
- // the data_reactive list is changed. This allows changes from within the Entry component to
- // bubble up to the data_map effectively.
- Effect::new(move |_| {
- let entry_list = data_reactive.get();
- data_map.update(|map| {
- map.insert(data_member.clone(), ValueType::List(Some(entry_list)));
- });
+ let data_list = Memo::new(move |_| {
+ data_map.with(|map| {
+ map.get(&data_member.get())
+ .and_then(|v| v.as_list().ok().flatten())
+ .unwrap_or_default()
+ })
});
+
+ // This effect updates the data_map with any new values from the data_list, every time
+ // the data_list is changed. This allows changes from within the Entry component to
+ // bubble up to the data_map effectively.
+ let update_parent_list = move |list| {
+ log!("Updating parent list using child list {:?}", list);
+ data_map.update(|map| {
+ map.insert(data_member.get(), ValueType::List(Some(list)));
+ });
+ };
- let add_entry = move |_| data_reactive.update(|list| list.push(new_entry()));
+ let add_entry = move |_| data_map.update(|map| {
+ log!("Adding new entry.");
+ let mut list = data_list.get_untracked();
+
+ list.push(new_entry());
+ map.insert(data_member.get(), ValueType::List(Some(list)));
+ });
view! {
@@ -112,33 +118,26 @@ pub fn MultiEntry(
// Render the entries
"You haven't added any entries yet."
}
}
>
}
}
diff --git a/src/components/tabs/sidebar.rs b/src/components/tabs/sidebar.rs
index 4ecaf33..4a2b7f0 100644
--- a/src/components/tabs/sidebar.rs
+++ b/src/components/tabs/sidebar.rs
@@ -54,8 +54,8 @@ pub fn TabSidebarList(
// Create a series of tabs based on a given list of names and paths.
view! {
-