12-user-info-jwt #6

Merged
william merged 3 commits from 12-user-info-jwt into develop 2021-12-22 16:27:47 -05:00
1 changed files with 17 additions and 5 deletions
Showing only changes of commit f04a3c7ba3 - Show all commits

View File

@ -27,7 +27,7 @@ abstract class _BaseMixPage extends SubscribingComponent {
protected mixService: MixService,
private recipeService: RecipeService,
private materialTypeService: MaterialTypeService,
private materialService: MaterialService,
protected materialService: MaterialService,
errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
@ -50,13 +50,15 @@ abstract class _BaseMixPage extends SubscribingComponent {
set recipe(recipe: Recipe) {
this._recipe = recipe
this.materials$ = this.materialService.getAllForMixCreation(recipe.id)
this.materials$ = this.fetchMaterials(recipe.id)
}
get recipe(): Recipe {
return this._recipe
}
protected abstract fetchMaterials(recipeId: number): Observable<Material[]>
abstract submit(dto: MixSaveDto)
}
@ -65,6 +67,10 @@ abstract class _BaseMixPage extends SubscribingComponent {
templateUrl: 'add.html'
})
export class MixAdd extends _BaseMixPage {
protected fetchMaterials(recipeId: number): Observable<Material[]> {
return this.materialService.getAllForMixCreation(recipeId)
}
submit(dto: MixSaveDto) {
this.subscribeAndNavigate(
this.mixService.saveDto(dto),
@ -80,21 +86,27 @@ export class MixAdd extends _BaseMixPage {
export class MixEdit extends _BaseMixPage {
mix: Mix
private mixId: number
ngOnInit() {
super.ngOnInit()
this.mixId = this.urlUtils.parseIntUrlParam('id')
this.fetchMix()
}
private fetchMix() {
const mixId = this.urlUtils.parseIntUrlParam('id')
this.subscribe(
this.mixService.getById(mixId),
this.mixService.getById(this.mixId),
mix => this.mix = mix
)
}
protected fetchMaterials(recipeId: number): Observable<Material[]> {
return this.materialService.getAllForMixUpdate(this.mixId)
}
submit(dto: MixSaveDto) {
this.subscribeAndNavigate(
this.mixService.updateDto({...dto, id: this.mix.id}),