diff --git a/src/components/items_list.rs b/src/components/items_list.rs index 1274ad5..19102c8 100644 --- a/src/components/items_list.rs +++ b/src/components/items_list.rs @@ -8,6 +8,17 @@ pub fn ItemsList(items: ReadSignal>) -> impl IntoView { // Create a signal for selected items let (selected_items_signal, set_selected_items) = create_signal(Vec::::new()); + // Function to toggle selection of an item + let toggle_selection = move |i: usize| { + set_selected_items.update(|items| { + if items.contains(&i) { + items.retain(|&x| x != i); + } else { + items.push(i); + } + }); + }; + view! {

{ "Items" }

@@ -18,18 +29,12 @@ pub fn ItemsList(items: ReadSignal>) -> impl IntoView { {"Select item for comparison"}
- { item.name.clone() } - { item.description.clone() } + { &item.name } - { &item.description }

    { "Tags:" }

    @@ -44,7 +49,7 @@ pub fn ItemsList(items: ReadSignal>) -> impl IntoView { }).collect::>()}
- }).collect::>()} + }).collect::>() } // Comparison Table @@ -65,8 +70,8 @@ pub fn ItemsList(items: ReadSignal>) -> impl IntoView { let item = &items.get()[i]; view! { - { item.name.clone() } - { item.description.clone() } + { &item.name } + { &item.description } {item.tags.iter().map(|(key, value)| view! { { key.clone() + ": " + value + " " } @@ -85,4 +90,4 @@ pub fn ItemsList(items: ReadSignal>) -> impl IntoView {
} -} \ No newline at end of file +}