@@ -0,0 +1,31 @@
|
||||
/** Angular Imports */
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Resolve, ActivatedRouteSnapshot } from '@angular/router';
|
||||
|
||||
/** rxjs Imports */
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
/** Custom Services */
|
||||
import { OrganizationService } from 'app/organization/organization.service';
|
||||
|
||||
/**
|
||||
* Holiday data resolver.
|
||||
*/
|
||||
@Injectable()
|
||||
export class HolidayResolver implements Resolve<Object> {
|
||||
|
||||
/**
|
||||
* @param {OrganizationService} organizationService Organization service.
|
||||
*/
|
||||
constructor(private organizationService: OrganizationService) {}
|
||||
|
||||
/**
|
||||
* Returns the holiday data.
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<any> {
|
||||
const holidayId = route.paramMap.get('id');
|
||||
return this.organizationService.getHoliday(holidayId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -56,7 +56,7 @@
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;" class="select-row"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;" class="select-row" [routerLink]="[row.id]"></tr>
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" fxLayout.lt-md="column" class="container m-b-20">
|
||||
<button mat-raised-button color="accent" *ngIf="holidayData.status.value !== 'Active'">
|
||||
<fa-icon icon="lock-open"></fa-icon>
|
||||
Activate
|
||||
</button>
|
||||
<button mat-raised-button color="primary" [routerLink]="['edit']">
|
||||
<fa-icon icon="edit"></fa-icon>
|
||||
Edit
|
||||
</button>
|
||||
<button mat-raised-button color="warn" (click)="deleteHoliday()">
|
||||
<fa-icon icon="trash"></fa-icon>
|
||||
Delete
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<mat-card>
|
||||
|
||||
<mat-card-content>
|
||||
|
||||
<div fxLayout="row wrap" class="content">
|
||||
|
||||
<div fxFlex="50%" class="header">
|
||||
Name
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%">
|
||||
{{ holidayData.name }}
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" class="header">
|
||||
From Date
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%">
|
||||
{{ holidayData.fromDate | date }}
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" class="header">
|
||||
To Date
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%">
|
||||
{{ holidayData.toDate | date }}
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" class="header">
|
||||
Repayments Scheduled To
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" *ngIf="holidayData.repaymentsRescheduledTo !== undefined && holidayData.repaymentsRescheduledTo !== null">
|
||||
{{ holidayData.repaymentsRescheduledTo | date }}
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" *ngIf="holidayData.repaymentsRescheduledTo === undefined || holidayData.repaymentsRescheduledTo === null">
|
||||
Next Repayment Date
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</mat-card-content>
|
||||
|
||||
</mat-card>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,14 @@
|
||||
.container {
|
||||
max-width: 37rem;
|
||||
|
||||
.content {
|
||||
div {
|
||||
margin: 1rem 0;
|
||||
word-wrap: break-word;
|
||||
|
||||
&.header {
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ViewHolidaysComponent } from './view-holidays.component';
|
||||
|
||||
describe('ViewHolidaysComponent', () => {
|
||||
let component: ViewHolidaysComponent;
|
||||
let fixture: ComponentFixture<ViewHolidaysComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ViewHolidaysComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ViewHolidaysComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -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 });
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user