WIP
Some checks failed
Quality Check / Linting (push) Failing after 20s

This commit is contained in:
Dominik Säume 2025-01-09 10:44:02 +01:00
parent 34d635a6fd
commit cc08a512cf
5 changed files with 150 additions and 4 deletions

View file

@ -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' }
];

View file

@ -1,4 +1,5 @@
<p>dashboard works!</p>
<a href="/employee/new">New Employee</a>
<a href="/employee/1">Edit Employee 3</a>
<button mat-button (click)="testInfo()">Test Info</button>
<button mat-button (click)="testError()">Test Error</button>

View file

@ -0,0 +1,45 @@
<form class="employee-detail" [formGroup]="employeeForm" appearance="outline">
<div class="employee-detail__info-view">
<div class="employee-detail__info-view__base">
<mat-form-field>
<mat-label>First Name</mat-label>
<input matInput formControlName="firstName">
</mat-form-field>
<mat-form-field>
<mat-label>Last Name</mat-label>
<input matInput formControlName="lastName">
</mat-form-field>
<mat-form-field>
<mat-label>Postcode</mat-label>
<mat-icon matSuffix>money</mat-icon>
<input matInput formControlName="postcode">
</mat-form-field>
<mat-form-field>
<mat-label>City</mat-label>
<mat-icon matSuffix>location_city</mat-icon>
<input matInput formControlName="city">
</mat-form-field>
<mat-form-field>
<mat-label>Street</mat-label>
<mat-icon matSuffix>house</mat-icon>
<input matInput formControlName="street">
</mat-form-field>
<mat-form-field>
<mat-label>Phone</mat-label>
<mat-icon matSuffix>phone</mat-icon>
<input matInput formControlName="phone">
</mat-form-field>
</div>
<div class="employee-detail__info-view__qualifications"></div>
</div>
<div class="employee-detail__action-row">
<button mat-flat-button (click)="onAbort()" class="abort">Abort</button>
@if (isNewEmployee) {
<button mat-flat-button (click)="onCreate()">Create</button>
}
@else {
<button mat-flat-button (click)="onSave()">Save</button>
}
</div>
</form>

View file

@ -0,0 +1,27 @@
@use '@angular/material' as mat;
.employee-detail {
display: flex;
flex-direction: column;
gap: 1rem;
&__info-view {
display: flex;
gap: 1rem;
>* {
flex-basis: 0;
flex-grow: 1;
}
&__base {
display: flex;
flex-direction: column;
}
}
&__action-row {
display: flex;
justify-content: space-between;
}
}

View file

@ -0,0 +1,67 @@
import { Component } from '@angular/core';
import { FormBuilder, FormGroup, ReactiveFormsModule } from '@angular/forms';
import { MatButton } from '@angular/material/button';
import { MatFormField, MatLabel, MatSuffix } from '@angular/material/form-field';
import { MatIcon } from '@angular/material/icon';
import { MatInput } from '@angular/material/input';
import { ActivatedRoute } from '@angular/router';
import { Employee, EmployeeService } from '@core/ems';
import { Observable, of } from 'rxjs';
@Component({
selector: 'app-employee-detail',
imports: [
MatButton,
ReactiveFormsModule,
MatFormField,
MatLabel,
MatInput,
MatIcon,
MatSuffix
],
templateUrl: './employee-detail.component.html',
styleUrl: './employee-detail.component.scss'
})
export class EmployeeDetailComponent {
isNewEmployee: boolean;
employeeForm: FormGroup;
constructor(private route: ActivatedRoute, private employeeService: EmployeeService, private formBuilder: FormBuilder) {
const idParam = this.route.snapshot.paramMap.get('id');
this.isNewEmployee = idParam == null;
this.employeeForm = this.formBuilder.group<Employee>({
id: 0,
firstName: '',
lastName: '',
postcode: '',
city: '',
street: '',
phone: '',
skillSet: []
});
if (this.isNewEmployee) {
return;
}
const id = parseInt(idParam as string);
this.employeeService.getEmployee({ id }).subscribe((employee) => {
this.employeeForm = this.formBuilder.group<Employee>(employee);
});
}
onAbort() {
}
onCreate() {
}
onSave() {
}
}