Allow editing of product version with the right permission.
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { MatRadioChange } from '@angular/material/radio';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
import { MenuCategory } from '../../core/menu-category';
|
||||
@ -21,6 +22,7 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
menuCategories: MenuCategory[] = [];
|
||||
saleCategories: SaleCategory[] = [];
|
||||
item: Product = new Product();
|
||||
list: Product[] = [];
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
@ -47,13 +49,14 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
ngOnInit() {
|
||||
this.route.data.subscribe((value) => {
|
||||
const data = value as {
|
||||
item: Product;
|
||||
items: Product[];
|
||||
menuCategories: MenuCategory[];
|
||||
saleCategories: SaleCategory[];
|
||||
};
|
||||
this.menuCategories = data.menuCategories;
|
||||
this.saleCategories = data.saleCategories;
|
||||
this.showItem(data.item);
|
||||
this.list = data.items;
|
||||
this.showItem(this.list[this.list.length - 1]);
|
||||
});
|
||||
}
|
||||
|
||||
@ -93,7 +96,7 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
|
||||
delete() {
|
||||
this.ser.delete(this.item.id as string).subscribe(
|
||||
this.ser.delete(this.item.versionId as string).subscribe(
|
||||
() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/products');
|
||||
@ -135,4 +138,9 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
this.item.quantity = +formModel.quantity;
|
||||
return this.item;
|
||||
}
|
||||
|
||||
loadProduct($event: MatRadioChange) {
|
||||
const product = this.list.find((x) => x.versionId === $event.value);
|
||||
this.showItem(product as Product);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user