actually make it function this time and refactor
This commit is contained in:
parent
dcc141a380
commit
c35e9d9111
@ -57,7 +57,12 @@ export class EditComponent implements OnInit {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.employeeService.create(this.employeeForm.value as Employee).subscribe();
|
if (this.employee.id === undefined) {
|
||||||
|
console.error('Employee ID is undefined');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.employeeService.update(this.employeeForm.value as Employee, this.employee.id).subscribe();
|
||||||
this.dialogRef.close();
|
this.dialogRef.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import {Component, inject, OnInit} from '@angular/core';
|
import {Component, inject, OnInit} from '@angular/core';
|
||||||
import {Observable} from "rxjs";
|
import {Observable} from "rxjs";
|
||||||
import {Qualification} from "../Qualification";
|
import {Qualification} from "../Qualification";
|
||||||
|
import {AsyncPipe} from "@angular/common";
|
||||||
import {MatDialog} from "@angular/material/dialog";
|
import {MatDialog} from "@angular/material/dialog";
|
||||||
import QualificationService from "../../services/qualification.service";
|
import QualificationService from "../../services/qualification.service";
|
||||||
import {CreateComponent} from "../create/create.component";
|
import {CreateComponent} from "../create/create.component";
|
||||||
@ -14,10 +15,18 @@ import {
|
|||||||
MatColumnDef,
|
MatColumnDef,
|
||||||
MatHeaderCell,
|
MatHeaderCell,
|
||||||
MatHeaderCellDef,
|
MatHeaderCellDef,
|
||||||
MatHeaderRow, MatHeaderRowDef, MatRow, MatRowDef,
|
MatHeaderRow,
|
||||||
|
MatHeaderRowDef,
|
||||||
|
MatRow,
|
||||||
|
MatRowDef,
|
||||||
MatTable
|
MatTable
|
||||||
} from "@angular/material/table";
|
} from "@angular/material/table";
|
||||||
|
import QualificationService from "../../services/qualification.service";
|
||||||
|
import {MatDialog} from "@angular/material/dialog";
|
||||||
|
import {CreateComponent} from "../create/create.component";
|
||||||
import {MatIcon} from "@angular/material/icon";
|
import {MatIcon} from "@angular/material/icon";
|
||||||
|
import {MatButton, MatIconButton} from "@angular/material/button";
|
||||||
|
import {EditComponent} from "../edit/edit.component";
|
||||||
import {MatCard, MatCardContent} from "@angular/material/card";
|
import {MatCard, MatCardContent} from "@angular/material/card";
|
||||||
import {MatTooltip} from "@angular/material/tooltip";
|
import {MatTooltip} from "@angular/material/tooltip";
|
||||||
import {MatProgressSpinner} from "@angular/material/progress-spinner";
|
import {MatProgressSpinner} from "@angular/material/progress-spinner";
|
||||||
@ -45,6 +54,7 @@ import {MatProgressSpinner} from "@angular/material/progress-spinner";
|
|||||||
MatProgressSpinner
|
MatProgressSpinner
|
||||||
],
|
],
|
||||||
templateUrl: './table.component.html',
|
templateUrl: './table.component.html',
|
||||||
|
standalone: true,
|
||||||
styleUrl: './table.component.css'
|
styleUrl: './table.component.css'
|
||||||
})
|
})
|
||||||
export class QualificationsComponent implements OnInit {
|
export class QualificationsComponent implements OnInit {
|
||||||
|
@ -23,4 +23,8 @@ export default class EmployeeApiService {
|
|||||||
public create(employee: Employee) {
|
public create(employee: Employee) {
|
||||||
return this.http.post<Employee>(`${EmployeeApiService.BASE_URL}/employees`, employee)
|
return this.http.post<Employee>(`${EmployeeApiService.BASE_URL}/employees`, employee)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public update(employee: Employee, id: number) {
|
||||||
|
return this.http.patch(`${EmployeeApiService.BASE_URL}/employees/${id}`, employee)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user