import { Component , OnInit , Input } from '@angular/core' ; import { ActivatedRoute , Router } from '@angular/router' ; import { DatePipe } from '@angular/common' ; import { MatDialog } from '@angular/material/dialog' ; import { LoansService } from 'app/loans/loans.service' ; import { FormGroup , FormBuilder , Validators } from '@angular/forms' ; /** Custom Services */ import { SettingsService } from 'app/settings/settings.service' ; @ Component ( { selector : 'mifosx-assign-loan-officer' , templateUrl : './assign-loan-officer.component.html' , styleUrls : [ './assign-loan-officer.component.scss' ] } ) export class AssignLoanOfficerComponent implements OnInit { @ Input ( ) dataObject : any ; /** Loan Id */ loanId : string ; loanOfficers : any [ ] ; /** Minimum Date allowed. */ minDate = new Date ( 2000 , 0 , 1 ) ; /** Maximum Date allowed. */ maxDate = new Date ( ) ; /** Assign loan Officer form. */ assignOfficerForm : FormGroup ; param { FormBuilder } formBuilder param { LoansService } systemService param { ActivatedRoute } route param { Router } router param { SettingsService } settingsService constructor ( private formBuilder , private loanService , private route , private router , private datePipe , private settingsService ) { this . loanId = this . route . parent . snapshot . params [ 'loanId' ] ; } /**
     * Creates the assign officer form.
     */ ngOnInit ( ) { this . createassignOfficerForm ( ) ; this . loanOfficers = this . dataObject . loanOfficerOptions ; } /**
     * Creates the create close form.
     */ createassignOfficerForm ( ) { this . assignOfficerForm = this . formBuilder . group ( { 'toLoanOfficerId' : [ '' , Validators . required ] , 'assignmentDate' : [ new Date ( ) , Validators . required ] } ) ; } submit ( ) { const assignmentDate = this . assignOfficerForm . value . assignmentDate ; const dateFormat = this . settingsService . dateFormat ; this . assignOfficerForm . patchValue ( { assignmentDate : this . datePipe . transform ( assignmentDate , dateFormat ) } ) ; const assignForm = this . assignOfficerForm . value ; assignForm . locale = this . settingsService . language . code ; assignForm . dateFormat = dateFormat ; assignForm . fromLoanOfficerId = this . dataObject . loanOfficerId || '' ; this . loanService . loanActionButtons ( this . loanId , 'assignLoanOfficer' , assignForm ) . subscribe ( ( response ) => { this . router . navigate ( [ `../../general` ] , { relativeTo : this . route } ) ; } ) ; } }