Still in progress
This commit is contained in:
@ -1,19 +1,17 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {FormArray, FormBuilder, FormGroup, Validators} from '@angular/forms';
|
||||
import {RoleService} from "../../role/role.service";
|
||||
import {GuestBookService} from "../guest-book.service";
|
||||
import {ToasterService} from "../../core/toaster.service";
|
||||
import {Role} from "../../role/role";
|
||||
import {GuestBook} from "../guest-book";
|
||||
import {ActivatedRoute, Router} from "@angular/router";
|
||||
import {User} from "../../user/user";
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { GuestBookService } from "../guest-book.service";
|
||||
import { ToasterService } from "../../core/toaster.service";
|
||||
import { GuestBook } from "../guest-book";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
|
||||
@Component({
|
||||
selector: 'app-guest-book-detail',
|
||||
templateUrl: './guest-book-detail.component.html',
|
||||
styleUrls: ['./guest-book-detail.component.css']
|
||||
})
|
||||
export class GuestBookDetailComponent implements OnInit {
|
||||
export class GuestBookDetailComponent implements OnInit, AfterViewInit {
|
||||
@ViewChild('name', { static: true }) nameElement: ElementRef;
|
||||
form: FormGroup;
|
||||
item: GuestBook;
|
||||
|
||||
@ -44,6 +42,12 @@ export class GuestBookDetailComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
setTimeout(() => {
|
||||
this.nameElement.nativeElement.focus();
|
||||
}, 0);
|
||||
}
|
||||
|
||||
showItem(item: GuestBook) {
|
||||
this.item = item;
|
||||
this.form.get('company').setValue(item.company);
|
||||
@ -53,12 +57,12 @@ export class GuestBookDetailComponent implements OnInit {
|
||||
this.form.get('address').setValue(item.address);
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
save() {
|
||||
this.ser.saveOrUpdate(this.getItem())
|
||||
.subscribe(
|
||||
(result) => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/guest-book/list');
|
||||
this.router.navigateByUrl('/guest-book');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
|
||||
Reference in New Issue
Block a user