show correct checkbox status
This commit is contained in:
parent
9238366137
commit
c5b21d1cef
3 changed files with 18 additions and 25 deletions
|
|
@ -21,7 +21,6 @@
|
||||||
pkgs.clippy
|
pkgs.clippy
|
||||||
pkgs.sqlite
|
pkgs.sqlite
|
||||||
pkgs.superhtml
|
pkgs.superhtml
|
||||||
pkgs.vscode-langservers-extracted
|
|
||||||
pkgs.rustfmt
|
pkgs.rustfmt
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,11 @@ struct IndexTemplate {
|
||||||
date: String,
|
date: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn range(bound: i32) -> Vec<i32> {
|
||||||
|
let iter = 0..bound;
|
||||||
|
iter.into_iter().collect()
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
#[template(path = "food-update.html")]
|
#[template(path = "food-update.html")]
|
||||||
struct FoodUpdateTemplate {
|
struct FoodUpdateTemplate {
|
||||||
|
|
|
||||||
|
|
@ -16,36 +16,25 @@
|
||||||
<button class="decrease">-</button>
|
<button class="decrease">-</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="checkboxes">
|
<div class="checkboxes">
|
||||||
|
{% for counter in self::range(10) %}
|
||||||
|
{% if loop.index as i32 <= food.target_servings %}
|
||||||
<label class="ok">
|
<label class="ok">
|
||||||
|
{% if loop.index as i32 <= food.actual_servings %}
|
||||||
<input type="checkbox" checked>
|
<input type="checkbox" checked>
|
||||||
</label>
|
{% else %}
|
||||||
<label class="ok">
|
|
||||||
<input type="checkbox">
|
<input type="checkbox">
|
||||||
|
{% endif %}
|
||||||
</label>
|
</label>
|
||||||
<label class="ok">
|
{% else %}
|
||||||
|
<label class="bad">
|
||||||
|
{% if loop.index as i32 <= food.actual_servings %}
|
||||||
<input type="checkbox" checked>
|
<input type="checkbox" checked>
|
||||||
</label>
|
{% else %}
|
||||||
<label class="bad">
|
|
||||||
<input type="checkbox" checked>
|
|
||||||
</label>
|
|
||||||
<label class="bad">
|
|
||||||
<input type="checkbox" checked>
|
|
||||||
</label>
|
|
||||||
<label class="bad">
|
|
||||||
<input type="checkbox">
|
|
||||||
</label>
|
|
||||||
<label class="bad">
|
|
||||||
<input type="checkbox">
|
|
||||||
</label>
|
|
||||||
<label class="bad">
|
|
||||||
<input type="checkbox">
|
|
||||||
</label>
|
|
||||||
<label class="bad">
|
|
||||||
<input type="checkbox">
|
|
||||||
</label>
|
|
||||||
<label class="bad">
|
|
||||||
<input type="checkbox">
|
<input type="checkbox">
|
||||||
|
{% endif %}
|
||||||
</label>
|
</label>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue