/** Angular Imports */ import { Component , OnInit } from '@angular/core' ; import { FormGroup , FormBuilder , Validators } from '@angular/forms' ; import { DatePipe } from '@angular/common' ; import { ActivatedRoute , Router } from '@angular/router' ; /** Custom Services */ import { GroupsService } from 'app/groups/groups.service' ; import { SettingsService } from 'app/settings/settings.service' ; /**
 * Activate Group Component
 */ @ Component ( { selector : 'mifosx-activate-group' , templateUrl : './activate-group.component.html' , styleUrls : [ './activate-group.component.scss' ] } ) export class ActivateGroupComponent implements OnInit { /** Minimum date allowed. */ minDate = new Date ( 2000 , 0 , 1 ) ; /** Maximum date allowed. */ maxDate = new Date ( ) ; /** Activate group form. */ activateGroupForm : FormGroup ; /** Group Id */ groupId : any ; param { FormBuilder } formBuilder param { groupsService } groupsService param { DatePipe } datePipe param { ActivatedRoute } route param { Router } router param { SettingsService } settingsService constructor ( private formBuilder , private groupsService , private datePipe , private route , private router , private settingsService ) { this . groupId = this . route . parent . snapshot . params [ 'groupId' ] ; } ngOnInit ( ) { this . createActivateGroupForm ( ) ; } /**
     * Creates the activate group form.
     */ createActivateGroupForm ( ) { this . activateGroupForm = this . formBuilder . group ( { 'activationDate' : [ '' , Validators . required ] } ) ; } /**
     * Submits the form and activates the group,
     * if successful redirects to the group.
     */ submit ( ) { const locale = this . settingsService . language . code ; const dateFormat = this . settingsService . dateFormat ; const prevactivationDate = this . activateGroupForm . value . activationDate ; this . activateGroupForm . patchValue ( { activationDate : this . datePipe . transform ( prevactivationDate , dateFormat ) , } ) ; const data = { ... this . activateGroupForm . value , dateFormat , locale } ; this . groupsService . executeGroupCommand ( this . groupId , 'activate' , data ) . subscribe ( ( ) => { this . router . navigate ( [ '../../' ] , { relativeTo : this . route } ) ; } ) ; } }