diff --git a/.idea/Compware.iml b/.idea/Compware.iml
new file mode 100644
index 0000000..cf84ae4
--- /dev/null
+++ b/.idea/Compware.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..6b84ce6
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index fc59556..0543bb0 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -7,7 +7,12 @@
-
+
+
+
+
+
+
@@ -28,26 +33,31 @@
}
+
+
- {
- "keyToString": {
- "RunOnceActivity.ShowReadmeOnStart": "true",
- "RunOnceActivity.git.unshallow": "true",
- "RunOnceActivity.rust.reset.selective.auto.import": "true",
- "git-widget-placeholder": "main",
- "node.js.detected.package.eslint": "true",
- "node.js.detected.package.tslint": "true",
- "node.js.selected.package.eslint": "(autodetect)",
- "node.js.selected.package.tslint": "(autodetect)",
- "nodejs_package_manager_path": "npm",
- "org.rust.cargo.project.model.PROJECT_DISCOVERY": "true",
- "org.rust.cargo.project.model.impl.CargoExternalSystemProjectAware.subscribe.first.balloon": "",
- "org.rust.first.attach.projects": "true",
- "vue.rearranger.settings.migration": "true"
+
+}]]>
@@ -97,6 +107,7 @@
1733407491778
+
diff --git a/src/app.rs b/src/app.rs
index 5ca104e..57153ae 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -1,7 +1,7 @@
use leptos::*;
use leptos_meta::*;
use crate::components::items_list::ItemsList;
-use crate::models::item::{Item, ReviewWithRating};
+use crate::models::item::Item;
use crate::nostr::NostrClient;
use tokio::sync::mpsc;
use uuid::Uuid;
diff --git a/src/components/editable_cell.rs b/src/components/editable_cell.rs
index a8f43ca..72d6c1e 100644
--- a/src/components/editable_cell.rs
+++ b/src/components/editable_cell.rs
@@ -9,7 +9,7 @@ pub fn EditableCell(
let handle_input = move |e: web_sys::Event| {
let new_value = event_target_value(&e);
- set_input_value(new_value.clone());
+ set_input_value.set(new_value.clone());
on_input(new_value);
};
diff --git a/src/components/items_list.rs b/src/components/items_list.rs
index e18fb78..ab09bc2 100644
--- a/src/components/items_list.rs
+++ b/src/components/items_list.rs
@@ -3,6 +3,9 @@ use crate::components::tag_editor::TagEditor;
use leptos::*;
use serde::Deserialize;
use uuid::Uuid;
+use leptos::logging::log;
+use crate::models::item::Item;
+use std::sync::{Arc, Mutex};
#[derive(Deserialize, Clone, Debug)]
struct WikidataSuggestion {
@@ -11,14 +14,6 @@ struct WikidataSuggestion {
description: Option,
}
-#[derive(Clone, Debug)]
-struct Item {
- id: String,
- name: String,
- description: String,
- tags: Vec<(String, String)>,
- wikidata_id: Option,
-}
#[component]
pub fn ItemsList(
@@ -32,7 +27,7 @@ pub fn ItemsList(
let fetch_wikidata_suggestions = move |query: String| {
spawn_local(async move {
if query.is_empty() {
- set_wikidata_suggestions(Vec::new());
+ set_wikidata_suggestions.set(Vec::new());
return;
}
@@ -44,7 +39,7 @@ pub fn ItemsList(
match gloo_net::http::Request::get(&url).send().await {
Ok(response) => {
if let Ok(data) = response.json::().await {
- set_wikidata_suggestions(data.search);
+ set_wikidata_suggestions.set(data.search);
}
}
Err(_) => log!("Failed to fetch Wikidata suggestions"),
@@ -87,13 +82,14 @@ pub fn ItemsList(
};
// Add a new item
- let add_item = move || {
+ let add_item = move |_: web_sys::MouseEvent|{
set_items.update(|items| {
items.push(Item {
id: Uuid::new_v4().to_string(),
name: String::new(),
description: String::new(),
tags: vec![],
+ reviews:vec![],
wikidata_id: None,
});
});
@@ -131,17 +127,24 @@ pub fn ItemsList(
/>
{move || {
- wikidata_suggestions.get().iter().map(|suggestion| {
+ let suggestions = wikidata_suggestions.get().to_vec();
+ suggestions.into_iter().map(|suggestion| {
+ // Clone all necessary fields upfront
+ let label_for_click = suggestion.label.clone();
+ let label_for_display = suggestion.label.clone();
+ let description = suggestion.description.clone().unwrap_or_default();
+ let id = suggestion.id.clone();
+
view! {
-
- { format!("{} - {}", suggestion.label, suggestion.description.clone().unwrap_or_default()) }
+ { format!("{} - {}", label_for_display, description) } // Use the cloned version for display
}
@@ -161,7 +164,7 @@ pub fn ItemsList(
// Actions
diff --git a/src/components/tag_editor.rs b/src/components/tag_editor.rs
index 20e1447..e38e436 100644
--- a/src/components/tag_editor.rs
+++ b/src/components/tag_editor.rs
@@ -1,19 +1,22 @@
use leptos::*;
+use std::sync::{Arc, Mutex};
+
+
#[component]
pub fn TagEditor(
tags: Vec<(String, String)>,
on_add: impl Fn(String, String) + 'static,
- on_remove: impl Fn(usize) + 'static,
+ on_remove: Arc>,
) -> impl IntoView {
let (key, set_key) = create_signal(String::new());
let (value, set_value) = create_signal(String::new());
- let add_tag = move || {
+ let add_tag = move |_| {
if !key.get().is_empty() && !value.get().is_empty() {
on_add(key.get(), value.get());
- set_key(String::new());
- set_value(String::new());
+ set_key.set(String::new());
+ set_value.set(String::new());
}
};
@@ -21,10 +24,16 @@ pub fn TagEditor(