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.sqlite
|
||||
pkgs.superhtml
|
||||
pkgs.vscode-langservers-extracted
|
||||
pkgs.rustfmt
|
||||
];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -36,6 +36,11 @@ struct IndexTemplate {
|
|||
date: String,
|
||||
}
|
||||
|
||||
fn range(bound: i32) -> Vec<i32> {
|
||||
let iter = 0..bound;
|
||||
iter.into_iter().collect()
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "food-update.html")]
|
||||
struct FoodUpdateTemplate {
|
||||
|
|
|
|||
|
|
@ -16,36 +16,25 @@
|
|||
<button class="decrease">-</button>
|
||||
</div>
|
||||
<div class="checkboxes">
|
||||
{% for counter in self::range(10) %}
|
||||
{% if loop.index as i32 <= food.target_servings %}
|
||||
<label class="ok">
|
||||
{% if loop.index as i32 <= food.actual_servings %}
|
||||
<input type="checkbox" checked>
|
||||
</label>
|
||||
<label class="ok">
|
||||
{% else %}
|
||||
<input type="checkbox">
|
||||
{% endif %}
|
||||
</label>
|
||||
<label class="ok">
|
||||
{% else %}
|
||||
<label class="bad">
|
||||
{% if loop.index as i32 <= food.actual_servings %}
|
||||
<input type="checkbox" checked>
|
||||
</label>
|
||||
<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">
|
||||
{% else %}
|
||||
<input type="checkbox">
|
||||
{% endif %}
|
||||
</label>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue