diff --git a/src/app/pages/recipe-upload-page/recipe-upload-page.css b/src/app/pages/recipe-upload-page/recipe-upload-page.css
index 9a0b03e..e69de29 100644
--- a/src/app/pages/recipe-upload-page/recipe-upload-page.css
+++ b/src/app/pages/recipe-upload-page/recipe-upload-page.css
@@ -1,44 +0,0 @@
-#recipe-upload-container {
- display: flex;
- flex-direction: column;
- row-gap: 5px;
-}
-
-form {
- display: flex;
- width: 100%;
- flex-direction: column;
- row-gap: 5px;
-}
-
-#recipe-upload-form {
- width: 66%;
-}
-
-.action-buttons-container {
- width: 100%;
- display: flex;
- column-gap: 5px;
-}
-
-/*button {*/
-/* width: 100%;*/
-/*}*/
-
-/*input[type="text"],*/
-/*textarea {*/
-/* padding: 10px;*/
-/* font-size: 16px;*/
-/*}*/
-
-#recipe-form-and-source {
- display: grid;
- grid-template-columns: 1fr 1fr;
- column-gap: 10px;
- justify-items: flex-start;
-}
-
-#recipe-form-and-source div,
-#recipe-form-and-source div img {
- width: 100%;
-}
diff --git a/src/app/pages/recipe-upload-page/recipe-upload-page.html b/src/app/pages/recipe-upload-page/recipe-upload-page.html
index 37ce283..01e5643 100644
--- a/src/app/pages/recipe-upload-page/recipe-upload-page.html
+++ b/src/app/pages/recipe-upload-page/recipe-upload-page.html
@@ -1,67 +1,25 @@
-
-
Upload Recipe
-
+
Upload Recipe
+
- @if (displayStep() === RecipeUploadStep.START) {
-
- } @else if (displayStep() === RecipeUploadStep.INFER) {
-
- } @else if (displayStep() === RecipeUploadStep.ENTER_DATA) {
-
- } @else if (displayStep() === RecipeUploadStep.REVIEW) {
-
- }
-
-
-
+@if (displayStep() === RecipeUploadStep.START) {
+
+} @else if (displayStep() === RecipeUploadStep.INFER) {
+
+} @else if (displayStep() === RecipeUploadStep.ENTER_DATA) {
+
+} @else if (displayStep() === RecipeUploadStep.REVIEW) {
+
+}
diff --git a/src/app/pages/recipe-upload-page/recipe-upload-page.ts b/src/app/pages/recipe-upload-page/recipe-upload-page.ts
index 87d7255..c2c688d 100644
--- a/src/app/pages/recipe-upload-page/recipe-upload-page.ts
+++ b/src/app/pages/recipe-upload-page/recipe-upload-page.ts
@@ -13,8 +13,9 @@ import { RecipeUploadStep } from '../../shared/client-models/RecipeUploadStep';
import { FileUploadEvent } from '../../shared/components/file-upload/FileUploadEvent';
import { tryMaybeInt } from '../../shared/util';
import { from, map, switchMap, tap } from 'rxjs';
-import { EnterRecipeDataEvent } from './steps/enter-recipe-data/EnterRecipeDataEvent';
import { Review } from './steps/review/review';
+import { EnterRecipeDataSubmitEvent } from './steps/enter-recipe-data/EnterRecipeDataSubmitEvent';
+import { QueryClient } from '@tanstack/angular-query-experimental';
@Component({
selector: 'app-recipe-upload-page',
@@ -35,6 +36,7 @@ export class RecipeUploadPage implements OnInit {
private readonly router = inject(Router);
private readonly activatedRoute = inject(ActivatedRoute);
private readonly recipeDraftService = inject(RecipeDraftService);
+ private readonly queryClient = inject(QueryClient);
private isValidStep(step: number): boolean {
if (this.model().draft?.lastInference || this.model().draft?.state === 'INFER') {
@@ -94,9 +96,10 @@ export class RecipeUploadPage implements OnInit {
await this.router.navigate([], {
relativeTo: this.activatedRoute,
queryParams: {
+ draftId: this.model().draft?.id,
step: targetStep,
},
- queryParamsHandling: 'merge',
+ queryParamsHandling: 'replace',
});
}
@@ -137,16 +140,22 @@ export class RecipeUploadPage implements OnInit {
}
}
- protected async onEnterRecipeDataEvent(event: EnterRecipeDataEvent): Promise {
- if (event._type === 'submit') {
- const { title, slug, rawText } = event.data;
- const model = await this.recipeDraftService.updateDraft(this.model().draft!.id, {
- title,
- slug,
- rawText,
- });
- await this.switchModel(model, RecipeUploadStep.REVIEW);
- }
+ protected async onEnterRecipeDataSubmit(event: EnterRecipeDataSubmitEvent): Promise {
+ const model = await this.recipeDraftService.updateDraft(this.model().draft!.id, event);
+ await this.switchModel(model, RecipeUploadStep.REVIEW);
+ }
+
+ protected async onDeleteDraft(): Promise {
+ await this.recipeDraftService.deleteDraft(this.model().draft!.id);
+ await this.queryClient.invalidateQueries({
+ queryKey: ['recipe-upload', 'in-progress-drafts']
+ });
+ await this.switchModel(
+ {
+ inProgressStep: RecipeUploadStep.START,
+ },
+ RecipeUploadStep.START,
+ );
}
protected async onPublish(): Promise {
diff --git a/src/app/pages/recipe-upload-page/recipe-upload-trail/recipe-upload-trail.ts b/src/app/pages/recipe-upload-page/recipe-upload-trail/recipe-upload-trail.ts
index 2b61fa7..b3ce882 100644
--- a/src/app/pages/recipe-upload-page/recipe-upload-trail/recipe-upload-trail.ts
+++ b/src/app/pages/recipe-upload-page/recipe-upload-trail/recipe-upload-trail.ts
@@ -34,6 +34,12 @@ export class RecipeUploadTrail {
completed: this.inProgressStep() > RecipeUploadStep.ENTER_DATA,
inProgress: this.inProgressStep() === RecipeUploadStep.ENTER_DATA,
},
+ {
+ index: RecipeUploadStep.REVIEW,
+ name: 'Review',
+ completed: this.inProgressStep() > RecipeUploadStep.REVIEW,
+ inProgress: this.inProgressStep() === RecipeUploadStep.REVIEW,
+ },
];
if (this.includeInfer()) {
base.push({
diff --git a/src/app/pages/recipe-upload-page/steps/ai-or-manual/ai-or-manual.html b/src/app/pages/recipe-upload-page/steps/ai-or-manual/ai-or-manual.html
index b64105d..c527e63 100644
--- a/src/app/pages/recipe-upload-page/steps/ai-or-manual/ai-or-manual.html
+++ b/src/app/pages/recipe-upload-page/steps/ai-or-manual/ai-or-manual.html
@@ -1,12 +1,12 @@
Start
- In Progress Drafts
@if (inProgressDrafts.isLoading()) {
Loading drafts...
} @else if (inProgressDrafts.isError()) {
Could not fetch drafts!
- } @else if (inProgressDrafts.isSuccess()) {
+ } @else if (inProgressDrafts.isSuccess() && inProgressDrafts.data().length) {
+ In Progress Drafts
@for (draft of inProgressDrafts.data(); track draft.id) {
-
diff --git a/src/app/pages/recipe-upload-page/steps/enter-recipe-data/EnterRecipeDataEvent.ts b/src/app/pages/recipe-upload-page/steps/enter-recipe-data/EnterRecipeDataEvent.ts
deleted file mode 100644
index baa8b75..0000000
--- a/src/app/pages/recipe-upload-page/steps/enter-recipe-data/EnterRecipeDataEvent.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-export type EnterRecipeDataEvent = EnterRecipeDataSubmitEvent;
-
-export interface EnterRecipeDataSubmitEvent {
- _type: 'submit';
- data: {
- title: string;
- slug: string;
- rawText: string;
- };
-}
diff --git a/src/app/pages/recipe-upload-page/steps/enter-recipe-data/EnterRecipeDataSubmitEvent.ts b/src/app/pages/recipe-upload-page/steps/enter-recipe-data/EnterRecipeDataSubmitEvent.ts
new file mode 100644
index 0000000..95156ea
--- /dev/null
+++ b/src/app/pages/recipe-upload-page/steps/enter-recipe-data/EnterRecipeDataSubmitEvent.ts
@@ -0,0 +1,10 @@
+export interface EnterRecipeDataSubmitEvent {
+ title: string;
+ slug: string;
+ ingredients: Array<{
+ amount: string | null,
+ name: string,
+ notes: string | null,
+ }>;
+ rawText: string;
+}
diff --git a/src/app/pages/recipe-upload-page/steps/enter-recipe-data/enter-recipe-data.css b/src/app/pages/recipe-upload-page/steps/enter-recipe-data/enter-recipe-data.css
index e0ddf0a..e84c155 100644
--- a/src/app/pages/recipe-upload-page/steps/enter-recipe-data/enter-recipe-data.css
+++ b/src/app/pages/recipe-upload-page/steps/enter-recipe-data/enter-recipe-data.css
@@ -1,3 +1,11 @@
+.ingredients-table {
+ width: 100ch;
+}
+
+.ingredient-input {
+ width: 100%;
+}
+
form {
display: flex;
flex-direction: column;
@@ -10,3 +18,8 @@ textarea {
overflow: hidden;
resize: none;
}
+
+.draft-info-container {
+ display: flex;
+ column-gap: 10px;
+}
diff --git a/src/app/pages/recipe-upload-page/steps/enter-recipe-data/enter-recipe-data.html b/src/app/pages/recipe-upload-page/steps/enter-recipe-data/enter-recipe-data.html
index 85ff05e..99f9c72 100644
--- a/src/app/pages/recipe-upload-page/steps/enter-recipe-data/enter-recipe-data.html
+++ b/src/app/pages/recipe-upload-page/steps/enter-recipe-data/enter-recipe-data.html
@@ -1,5 +1,20 @@
Enter Recipe
+
+
+
Draft started: {{ model().draft!.created }}
+
Last saved: {{ model().draft!.modified }}
+
+
+
+
+
+
+
+
}
- @for (recipeComments of commentsQuery.data()?.pages; track $index) {
+ @for (recipeComments of commentsQuery.data()!.pages; track $index) {
@for (recipeComment of recipeComments.content; track recipeComment.id) {