mirror of
https://github.com/zaphar/kitchen.git
synced 2025-07-22 19:40:14 -04:00
Link count of recipe to state in the service.
This commit is contained in:
parent
c212a453e3
commit
866483aa98
@ -30,9 +30,8 @@ fn recipe_check_box(props: RecipeCheckBoxProps) -> View<G> {
|
||||
// the `view!` macro.
|
||||
let i = props.i;
|
||||
let id_as_str = Rc::new(format!("{}", i));
|
||||
let id_cloned = id_as_str.clone();
|
||||
let id_cloned_2 = id_as_str.clone();
|
||||
let count = Signal::new(String::from("0"));
|
||||
let count = Signal::new(format!("{}", app_service.get_recipe_count_by_index(i)));
|
||||
view! {
|
||||
input(type="number", min="0", bind:value=count.clone(), name="recipe_id", value=id_as_str.clone(), on:change=move |_| {
|
||||
let mut app_service = app_service.clone();
|
||||
|
@ -86,6 +86,10 @@ impl AppService {
|
||||
self.menu_list.set(v);
|
||||
}
|
||||
|
||||
pub fn get_recipe_count_by_index(&self, i: usize) -> usize {
|
||||
self.menu_list.get().get(&i).map(|i| *i).unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn get_recipes(&self) -> Signal<Vec<(usize, Recipe)>> {
|
||||
self.recipes.clone()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user