+* Finish all local storage API (remove scheduled, add ingredient, etc..)
+* Find an elegant/global way to adapt the quantities to servings (e.g. shopping list)
* FIX: when the event blur is triggered when changing page, the async process doesn't finish all the time
* User can change default_servings in profile
+* Add a way to retrieve a backup of the database (only if admin)
+ * Maybe make a dev-page with logs and other tools/information
* Can choose servings number in recipe view
* Default number is the user setting user.default_servings
* A symbol show the native recipe servings number
* Define the UI (mockups).
* Two CSS: one for desktop and one for mobile
* Use CSS flex/grid to define a good design/layout
+* CSS for dark mode + autodetect
* CSS for toast and modal dialog
-* Calendar: Choose the first day of the week
+* Calendar: Choose the first day of the week
+* i18n: prefix uri with the language: /fr/recipe/view/2
* Make a search page
Use FTS5:
https://sqlite.org/fts5.html
use ron::{
de::from_reader,
- ser::{to_writer_pretty, PrettyConfig},
+ ser::{PrettyConfig, to_writer_pretty},
};
use serde::{Deserialize, Serialize};
)
}),
Err(_) => {
- let file = File::create(consts::FILE_CONF).unwrap_or_else(|error| {
+ let mut file = File::create(consts::FILE_CONF).unwrap_or_else(|error| {
panic!(
"Failed to create default configuration file {}: {}",
consts::FILE_CONF,
let default_config = Config::default();
- to_writer_pretty(file, &default_config, PrettyConfig::new()).unwrap_or_else(|error| {
- panic!(
- "Failed to write default configuration file {}: {}",
- consts::FILE_CONF,
- error
- )
- });
+ to_writer_pretty(&mut file, &default_config, PrettyConfig::new()).unwrap_or_else(
+ |error| {
+ panic!(
+ "Failed to write default configuration file {}: {}",
+ consts::FILE_CONF,
+ error
+ )
+ },
+ );
default_config
}
{
Err(Error::Database(error))
if error.code() == Some(std::borrow::Cow::Borrowed("2067"))
- && error.message() == "UNIQUE constraint failed: RecipeScheduled.user_id, RecipeScheduled.recipe_id, RecipeScheduled.date" =>
+ && error.message()
+ == "UNIQUE constraint failed: RecipeScheduled.user_id, RecipeScheduled.recipe_id, RecipeScheduled.date" =>
{
Ok(AddScheduledRecipeResult::RecipeAlreadyScheduledAtThisDate)
}
- Err(error) => {
- Err(DBError::from(error))
- }
+ Err(error) => Err(DBError::from(error)),
Ok(insert_result) => {
-
if add_ingredients_to_shopping_list {
sqlx::query(
r#"
INNER JOIN [Group] ON [Group].[id] = [Step].[group_id]
INNER JOIN [Recipe] ON [Recipe].[id] = [Group].[recipe_id]
WHERE [Recipe].[id] = $1
- "#)
- .bind(recipe_id)
- .bind(user_id)
- .bind(insert_result.last_insert_rowid())
- .bind(servings)
- .execute(&mut *tx)
- .await?;
+ "#,
+ )
+ .bind(recipe_id)
+ .bind(user_id)
+ .bind(insert_result.last_insert_rowid())
+ .bind(servings)
+ .execute(&mut *tx)
+ .await?;
}
tx.commit().await?;
-use axum::Error;
use chrono::{Duration, prelude::*};
use rand::distr::{Alphanumeric, SampleString};
use sqlx::Sqlite;
edition = "2024"
[dependencies]
-ron = "0.8"
+ron = "0.8" # Can't upgrade to 0.9 because of https://github.com/ron-rs/ron/issues/561.
serde = { version = "1.0", features = ["derive"] }
chrono = { version = "0.4", features = ["serde"] }
chrono = { version = "0.4", features = ["serde", "unstable-locales"] }
-ron = "0.8"
+ron = "0.8" # Can't upgrade to 0.9 because of https://github.com/ron-rs/ron/issues/561.
serde = { version = "1.0", features = ["derive"] }
serde_html_form = "0.2"
thiserror = "2"
use std::{cell::RefCell, rc::Rc};
-use chrono::{offset::Local, Datelike, Days, Months, NaiveDate, Weekday};
+use chrono::{Datelike, Days, Months, NaiveDate, Weekday, offset::Local};
use common::{ron_api, utils::substitute_with_names};
use gloo::{
console::log,
modal_dialog,
recipe_scheduler::RecipeScheduler,
request,
- utils::{by_id, get_locale, selector, selector_all, SelectorExt},
+ utils::{SelectorExt, by_id, get_locale, selector, selector_all},
};
struct CalendarStateInternal {
EventListener::new(&days, "click", move |event| {
let target: Element = event.target().unwrap().dyn_into().unwrap();
- log!(event);
+ // log!(event); // TODO: Remove.
if target.class_name() == "number" && options.can_select_date {
let first_day = first_grid_day(state_clone.get_displayed_date());
}
EventListener::new(
+ // TODO: Find the right place to move the item based on:
+ // 1) recipe id, 2) name, 3) shopping entry id
+ // Se shopping_list.rs@L30
&item_element.selector(".item-is-checked"),
"change",
move |event| {
use chrono::{Datelike, Days, Months, NaiveDate};
use common::ron_api;
use gloo::storage::{LocalStorage, Storage};
-use ron::ser::{to_string_pretty, PrettyConfig};
+use ron::ser::{PrettyConfig, to_string_pretty};
use serde::{Deserialize, Serialize};
use thiserror::Error;
if self.is_local {
todo!();
} else {
- request::put(
+ request::patch(
"shopping_list/set_checked",
ron_api::Value {
id: item_id,