diff --git a/src/components/multi_entry.rs b/src/components/multi_entry.rs index 6a6ce80..8f7449b 100644 --- a/src/components/multi_entry.rs +++ b/src/components/multi_entry.rs @@ -75,8 +75,8 @@ pub fn MultiEntry( #[prop()] data_map: RwSignal>, /// The type and order of the inputs for each `Entry` component within this `MultiEntry` component. - #[prop(optional)] - schema: Vec, + #[prop(optional, into)] + schema: Signal>, ) -> 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. @@ -85,9 +85,8 @@ pub fn MultiEntry( .get_untracked() .get(&data_member) .unwrap_or(&ValueType::List(None)) - .as_list() - .unwrap_or(Some(Vec::::new())) - .unwrap_or(Vec::new()), + .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 @@ -103,42 +102,51 @@ pub fn MultiEntry( let add_entry = move |_| data_reactive.update(|list| list.push(new_entry())); view! { -
- {label} - - {description} - +
+
+ {label} + + {description} + +
// Render the entries - - } + "You haven't added any entries yet."
} - /> + > + + } + } + /> +
"Add entry" @@ -181,12 +189,12 @@ fn Entry( data_map: RwSignal>, /// The schema of this entry. Should contain all information about what inputs to use and what /// data members those inputs modify. - #[prop()] - schema: Vec, + #[prop(into)] + schema: Signal>, ) -> impl IntoView { view! {
- {schema.iter() + {schema.get().iter() .map(|input_type| { input_type.clone().into_view(data_map.clone()) }).collect_view()