feat: add view holiday component (#780)

Fixes: #749
This commit is contained in:
Benura Abeywardena
2020-05-22 19:35:22 +05:30
committed by GitHub
parent 5e1b1aeae5
commit 0bd07753a9
9 changed files with 238 additions and 6 deletions
@@ -0,0 +1,55 @@
/** Angular Imports. */
import { Component } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { MatDialog } from '@angular/material';
/** Custom Services. */
import { OrganizationService } from 'app/organization/organization.service';
/** Custom Components. */
import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dialog.component';
/**
* View Holidays component.
*/
@Component({
selector: 'mifosx-view-holidays',
templateUrl: './view-holidays.component.html',
styleUrls: ['./view-holidays.component.scss']
})
export class ViewHolidaysComponent {
/** Holiday data. */
holidayData: any;
/**
* Retrieves hioliday data from `resolve`.
* @param {ActivatedRoute} route Activated Route.
*/
constructor(private route: ActivatedRoute,
private router: Router,
private dialog: MatDialog,
private organizationService: OrganizationService ) {
this.route.data.subscribe((data: { holidays: any}) => {
this.holidayData = data.holidays;
});
}
/**
* Deletes the holiday.
*/
deleteHoliday() {
const deleteHolidayDialogRef = this.dialog.open(DeleteDialogComponent, {
data: { deleteContext: `holiday ${this.holidayData.id}` }
});
deleteHolidayDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) {
this.organizationService.deleteHoliday(this.holidayData.id)
.subscribe(() => {
this.router.navigate(['../'], { relativeTo: this.route });
});
}
});
}
}