v0.13-dockerP5

This commit is contained in:
2022-11-30 19:32:31 +05:30
parent d1ce4addda
commit 3a44bc375e
2 changed files with 44 additions and 4 deletions

View File

@@ -380,7 +380,9 @@ pub fn BookDB<G: Html>(cx: Scope, bookitem: BookUIProp) -> View<G> {
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<G: Html>(cx: Scope, bookitem: BookUIProp) -> View<G> {
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<G: Html>(cx: Scope, bookitem: BookUIProp) -> View<G> {
#[component]
async fn AddingUI<G: Html>(cx: Scope<'_>) -> View<G> {
let app_state = use_context::<AppState>(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::<DomNode>();
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::<DomNode>();
dom_node.remove_attribute("display");
} else {
let dom_node = node_ref.get::<DomNode>();
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<G: Html>(cx: Scope<'_>) -> View<G> {
let app_state = use_context::<AppState>(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::<DomNode>();
dom_node.set_attribute("display","none");
};
create_effect(cx, || {
if *app_state.displaying.get() == true {
let dom_node = node_ref.get::<DomNode>();
dom_node.remove_attribute("display");
} else {
let dom_node = node_ref.get::<DomNode>();
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"){