mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-05 05:25:26 +02:00
Fix: Allow Last Made to be Updated on Locked Recipes (#2140)
* allow certain props to be updated on locked recipe * pytest * added "last_made" to hardcoded datetime fields * refactored last made to its own route * codegen/types * updated pytest
This commit is contained in:
parent
a6c46a7420
commit
fd03d468d4
9 changed files with 88 additions and 5 deletions
|
@ -126,8 +126,7 @@ export default defineComponent({
|
|||
|
||||
// we also update the recipe's last made value
|
||||
if (!props.value || newTimelineEvent.value.timestamp > props.value) {
|
||||
const payload = {lastMade: newTimelineEvent.value.timestamp};
|
||||
actions.push(userApi.recipes.patchOne(props.recipeSlug, payload));
|
||||
actions.push(userApi.recipes.updateLastMade(props.recipeSlug, newTimelineEvent.value.timestamp));
|
||||
|
||||
// update recipe in parent so the user can see it
|
||||
// we remove the trailing "Z" since this is how the API returns it
|
||||
|
|
|
@ -303,6 +303,9 @@ export interface RecipeCommentUpdate {
|
|||
export interface RecipeDuplicate {
|
||||
name?: string;
|
||||
}
|
||||
export interface RecipeLastMade {
|
||||
timestamp: string;
|
||||
}
|
||||
export interface RecipeShareToken {
|
||||
recipeId: string;
|
||||
expiresAt?: string;
|
||||
|
|
|
@ -10,6 +10,7 @@ import {
|
|||
ParsedIngredient,
|
||||
UpdateImageResponse,
|
||||
RecipeZipTokenResponse,
|
||||
RecipeLastMade,
|
||||
RecipeTimelineEventIn,
|
||||
RecipeTimelineEventOut,
|
||||
RecipeTimelineEventUpdate,
|
||||
|
@ -48,6 +49,8 @@ const routes = {
|
|||
recipesSlugComments: (slug: string) => `${prefix}/recipes/${slug}/comments`,
|
||||
recipesSlugCommentsId: (slug: string, id: number) => `${prefix}/recipes/${slug}/comments/${id}`,
|
||||
|
||||
recipesSlugLastMade: (slug: string) => `${prefix}/recipes/${slug}/last-made`,
|
||||
|
||||
recipesSlugTimelineEvent: (slug: string) => `${prefix}/recipes/${slug}/timeline/events`,
|
||||
recipesSlugTimelineEventId: (slug: string, id: string) => `${prefix}/recipes/${slug}/timeline/events/${id}`,
|
||||
};
|
||||
|
@ -164,6 +167,10 @@ export class RecipeAPI extends BaseCRUDAPI<CreateRecipe, Recipe, Recipe> {
|
|||
return await this.requests.post(routes.recipesCreateFromOcr, formData);
|
||||
}
|
||||
|
||||
async updateLastMade(recipeSlug: string, timestamp: string) {
|
||||
return await this.requests.patch<Recipe, RecipeLastMade>(routes.recipesSlugLastMade(recipeSlug), { timestamp })
|
||||
}
|
||||
|
||||
async createTimelineEvent(recipeSlug: string, payload: RecipeTimelineEventIn) {
|
||||
return await this.requests.post<RecipeTimelineEventOut>(routes.recipesSlugTimelineEvent(recipeSlug), payload);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue