Fix: FormArrays were not getting cleared and were basically fucking the whole thing up.
Fix: EmployeeAttendance was borking because the inital employee was null.
This commit is contained in:
parent
c7bc379032
commit
4b97c4228a
overlord/src/app
attendance
closing-stock
employee-attendance
incentive
role/role-detail
settings
user/user-detail
@ -57,7 +57,7 @@ export class AttendanceComponent implements OnInit {
|
|||||||
this.info = data.info;
|
this.info = data.info;
|
||||||
this.attendanceTypes = data.attendanceTypes;
|
this.attendanceTypes = data.attendanceTypes;
|
||||||
this.form.controls.date.setValue(moment(this.info.date, 'DD-MMM-YYYY').toDate());
|
this.form.controls.date.setValue(moment(this.info.date, 'DD-MMM-YYYY').toDate());
|
||||||
this.form.controls.attendances.reset();
|
this.form.controls.attendances.clear();
|
||||||
this.info.body.forEach((x) =>
|
this.info.body.forEach((x) =>
|
||||||
this.form.controls.attendances.push(
|
this.form.controls.attendances.push(
|
||||||
new FormGroup({
|
new FormGroup({
|
||||||
|
@ -81,6 +81,7 @@ export class ClosingStockComponent implements OnInit {
|
|||||||
date: moment(this.info.date, 'DD-MMM-YYYY').toDate(),
|
date: moment(this.info.date, 'DD-MMM-YYYY').toDate(),
|
||||||
costCentre: this.info.costCentre.id,
|
costCentre: this.info.costCentre.id,
|
||||||
});
|
});
|
||||||
|
this.form.controls.stocks.clear();
|
||||||
this.info.items.forEach((x) =>
|
this.info.items.forEach((x) =>
|
||||||
this.form.controls.stocks.push(
|
this.form.controls.stocks.push(
|
||||||
new FormGroup({
|
new FormGroup({
|
||||||
|
@ -79,8 +79,8 @@ export class EmployeeAttendanceComponent implements OnInit, AfterViewInit {
|
|||||||
this.attendanceTypes = data.attendanceTypes;
|
this.attendanceTypes = data.attendanceTypes;
|
||||||
this.form.controls.startDate.setValue(moment(this.info.startDate, 'DD-MMM-YYYY').toDate());
|
this.form.controls.startDate.setValue(moment(this.info.startDate, 'DD-MMM-YYYY').toDate());
|
||||||
this.form.controls.finishDate.setValue(moment(this.info.finishDate, 'DD-MMM-YYYY').toDate());
|
this.form.controls.finishDate.setValue(moment(this.info.finishDate, 'DD-MMM-YYYY').toDate());
|
||||||
this.form.controls.employee.setValue(this.info.employee.name);
|
this.form.controls.employee.setValue(this.info.employee?.name ?? '');
|
||||||
this.form.controls.attendances.reset();
|
this.form.controls.attendances.clear();
|
||||||
this.info.body.forEach((x) =>
|
this.info.body.forEach((x) =>
|
||||||
this.form.controls.attendances.push(
|
this.form.controls.attendances.push(
|
||||||
new FormGroup({
|
new FormGroup({
|
||||||
@ -120,12 +120,14 @@ export class EmployeeAttendanceComponent implements OnInit, AfterViewInit {
|
|||||||
const formValue = this.form.value;
|
const formValue = this.form.value;
|
||||||
this.info.startDate = moment(formValue.startDate).format('DD-MMM-YYYY');
|
this.info.startDate = moment(formValue.startDate).format('DD-MMM-YYYY');
|
||||||
this.info.finishDate = moment(formValue.finishDate).format('DD-MMM-YYYY');
|
this.info.finishDate = moment(formValue.finishDate).format('DD-MMM-YYYY');
|
||||||
this.router.navigate(['/employee-attendance', this.info.employee.id], {
|
if (this.info.employee) {
|
||||||
queryParams: {
|
this.router.navigate(['/employee-attendance', this.info.employee.id], {
|
||||||
startDate: this.info.startDate,
|
queryParams: {
|
||||||
finishDate: this.info.finishDate,
|
startDate: this.info.startDate,
|
||||||
},
|
finishDate: this.info.finishDate,
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
save() {
|
save() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Observable } from 'rxjs/internal/Observable';
|
import { Observable, of as observableOf } from 'rxjs';
|
||||||
import { catchError } from 'rxjs/operators';
|
import { catchError } from 'rxjs/operators';
|
||||||
|
|
||||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||||
@ -35,6 +35,9 @@ export class EmployeeAttendanceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
save(employeeAttendance: EmployeeAttendance): Observable<EmployeeAttendance> {
|
save(employeeAttendance: EmployeeAttendance): Observable<EmployeeAttendance> {
|
||||||
|
if (!employeeAttendance.employee) {
|
||||||
|
return observableOf(new EmployeeAttendance());
|
||||||
|
}
|
||||||
const { id } = employeeAttendance.employee;
|
const { id } = employeeAttendance.employee;
|
||||||
return this.http
|
return this.http
|
||||||
.post<EmployeeAttendance>(`${url}/${id}`, employeeAttendance)
|
.post<EmployeeAttendance>(`${url}/${id}`, employeeAttendance)
|
||||||
|
@ -5,13 +5,12 @@ import { EmployeeAttendanceItem } from './employee-attendance-item';
|
|||||||
export class EmployeeAttendance {
|
export class EmployeeAttendance {
|
||||||
startDate: string;
|
startDate: string;
|
||||||
finishDate: string;
|
finishDate: string;
|
||||||
employee: Employee;
|
employee?: Employee;
|
||||||
body: EmployeeAttendanceItem[];
|
body: EmployeeAttendanceItem[];
|
||||||
|
|
||||||
public constructor(init?: Partial<EmployeeAttendance>) {
|
public constructor(init?: Partial<EmployeeAttendance>) {
|
||||||
this.startDate = '';
|
this.startDate = '';
|
||||||
this.finishDate = '';
|
this.finishDate = '';
|
||||||
this.employee = new Employee();
|
|
||||||
this.body = [];
|
this.body = [];
|
||||||
Object.assign(this, init);
|
Object.assign(this, init);
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,7 @@ export class IncentiveComponent implements OnInit {
|
|||||||
loadVoucher(voucher: Voucher) {
|
loadVoucher(voucher: Voucher) {
|
||||||
this.voucher = voucher;
|
this.voucher = voucher;
|
||||||
this.form.controls.date.setValue(moment(this.voucher.date, 'DD-MMM-YYYY').toDate());
|
this.form.controls.date.setValue(moment(this.voucher.date, 'DD-MMM-YYYY').toDate());
|
||||||
|
this.form.controls.incentives.clear();
|
||||||
this.voucher.incentives.forEach((x) =>
|
this.voucher.incentives.forEach((x) =>
|
||||||
this.form.controls.incentives.push(
|
this.form.controls.incentives.push(
|
||||||
new FormGroup({
|
new FormGroup({
|
||||||
|
@ -45,7 +45,7 @@ export class RoleDetailComponent implements OnInit, AfterViewInit {
|
|||||||
this.item = data.item;
|
this.item = data.item;
|
||||||
|
|
||||||
this.form.controls.name.setValue(this.item.name);
|
this.form.controls.name.setValue(this.item.name);
|
||||||
this.form.controls.permissions.reset();
|
this.form.controls.permissions.clear();
|
||||||
this.item.permissions.forEach((x) =>
|
this.item.permissions.forEach((x) =>
|
||||||
this.form.controls.permissions.push(
|
this.form.controls.permissions.push(
|
||||||
new FormGroup({
|
new FormGroup({
|
||||||
|
@ -111,7 +111,7 @@ export class SettingsComponent implements OnInit {
|
|||||||
|
|
||||||
showLockInformation(info: LockInfo[]) {
|
showLockInformation(info: LockInfo[]) {
|
||||||
this.lockInformation = info;
|
this.lockInformation = info;
|
||||||
this.lockInfoForm.controls.accountTypes.reset();
|
this.lockInfoForm.controls.accountTypes.clear();
|
||||||
this.accountTypes.forEach((x) =>
|
this.accountTypes.forEach((x) =>
|
||||||
this.lockInfoForm.controls.accountTypes.push(
|
this.lockInfoForm.controls.accountTypes.push(
|
||||||
new FormGroup({
|
new FormGroup({
|
||||||
@ -119,7 +119,7 @@ export class SettingsComponent implements OnInit {
|
|||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
this.lockInfoForm.controls.voucherTypes.reset();
|
this.lockInfoForm.controls.voucherTypes.clear();
|
||||||
this.voucherTypes.forEach((x) =>
|
this.voucherTypes.forEach((x) =>
|
||||||
this.lockInfoForm.controls.voucherTypes.push(
|
this.lockInfoForm.controls.voucherTypes.push(
|
||||||
new FormGroup({
|
new FormGroup({
|
||||||
|
@ -58,6 +58,7 @@ export class UserDetailComponent implements OnInit, AfterViewInit {
|
|||||||
this.form.controls.name.setValue(item.name);
|
this.form.controls.name.setValue(item.name);
|
||||||
this.form.controls.password.setValue(null);
|
this.form.controls.password.setValue(null);
|
||||||
this.form.controls.lockedOut.setValue(item.lockedOut);
|
this.form.controls.lockedOut.setValue(item.lockedOut);
|
||||||
|
this.form.controls.roles.clear();
|
||||||
this.item.roles.forEach((x) =>
|
this.item.roles.forEach((x) =>
|
||||||
this.form.controls.roles.push(
|
this.form.controls.roles.push(
|
||||||
new FormGroup({
|
new FormGroup({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user