use autoincrement for IDs
This commit is contained in:
+4
-4
@@ -282,7 +282,7 @@ fn item_groups<'a>(items: &'a [Item], categories: &[Category]) -> Vec<(String, V
|
||||
for category in categories {
|
||||
let items_in_category = items
|
||||
.iter()
|
||||
.filter(|item| item.category_id.as_deref() == Some(category.id.as_str()))
|
||||
.filter(|item| item.category_id == Some(category.id))
|
||||
.collect::<Vec<_>>();
|
||||
if !items_in_category.is_empty() {
|
||||
groups.push((category.name.clone(), items_in_category));
|
||||
@@ -359,7 +359,7 @@ fn item_row(item: &Item, categories: &[Category], csrf_token: &str) -> Markup {
|
||||
input name="note" value=(item.note) maxlength="120";
|
||||
label { "Category" }
|
||||
select name="category_id" {
|
||||
(category_options(categories, item.category_id.as_deref()))
|
||||
(category_options(categories, item.category_id))
|
||||
}
|
||||
button class="button button-small button-secondary" type="submit" { "Save" }
|
||||
}
|
||||
@@ -377,7 +377,7 @@ fn item_row(item: &Item, categories: &[Category], csrf_token: &str) -> Markup {
|
||||
}
|
||||
}
|
||||
|
||||
fn category_options(categories: &[Category], selected: Option<&str>) -> Markup {
|
||||
fn category_options(categories: &[Category], selected: Option<i64>) -> Markup {
|
||||
html! {
|
||||
@if selected.is_none() {
|
||||
option value="" selected { "No category" }
|
||||
@@ -385,7 +385,7 @@ fn category_options(categories: &[Category], selected: Option<&str>) -> Markup {
|
||||
option value="" { "No category" }
|
||||
}
|
||||
@for category in categories {
|
||||
@if selected == Some(category.id.as_str()) {
|
||||
@if selected == Some(category.id) {
|
||||
option value=(category.id) selected { (category.name) }
|
||||
} @else {
|
||||
option value=(category.id) { (category.name) }
|
||||
|
||||
Reference in New Issue
Block a user