Recipe edit, we can now delete groups, steps and ingredients
This commit is contained in:
parent
d4962c98ff
commit
5ce3391466
11 changed files with 183 additions and 68 deletions
30
frontend/src/modal_dialog.rs
Normal file
30
frontend/src/modal_dialog.rs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
use futures::{future::FutureExt, pin_mut, select};
|
||||
use web_sys::{Element, HtmlDialogElement};
|
||||
|
||||
use crate::utils::{by_id, SelectExt};
|
||||
|
||||
use crate::on_click;
|
||||
|
||||
pub async fn show(message: &str) -> bool {
|
||||
let dialog: HtmlDialogElement = by_id("modal-dialog");
|
||||
let input_ok: Element = dialog.select(".ok");
|
||||
let input_cancel: Element = dialog.select(".cancel");
|
||||
|
||||
dialog.select::<Element>(".content").set_inner_html(message);
|
||||
|
||||
dialog.show_modal().unwrap();
|
||||
|
||||
let click_ok = on_click::OnClick::new(&input_ok).fuse();
|
||||
let click_cancel = on_click::OnClick::new(&input_cancel).fuse();
|
||||
|
||||
pin_mut!(click_ok, click_cancel);
|
||||
|
||||
let result = select! {
|
||||
() = click_ok => true,
|
||||
() = click_cancel => false,
|
||||
};
|
||||
|
||||
dialog.close();
|
||||
|
||||
result
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue