Prettier.
This commit is contained in:
parent
b42971703f
commit
14acdc3e83
@ -28,7 +28,7 @@ export class RecipePageContent {
|
|||||||
const recipe = this.recipeView().recipe;
|
const recipe = this.recipeView().recipe;
|
||||||
return {
|
return {
|
||||||
queryKey: ['recipe-main-images', recipe.owner.username, recipe.slug],
|
queryKey: ['recipe-main-images', recipe.owner.username, recipe.slug],
|
||||||
queryFn: () => this.imageService.getImage(recipe.mainImage?.url)
|
queryFn: () => this.imageService.getImage(recipe.mainImage?.url),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -76,7 +76,10 @@ export class RecipeUploadPage implements OnInit {
|
|||||||
.subscribe();
|
.subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async switchModel(model: RecipeUploadClientModel, switchStep: boolean | RecipeUploadStep = false): Promise<void> {
|
private async switchModel(
|
||||||
|
model: RecipeUploadClientModel,
|
||||||
|
switchStep: boolean | RecipeUploadStep = false,
|
||||||
|
): Promise<void> {
|
||||||
this.model.set(model);
|
this.model.set(model);
|
||||||
this.includeInfer.set(!!model.draft?.lastInference);
|
this.includeInfer.set(!!model.draft?.lastInference);
|
||||||
if (switchStep === true) {
|
if (switchStep === true) {
|
||||||
@ -140,7 +143,7 @@ export class RecipeUploadPage implements OnInit {
|
|||||||
const model = await this.recipeDraftService.updateDraft(this.model().draft!.id, {
|
const model = await this.recipeDraftService.updateDraft(this.model().draft!.id, {
|
||||||
title,
|
title,
|
||||||
slug,
|
slug,
|
||||||
rawText
|
rawText,
|
||||||
});
|
});
|
||||||
await this.switchModel(model, RecipeUploadStep.REVIEW);
|
await this.switchModel(model, RecipeUploadStep.REVIEW);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
export type EnterRecipeDataEvent = EnterRecipeDataSubmitEvent
|
export type EnterRecipeDataEvent = EnterRecipeDataSubmitEvent;
|
||||||
|
|
||||||
export interface EnterRecipeDataSubmitEvent {
|
export interface EnterRecipeDataSubmitEvent {
|
||||||
_type: 'submit';
|
_type: 'submit';
|
||||||
@ -6,5 +6,5 @@ export interface EnterRecipeDataSubmitEvent {
|
|||||||
title: string;
|
title: string;
|
||||||
slug: string;
|
slug: string;
|
||||||
rawText: string;
|
rawText: string;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,8 @@ import {
|
|||||||
inject,
|
inject,
|
||||||
Injector,
|
Injector,
|
||||||
input,
|
input,
|
||||||
OnInit, output,
|
OnInit,
|
||||||
|
output,
|
||||||
runInInjectionContext,
|
runInInjectionContext,
|
||||||
viewChild,
|
viewChild,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
@ -73,8 +74,8 @@ export class EnterRecipeData implements OnInit {
|
|||||||
data: {
|
data: {
|
||||||
title: title!,
|
title: title!,
|
||||||
slug: slug!,
|
slug: slug!,
|
||||||
rawText: text!
|
rawText: text!,
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,21 +3,20 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|||||||
import { Review } from './review';
|
import { Review } from './review';
|
||||||
|
|
||||||
describe('Review', () => {
|
describe('Review', () => {
|
||||||
let component: Review;
|
let component: Review;
|
||||||
let fixture: ComponentFixture<Review>;
|
let fixture: ComponentFixture<Review>;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
imports: [Review]
|
imports: [Review],
|
||||||
})
|
}).compileComponents();
|
||||||
.compileComponents();
|
|
||||||
|
|
||||||
fixture = TestBed.createComponent(Review);
|
fixture = TestBed.createComponent(Review);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create', () => {
|
it('should create', () => {
|
||||||
expect(component).toBeTruthy();
|
expect(component).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,20 +3,16 @@ import { RecipeDraftViewModel } from '../../../../shared/models/RecipeDraftView.
|
|||||||
import { MatButton } from '@angular/material/button';
|
import { MatButton } from '@angular/material/button';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-review',
|
selector: 'app-review',
|
||||||
imports: [
|
imports: [MatButton],
|
||||||
MatButton
|
templateUrl: './review.html',
|
||||||
],
|
styleUrl: './review.css',
|
||||||
templateUrl: './review.html',
|
|
||||||
styleUrl: './review.css',
|
|
||||||
})
|
})
|
||||||
export class Review {
|
export class Review {
|
||||||
|
|
||||||
public readonly draft = input.required<RecipeDraftViewModel>();
|
public readonly draft = input.required<RecipeDraftViewModel>();
|
||||||
public readonly publish = output<void>();
|
public readonly publish = output<void>();
|
||||||
|
|
||||||
protected onPublish(): void {
|
protected onPublish(): void {
|
||||||
this.publish.emit();
|
this.publish.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,5 +2,5 @@ export enum RecipeUploadStep {
|
|||||||
START,
|
START,
|
||||||
INFER,
|
INFER,
|
||||||
ENTER_DATA,
|
ENTER_DATA,
|
||||||
REVIEW
|
REVIEW,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,7 +31,7 @@ export class RecipeCard {
|
|||||||
const recipe = this.recipe();
|
const recipe = this.recipe();
|
||||||
return {
|
return {
|
||||||
queryKey: ['recipe-main-images', recipe.owner.username, recipe.slug],
|
queryKey: ['recipe-main-images', recipe.owner.username, recipe.slug],
|
||||||
queryFn: () => this.imageService.getImage(recipe.mainImage?.url)
|
queryFn: () => this.imageService.getImage(recipe.mainImage?.url),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,32 +72,30 @@ export class RecipeDraftService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateDraft(id: string, data: {
|
public updateDraft(
|
||||||
title?: string | null;
|
id: string,
|
||||||
slug?: string | null;
|
data: {
|
||||||
rawText?: string | null;
|
title?: string | null;
|
||||||
}): Promise<RecipeUploadClientModel> {
|
slug?: string | null;
|
||||||
|
rawText?: string | null;
|
||||||
|
},
|
||||||
|
): Promise<RecipeUploadClientModel> {
|
||||||
return firstValueFrom(
|
return firstValueFrom(
|
||||||
this.http.put<WithStringDates<RecipeDraftViewModel>>(
|
this.http
|
||||||
this.endpointService.getUrl('recipeDrafts', [id]),
|
.put<WithStringDates<RecipeDraftViewModel>>(this.endpointService.getUrl('recipeDrafts', [id]), data)
|
||||||
data
|
|
||||||
)
|
|
||||||
.pipe(
|
.pipe(
|
||||||
map(rawView => this.hydrateView(rawView)),
|
map((rawView) => this.hydrateView(rawView)),
|
||||||
map(draft => ({
|
map((draft) => ({
|
||||||
draft,
|
draft,
|
||||||
inProgressStep: RecipeUploadStep.ENTER_DATA,
|
inProgressStep: RecipeUploadStep.ENTER_DATA,
|
||||||
}))
|
})),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public publish(id: string): Promise<Recipe> {
|
public publish(id: string): Promise<Recipe> {
|
||||||
return firstValueFrom(
|
return firstValueFrom(
|
||||||
this.http.post<Recipe>(
|
this.http.post<Recipe>(this.endpointService.getUrl('recipeDrafts', [id, 'publish']), null),
|
||||||
this.endpointService.getUrl('recipeDrafts', [id, 'publish']),
|
|
||||||
null
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user