Add a calendar to schedule a recipe to a chosen date (WIP)
This commit is contained in:
parent
d9449de02b
commit
9d3f9e9c60
15 changed files with 441 additions and 62 deletions
|
|
@ -1,16 +1,39 @@
|
|||
use futures::{future::FutureExt, pin_mut, select};
|
||||
use web_sys::{Element, HtmlDialogElement};
|
||||
|
||||
use crate::utils::{by_id, SelectorExt};
|
||||
use crate::{
|
||||
on_click,
|
||||
utils::{by_id, selector_and_clone, SelectorExt},
|
||||
};
|
||||
|
||||
use crate::on_click;
|
||||
pub enum DialogContent<'a, T>
|
||||
where
|
||||
T: Fn(&Element),
|
||||
{
|
||||
Text(&'a str),
|
||||
CloneFromElement(&'a str, T),
|
||||
}
|
||||
|
||||
pub async fn show(message: &str) -> bool {
|
||||
pub async fn show<T>(content: DialogContent<'_, T>) -> bool
|
||||
where
|
||||
T: Fn(&Element),
|
||||
{
|
||||
let dialog: HtmlDialogElement = by_id("modal-dialog");
|
||||
|
||||
let input_ok: Element = dialog.selector(".ok");
|
||||
let input_cancel: Element = dialog.selector(".cancel");
|
||||
|
||||
dialog.selector::<Element>(".content").set_inner_html(message);
|
||||
let content_element = dialog.selector::<Element>(".content");
|
||||
|
||||
match content {
|
||||
DialogContent::Text(message) => content_element.set_inner_html(message),
|
||||
DialogContent::CloneFromElement(element_selector, initilizer) => {
|
||||
let element: Element = selector_and_clone(element_selector);
|
||||
content_element.set_inner_html("");
|
||||
content_element.append_child(&element).unwrap();
|
||||
initilizer(&element);
|
||||
}
|
||||
}
|
||||
|
||||
dialog.show_modal().unwrap();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue