activate holidays

This commit is contained in:
gustavao
2021-08-11 11:30:46 -05:00
parent 7b084caa61
commit 84b2d8c5df
3 changed files with 67 additions and 38 deletions
@@ -1,6 +1,6 @@
<div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" fxLayout.lt-md="column" class="container m-b-20"> <div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" fxLayout.lt-md="column" class="container m-b-20">
<span *mifosxHasPermission="'ACTIVATE_HOLIDAY'"> <span *mifosxHasPermission="'ACTIVATE_HOLIDAY'">
<button mat-raised-button color="accent" *ngIf="holidayData.status.value !== 'Active'"> <button mat-raised-button color="accent" (click)="activateHoliday()" *ngIf="holidayData.status.value !== 'Active'">
<fa-icon icon="lock-open"></fa-icon>&nbsp;&nbsp; <fa-icon icon="lock-open"></fa-icon>&nbsp;&nbsp;
Activate Activate
</button> </button>
@@ -7,6 +7,7 @@ import { MatDialog } from '@angular/material/dialog';
import { OrganizationService } from 'app/organization/organization.service'; import { OrganizationService } from 'app/organization/organization.service';
/** Custom Components. */ /** Custom Components. */
import { ConfirmationDialogComponent } from '../../../shared/confirmation-dialog/confirmation-dialog.component';
import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dialog.component'; import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dialog.component';
/** /**
@@ -52,4 +53,21 @@ export class ViewHolidaysComponent {
}); });
} }
/**
* Activate holiday.
*/
activateHoliday() {
const unAssignStaffDialogRef = this.dialog.open(ConfirmationDialogComponent, {
data: { heading: 'Holiday', dialogContext: `Are you sure you want to activate ${this.holidayData.name} holiday` }
});
unAssignStaffDialogRef.afterClosed().subscribe((response: { confirm: any }) => {
if (response.confirm) {
this.organizationService.activateHoliday(this.holidayData.id)
.subscribe((response: any) => {
this.router.navigate(['/organization/holidays']);
});
}
});
}
} }
@@ -639,6 +639,17 @@ export class OrganizationService {
return this.http.delete(`/holidays/${holidayId}`); return this.http.delete(`/holidays/${holidayId}`);
} }
/**
* Activate Holiday.
* @param holidayId Holiday Id to be deleted.
* @returns {Observable<any>} Resource Id.
*/
activateHoliday(holidayId: string): Observable<any> {
const httpParams = new HttpParams()
.set('command','activate');
return this.http.post(`/holidays/${holidayId}`, null, { params: httpParams });
}
/** /**
* @param {any} employeeId Employee ID of Employee to be edited. * @param {any} employeeId Employee ID of Employee to be edited.
* @returns {Observable<any>} * @returns {Observable<any>}