From 3a44bc375eaf856c5387cfa5e07d46399e28923b Mon Sep 17 00:00:00 2001 From: Vinod J M Date: Wed, 30 Nov 2022 19:32:31 +0530 Subject: [PATCH] v0.13-dockerP5 --- backend/api/src/lib.rs | 2 ++ frontend/src/main.rs | 46 ++++++++++++++++++++++++++++++++++++++---- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/backend/api/src/lib.rs b/backend/api/src/lib.rs index 2283ecd..251b2ab 100644 --- a/backend/api/src/lib.rs +++ b/backend/api/src/lib.rs @@ -485,6 +485,8 @@ async fn create_by_isbn( isbn: doc_sent.isbn.unwrap_or(vec!["".to_string()]), }; booksman_search::create_or_update_book(book_meili, meili_client).await; + } else { + println!("ISBN Not found : {}",isbnstring); } } return "Done"; diff --git a/frontend/src/main.rs b/frontend/src/main.rs index e809ea5..d89ec80 100644 --- a/frontend/src/main.rs +++ b/frontend/src/main.rs @@ -380,7 +380,9 @@ pub fn BookDB(cx: Scope, bookitem: BookUIProp) -> View { img(src=coverurl,width="100") (format!("{:?}",loctitle)) + br{} (format!("{:?}",locauthors)) + br{} (format!("{:?}",locdesc)) button(class="delete", on:click=handle_delete){ "-" } @@ -460,9 +462,10 @@ pub fn BookOL(cx: Scope, bookitem: BookUIProp) -> View { div(class="card"){ img(src=coverurl,width="100") - (format!("{:?}",loctitle)) + br{} (format!("{:?}",locauthors)) + br{} (format!("{:?}",locdesc)) button(class="add", on:click=handle_add){ "+" } } @@ -474,6 +477,10 @@ pub fn BookOL(cx: Scope, bookitem: BookUIProp) -> View { #[component] async fn AddingUI(cx: Scope<'_>) -> View { let app_state = use_context::(cx); + + let node_ref = create_node_ref(cx); + + let inp_title = create_signal(cx, (*app_state.addingbook.get()).clone().title); let inp_olkey = create_signal(cx, (*app_state.addingbook.get()).clone().open_library_key.unwrap_or("".to_string())); let inp_editioncount = create_signal(cx, (*app_state.addingbook.get()).clone().edition_count.unwrap_or(0).to_string()); @@ -493,7 +500,7 @@ let inp_time = create_signal(cx, (*app_state.addingbook.get()).clone().time.unwr let inp_isbn = create_signal(cx, (*app_state.addingbook.get()).clone().isbn.unwrap_or(vec!["".to_string()]).join(", ")); create_effect(cx, || { - info!("{:?}",*app_state.addingbook.get()); +// info!("{:?}",*app_state.addingbook.get()); inp_title.set((*app_state.addingbook.get()).clone().title); inp_olkey.set((*app_state.addingbook.get()).clone().open_library_key.unwrap_or("".to_string())); inp_editioncount.set((*app_state.addingbook.get()).clone().edition_count.unwrap_or(0).to_string()); @@ -512,9 +519,14 @@ inp_author.set((*app_state.addingbook.get()).clone().author_name.unwrap_or(vec![ inp_time.set((*app_state.addingbook.get()).clone().time.unwrap_or(vec!["".to_string()]).join(", ")); inp_isbn.set((*app_state.addingbook.get()).clone().isbn.unwrap_or(vec!["".to_string()]).join(", ")); }); + let handle_cancel = |_| { app_state.updating.set(false); app_state.adding.set(false); + + let dom_node = node_ref.get::(); + dom_node.set_attribute("display","none"); + }; let handle_add = |_| { @@ -547,6 +559,7 @@ info!("Adding book"); isbn: Some(isbns), }; + if *app_state.updating.get() == false { spawn_local(async move { let temp = add_book(record).await.unwrap(); @@ -565,11 +578,22 @@ info!("Adding book"); }; + + create_effect(cx, || { + if *app_state.updating.get() == true || *app_state.adding.get() == true { + let dom_node = node_ref.get::(); + dom_node.remove_attribute("display"); + } else { + let dom_node = node_ref.get::(); + dom_node.set_attribute("display","none"); + } + }); + view! {cx, (if *app_state.adding.get() == true || *app_state.updating.get() == true { view!{ cx, - div(class="modal-box"){ + div(class="modal-box",ref=node_ref){ div(class="modal-content"){ p { @@ -612,16 +636,30 @@ async fn SelectedUI(cx: Scope<'_>) -> View { let app_state = use_context::(cx); let displ_book = create_signal(cx, (*app_state.displayingbook.get()).clone()); let coverurl = create_signal(cx, app_state.displayingbook.get().clone().cover.clone().unwrap().to_string().clone()); + let node_ref = create_node_ref(cx); let handle_close = move |_| { app_state.displaying.set(false); + let dom_node = node_ref.get::(); + dom_node.set_attribute("display","none"); }; + + create_effect(cx, || { + if *app_state.displaying.get() == true { + let dom_node = node_ref.get::(); + dom_node.remove_attribute("display"); + } else { + let dom_node = node_ref.get::(); + dom_node.set_attribute("display","none"); + } + }); + view! {cx, (if *app_state.displaying.get() == true { view!{ cx, - div(class="modal-box"){ + div(class="modal-box", ref=node_ref){ div(class="modal-content"){ p{ div(class="select-book"){