/** Angular Imports */ import { Injectable } from '@angular/core' ; import { Resolve , ActivatedRouteSnapshot } from '@angular/router' ; /** rxjs Imports */ import { Observable } from 'rxjs' ; /** Custom Services */ import { LoansService } from '../loans.service' ; /**
 * Loans notes data resolver.
 */ @ Injectable ( ) export class LoanActionButtonResolver implements Resolve < Object > { param { LoansService } LoansService constructor ( private loansService ) { } returns { Observable < any > } resolve ( route ) { const loanId = route . parent . paramMap . get ( 'loanId' ) ; const loanActionButton = route . paramMap . get ( 'action' ) ; if ( loanActionButton === 'Assign Loan Officer' || loanActionButton === 'Change Loan Officer' ) { return this . loansService . getLoanTemplate ( loanId ) ; } else if ( loanActionButton === 'Waive Interest' ) { return this . loansService . getLoanActionTemplate ( loanId , 'waiveinterest' ) ; } else if ( loanActionButton === 'Write Off' ) { return this . loansService . getLoanActionTemplate ( loanId , 'writeoff' ) ; } else if ( loanActionButton === 'Close' ) { return this . loansService . getLoanActionTemplate ( loanId , 'close' ) ; } else if ( loanActionButton === 'Close (as Rescheduled)' ) { return this . loansService . getLoanActionTemplate ( loanId , 'close-rescheduled' ) ; } else if ( loanActionButton === 'Reschedule' ) { return this . loansService . rescheduleLoanTemplate ( ) ; } else if ( loanActionButton === 'Prepay Loan' ) { return this . loansService . getLoanActionTemplate ( loanId , 'prepayLoan' ) ; } else if ( loanActionButton === 'Add Collateral' ) { return this . loansService . getLoanCollateralTemplate ( loanId ) ; } else if ( loanActionButton === 'Disburse to Savings' ) { return this . loansService . getLoanActionTemplate ( loanId , 'disburseToSavings' ) ; } else if ( loanActionButton === 'Recovery Payment' ) { return this . loansService . getLoanActionTemplate ( loanId , 'recoverypayment' ) ; } else if ( loanActionButton === 'View Guarantors' ) { return this . loansService . getLoanAccountResource ( loanId , 'guarantors' ) ; } else if ( loanActionButton === 'Create Guarantor' ) { return this . loansService . getGuarantorTemplate ( loanId ) ; } else if ( loanActionButton === 'Disburse' ) { return this . loansService . getLoanActionTemplate ( loanId , 'disburse' ) ; } else if ( loanActionButton === 'Loan Screen Reports' ) { return this . loansService . getLoanScreenReportsData ( ) ; } else if ( loanActionButton === 'Approve' ) { return this . loansService . getLoanApprovalTemplate ( loanId ) ; } else if ( loanActionButton === 'Add Loan Charge' ) { return this . loansService . getLoanChargeTemplateResource ( loanId ) ; } else { return undefined ; } } }