Recipe can now be scheduled
This commit is contained in:
parent
ae6da1a5ae
commit
fbef990022
18 changed files with 233 additions and 51 deletions
|
|
@ -7,12 +7,26 @@ use crate::{
|
|||
};
|
||||
|
||||
pub async fn show(element_selector: &str) -> bool {
|
||||
show_and_initialize(element_selector, async |_| {}).await
|
||||
show_and_initialize(element_selector, async |_| Some(()))
|
||||
.await
|
||||
.is_some()
|
||||
}
|
||||
|
||||
pub async fn show_and_initialize<T>(element_selector: &str, initializer: T) -> bool
|
||||
pub async fn show_and_initialize<T, U>(element_selector: &str, initializer: T) -> Option<U>
|
||||
where
|
||||
T: AsyncFn(Element),
|
||||
T: AsyncFn(Element) -> U,
|
||||
{
|
||||
show_and_initialize_with_ok(element_selector, initializer, |_, result| result).await
|
||||
}
|
||||
|
||||
pub async fn show_and_initialize_with_ok<T, V, W, U>(
|
||||
element_selector: &str,
|
||||
initializer: T,
|
||||
ok: V,
|
||||
) -> Option<W>
|
||||
where
|
||||
T: AsyncFn(Element) -> U,
|
||||
V: Fn(Element, U) -> W,
|
||||
{
|
||||
let dialog: HtmlDialogElement = by_id("modal-dialog");
|
||||
|
||||
|
|
@ -24,7 +38,7 @@ where
|
|||
let element: Element = selector_and_clone(element_selector);
|
||||
content_element.set_inner_html("");
|
||||
content_element.append_child(&element).unwrap();
|
||||
initializer(element).await;
|
||||
let init_result = initializer(element.clone()).await;
|
||||
|
||||
dialog.show_modal().unwrap();
|
||||
|
||||
|
|
@ -34,8 +48,8 @@ where
|
|||
pin_mut!(click_ok, click_cancel);
|
||||
|
||||
let result = select! {
|
||||
() = click_ok => true,
|
||||
() = click_cancel => false,
|
||||
() = click_ok => Some(ok(element, init_result)),
|
||||
() = click_cancel => None,
|
||||
};
|
||||
|
||||
dialog.close();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue