diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index 087641c..467bc07 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -1,4 +1,10 @@ -import {Routes} from '@angular/router'; -import {DashboardComponent} from '@app/views/dashboard/dashboard.component'; +import { Routes } from '@angular/router'; +import { DashboardComponent } from '@app/views/dashboard/dashboard.component'; -export const routes: Routes = [{path: '', component: DashboardComponent, title: 'Home'}]; +import { EmployeeDetailComponent } from './views/employee-detail/employee-detail.component'; + +export const routes: Routes = [ + { path: '', component: DashboardComponent, title: 'Home' }, + { path: 'employee/new', component: EmployeeDetailComponent, title: 'New Employee' }, + { path: 'employee/:id', component: EmployeeDetailComponent, title: 'Edit Employee' } +]; diff --git a/src/app/views/dashboard/dashboard.component.html b/src/app/views/dashboard/dashboard.component.html index 2e49c07..04367cb 100644 --- a/src/app/views/dashboard/dashboard.component.html +++ b/src/app/views/dashboard/dashboard.component.html @@ -1,4 +1,5 @@

dashboard works!

- +New Employee +Edit Employee 3 diff --git a/src/app/views/employee-detail/employee-detail.component.html b/src/app/views/employee-detail/employee-detail.component.html new file mode 100644 index 0000000..504f613 --- /dev/null +++ b/src/app/views/employee-detail/employee-detail.component.html @@ -0,0 +1,23 @@ +
+
+ @if (isNewEmployee) { +

New Employee View Works

+ } + @else { +

Edit Employee View Works

+ @if ($employee|async;as employee) { + {{employee|json}} + } + } +
+
+ + @if (isNewEmployee) { + + } + @else { + + } +
+ +
diff --git a/src/app/views/employee-detail/employee-detail.component.scss b/src/app/views/employee-detail/employee-detail.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/views/employee-detail/employee-detail.component.ts b/src/app/views/employee-detail/employee-detail.component.ts new file mode 100644 index 0000000..9a1f8d2 --- /dev/null +++ b/src/app/views/employee-detail/employee-detail.component.ts @@ -0,0 +1,40 @@ +import { AsyncPipe, JsonPipe } from '@angular/common'; +import { Component } from '@angular/core'; +import { MatButton } from '@angular/material/button'; +import { ActivatedRoute } from '@angular/router'; +import { Employee, EmployeeService } from '@core/ems'; +import { Observable, of } from 'rxjs'; + +@Component({ + selector: 'app-employee-detail', + imports: [AsyncPipe, JsonPipe, MatButton], + templateUrl: './employee-detail.component.html', + styleUrl: './employee-detail.component.scss' +}) +export class EmployeeDetailComponent { + isNewEmployee: boolean; + $employee: Observable = of(); + constructor(private route: ActivatedRoute, private employeeService: EmployeeService) { + const idParam = this.route.snapshot.paramMap.get('id'); + this.isNewEmployee = idParam == null; + + if (this.isNewEmployee) { + return; + } + + const id = parseInt(idParam as string); + this.$employee = this.employeeService.getEmployee({ id }); + } + + onAbort() { + + } + + onCreate() { + + } + + onSave() { + + } +}