Blacked and isorted the python files
Prettied and eslinted the typescript/html files
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { ToasterService } from '../../core/toaster.service';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { ModifierService } from '../modifier.service';
|
||||
import { Modifier } from '../../core/modifier';
|
||||
import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog.component';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
import { Modifier } from '../../core/modifier';
|
||||
import { ModifierCategory } from '../../core/modifier-category';
|
||||
import { ToasterService } from '../../core/toaster.service';
|
||||
import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog.component';
|
||||
import { ModifierService } from '../modifier.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-modifier-detail',
|
||||
templateUrl: './modifier-detail.component.html',
|
||||
styleUrls: ['./modifier-detail.component.css']
|
||||
styleUrls: ['./modifier-detail.component.css'],
|
||||
})
|
||||
export class ModifierDetailComponent implements OnInit, AfterViewInit {
|
||||
@ViewChild('name', { static: true }) nameElement: ElementRef;
|
||||
@@ -25,7 +26,7 @@ export class ModifierDetailComponent implements OnInit, AfterViewInit {
|
||||
private dialog: MatDialog,
|
||||
private fb: FormBuilder,
|
||||
private toaster: ToasterService,
|
||||
private ser: ModifierService
|
||||
private ser: ModifierService,
|
||||
) {
|
||||
this.createForm();
|
||||
}
|
||||
@@ -36,16 +37,17 @@ export class ModifierDetailComponent implements OnInit, AfterViewInit {
|
||||
showInBill: '',
|
||||
price: '',
|
||||
modifierCategory: '',
|
||||
isActive: ''
|
||||
isActive: '',
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { item: Modifier, modifierCategories: ModifierCategory[] }) => {
|
||||
this.route.data.subscribe(
|
||||
(data: { item: Modifier; modifierCategories: ModifierCategory[] }) => {
|
||||
this.modifierCategories = data.modifierCategories;
|
||||
this.showItem(data.item);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
showItem(item: Modifier) {
|
||||
@@ -55,7 +57,7 @@ export class ModifierDetailComponent implements OnInit, AfterViewInit {
|
||||
showInBill: this.item.showInBill,
|
||||
price: this.item.price || '',
|
||||
isActive: this.item.isActive,
|
||||
modifierCategory: this.item.modifierCategory.id ? this.item.modifierCategory.id : ''
|
||||
modifierCategory: this.item.modifierCategory.id ? this.item.modifierCategory.id : '',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -66,35 +68,33 @@ export class ModifierDetailComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
|
||||
save() {
|
||||
this.ser.saveOrUpdate(this.getItem())
|
||||
.subscribe(
|
||||
(result) => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/modifiers');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
}
|
||||
);
|
||||
this.ser.saveOrUpdate(this.getItem()).subscribe(
|
||||
() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/modifiers');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
delete() {
|
||||
this.ser.delete(this.item.id)
|
||||
.subscribe(
|
||||
(result) => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/modifiers');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
}
|
||||
);
|
||||
this.ser.delete(this.item.id).subscribe(
|
||||
() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/modifiers');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
confirmDelete(): void {
|
||||
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
|
||||
width: '250px',
|
||||
data: {title: 'Delete Modifier?', content: 'Are you sure? This cannot be undone.'}
|
||||
data: { title: 'Delete Modifier?', content: 'Are you sure? This cannot be undone.' },
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((result: boolean) => {
|
||||
|
||||
Reference in New Issue
Block a user