Blacked and isorted the python files
Prettied and eslinted the typescript/html files
This commit is contained in:
@ -1,14 +1,15 @@
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { GuestBookService } from '../guest-book.service';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
import { ToasterService } from '../../core/toaster.service';
|
||||
import { GuestBook } from '../guest-book';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { GuestBookService } from '../guest-book.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-guest-book-detail',
|
||||
templateUrl: './guest-book-detail.component.html',
|
||||
styleUrls: ['./guest-book-detail.component.css']
|
||||
styleUrls: ['./guest-book-detail.component.css'],
|
||||
})
|
||||
export class GuestBookDetailComponent implements OnInit, AfterViewInit {
|
||||
@ViewChild('name', { static: true }) nameElement: ElementRef;
|
||||
@ -20,7 +21,7 @@ export class GuestBookDetailComponent implements OnInit, AfterViewInit {
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private toaster: ToasterService,
|
||||
private ser: GuestBookService
|
||||
private ser: GuestBookService,
|
||||
) {
|
||||
this.createForm();
|
||||
}
|
||||
@ -31,15 +32,14 @@ export class GuestBookDetailComponent implements OnInit, AfterViewInit {
|
||||
name: [null, Validators.required],
|
||||
phone: [null, Validators.required],
|
||||
pax: ['0', Validators.required],
|
||||
address: null
|
||||
address: null,
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { item: GuestBook }) => {
|
||||
this.showItem(data.item);
|
||||
});
|
||||
this.route.data.subscribe((data: { item: GuestBook }) => {
|
||||
this.showItem(data.item);
|
||||
});
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
@ -50,26 +50,25 @@ export class GuestBookDetailComponent implements OnInit, AfterViewInit {
|
||||
|
||||
showItem(item: GuestBook) {
|
||||
this.item = item;
|
||||
this.form.setValue({
|
||||
company: item.company,
|
||||
name: item.name,
|
||||
phone: item.phone,
|
||||
pax: '' + item.pax,
|
||||
address: item.address
|
||||
this.form.setValue({
|
||||
company: item.company,
|
||||
name: item.name,
|
||||
phone: item.phone,
|
||||
pax: `${item.pax}`,
|
||||
address: item.address,
|
||||
});
|
||||
}
|
||||
|
||||
save() {
|
||||
this.ser.saveOrUpdate(this.getItem())
|
||||
.subscribe(
|
||||
(result) => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/guest-book');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
}
|
||||
);
|
||||
this.ser.saveOrUpdate(this.getItem()).subscribe(
|
||||
() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/guest-book');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
getItem(): GuestBook {
|
||||
|
||||
Reference in New Issue
Block a user