Fix: Username unique index was case sensitive and this allowed duplicate names.

Feature: Moved temporal products into their own module and reverted the products module
This commit is contained in:
2021-10-27 09:27:47 +05:30
parent debe0df7b7
commit 124cf4d9ff
40 changed files with 1522 additions and 313 deletions

View File

@ -1,7 +1,6 @@
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';
@ -22,7 +21,6 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
menuCategories: MenuCategory[] = [];
saleCategories: SaleCategory[] = [];
item: Product = new Product();
list: Product[] = [];
constructor(
private route: ActivatedRoute,
@ -34,7 +32,6 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
) {
// Create form
this.form = this.fb.group({
code: { value: '', disabled: true },
name: '',
units: '',
menuCategory: '',
@ -49,21 +46,19 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
ngOnInit() {
this.route.data.subscribe((value) => {
const data = value as {
items: Product[];
item: Product;
menuCategories: MenuCategory[];
saleCategories: SaleCategory[];
};
this.menuCategories = data.menuCategories;
this.saleCategories = data.saleCategories;
this.list = data.items;
this.showItem(this.list[this.list.length - 1]);
this.showItem(data.item);
});
}
showItem(item: Product) {
this.item = item;
this.form.setValue({
code: this.item.code || '(Auto)',
name: this.item.name || '',
units: this.item.units || '',
menuCategory: this.item.menuCategory ? this.item.menuCategory.id : '',
@ -96,7 +91,7 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
}
delete() {
this.ser.delete(this.item.versionId as string).subscribe(
this.ser.delete(this.item.id as string).subscribe(
() => {
this.toaster.show('Success', '');
this.router.navigateByUrl('/products');
@ -138,9 +133,4 @@ 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);
}
}