Recipe edit (WIP): Buttons to add steps and inrgedients
This commit is contained in:
parent
6876a254e1
commit
d4962c98ff
9 changed files with 182 additions and 15 deletions
|
|
@ -355,6 +355,32 @@ pub async fn set_group_comment(
|
|||
Ok(StatusCode::OK)
|
||||
}
|
||||
|
||||
#[debug_handler]
|
||||
pub async fn add_step(
|
||||
State(connection): State<db::Connection>,
|
||||
Extension(user): Extension<Option<model::User>>,
|
||||
ExtractRon(ron): ExtractRon<common::ron_api::AddRecipeStep>,
|
||||
) -> Result<impl IntoResponse> {
|
||||
check_user_rights_recipe_group(&connection, &user, ron.group_id).await?;
|
||||
let step_id = connection.add_recipe_step(ron.group_id).await?;
|
||||
|
||||
Ok(ron_response(
|
||||
StatusCode::OK,
|
||||
common::ron_api::AddRecipeStepResult { step_id },
|
||||
))
|
||||
}
|
||||
|
||||
#[debug_handler]
|
||||
pub async fn rm_step(
|
||||
State(connection): State<db::Connection>,
|
||||
Extension(user): Extension<Option<model::User>>,
|
||||
ExtractRon(ron): ExtractRon<common::ron_api::RemoveRecipeStep>,
|
||||
) -> Result<impl IntoResponse> {
|
||||
check_user_rights_recipe_step(&connection, &user, ron.step_id).await?;
|
||||
connection.rm_recipe_step(ron.step_id).await?;
|
||||
Ok(StatusCode::OK)
|
||||
}
|
||||
|
||||
#[debug_handler]
|
||||
pub async fn set_step_action(
|
||||
State(connection): State<db::Connection>,
|
||||
|
|
@ -366,6 +392,32 @@ pub async fn set_step_action(
|
|||
Ok(StatusCode::OK)
|
||||
}
|
||||
|
||||
#[debug_handler]
|
||||
pub async fn add_ingredient(
|
||||
State(connection): State<db::Connection>,
|
||||
Extension(user): Extension<Option<model::User>>,
|
||||
ExtractRon(ron): ExtractRon<common::ron_api::AddRecipeIngredient>,
|
||||
) -> Result<impl IntoResponse> {
|
||||
check_user_rights_recipe_step(&connection, &user, ron.step_id).await?;
|
||||
let ingredient_id = connection.add_recipe_ingredient(ron.step_id).await?;
|
||||
|
||||
Ok(ron_response(
|
||||
StatusCode::OK,
|
||||
common::ron_api::AddRecipeIngredientResult { ingredient_id },
|
||||
))
|
||||
}
|
||||
|
||||
#[debug_handler]
|
||||
pub async fn rm_ingredient(
|
||||
State(connection): State<db::Connection>,
|
||||
Extension(user): Extension<Option<model::User>>,
|
||||
ExtractRon(ron): ExtractRon<common::ron_api::RemoveRecipeIngredient>,
|
||||
) -> Result<impl IntoResponse> {
|
||||
check_user_rights_recipe_ingredient(&connection, &user, ron.ingredient_id).await?;
|
||||
connection.rm_recipe_ingredient(ron.ingredient_id).await?;
|
||||
Ok(StatusCode::OK)
|
||||
}
|
||||
|
||||
#[debug_handler]
|
||||
pub async fn set_ingredient_name(
|
||||
State(connection): State<db::Connection>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue