Tag: v7.0.2
Fix: Attendance Type and Account Type objects were borking as their convenience methods were not returning anything Fix: Employee Benefits and Incentive post voucher did not reload the page Fix: For all vouchers, to prevent double data loading on save / update either reload data or navigate, don't reload data and then navigate so that the data appears once and then disappears
This commit is contained in:
@@ -46,20 +46,24 @@ export class IncentiveComponent implements OnInit {
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { voucher: Voucher }) => {
|
||||
this.voucher = data.voucher;
|
||||
this.form.get('date').setValue(moment(this.voucher.date, 'DD-MMM-YYYY').toDate());
|
||||
this.form.setControl('incentives', this.fb.array(
|
||||
this.voucher.incentives.map(
|
||||
x => this.fb.group({
|
||||
points: x.points
|
||||
})
|
||||
)
|
||||
));
|
||||
this.dataSource = new IncentiveDataSource(this.incentiveObservable);
|
||||
this.incentiveObservable.next(this.voucher.incentives);
|
||||
this.loadVoucher(data.voucher);
|
||||
});
|
||||
}
|
||||
|
||||
loadVoucher(voucher) {
|
||||
this.voucher = voucher;
|
||||
this.form.get('date').setValue(moment(this.voucher.date, 'DD-MMM-YYYY').toDate());
|
||||
this.form.setControl('incentives', this.fb.array(
|
||||
this.voucher.incentives.map(
|
||||
x => this.fb.group({
|
||||
points: x.points
|
||||
})
|
||||
)
|
||||
));
|
||||
this.dataSource = new IncentiveDataSource(this.incentiveObservable);
|
||||
this.incentiveObservable.next(this.voucher.incentives);
|
||||
}
|
||||
|
||||
createForm() {
|
||||
this.form = this.fb.group({
|
||||
date: '',
|
||||
@@ -74,17 +78,7 @@ export class IncentiveComponent implements OnInit {
|
||||
if (x !== this.voucher.date && !this.voucher.id) {
|
||||
return this.ser.getIncentive(x)
|
||||
.subscribe((voucher: Voucher) => {
|
||||
this.voucher = voucher;
|
||||
this.form.get('date').setValue(moment(this.voucher.date, 'DD-MMM-YYYY').toDate());
|
||||
this.form.setControl('incentives', this.fb.array(
|
||||
this.voucher.incentives.map(
|
||||
i => this.fb.group({
|
||||
points: i.points
|
||||
})
|
||||
)
|
||||
));
|
||||
this.dataSource = new IncentiveDataSource(this.incentiveObservable);
|
||||
this.incentiveObservable.next(this.voucher.incentives);
|
||||
this.loadVoucher(voucher);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -137,6 +131,7 @@ export class IncentiveComponent implements OnInit {
|
||||
this.ser.post(this.voucher.id)
|
||||
.subscribe(
|
||||
(result) => {
|
||||
this.loadVoucher(result);
|
||||
this.toaster.show('Success', 'Voucher Posted');
|
||||
},
|
||||
(error) => {
|
||||
@@ -146,11 +141,15 @@ export class IncentiveComponent implements OnInit {
|
||||
}
|
||||
|
||||
save() {
|
||||
this.ser.saveOrUpdate(this.getVoucher())
|
||||
const voucher: Voucher = this.getVoucher();
|
||||
this.ser.saveOrUpdate(voucher)
|
||||
.subscribe(
|
||||
(result) => {
|
||||
this.toaster.show('Success', '');
|
||||
if (voucher.id === result.id) {
|
||||
this.loadVoucher(result);
|
||||
} else {
|
||||
this.router.navigate(['/incentive', result.id]);
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error);
|
||||
|
||||
Reference in New Issue
Block a user