/** Angular Imports */ import { Component , OnInit } from '@angular/core' ; import { FormGroup , FormBuilder , Validators } from '@angular/forms' ; import { ActivatedRoute , Router } from '@angular/router' ; /** Custom Services */ import { SystemService } from '../../system.service' ; /**
 * Edit Code Component.
 */ @ Component ( { selector : 'mifosx-edit-code' , templateUrl : './edit-code.component.html' , styleUrls : [ './edit-code.component.scss' ] } ) export class EditCodeComponent implements OnInit { /** Code Form */ codeForm : FormGroup ; /** Code Data */ codeData : any ; param { FormBuilder } formBuilder param { SystemService } systemService param { ActivatedRoute } route param { Router } router constructor ( private formBuilder , private systemService , private route , private router ) { this . route . data . subscribe ( ( data ) => { this . codeData = data . code ; } ) ; } /**
     * Creates and sets the code form.
     */ ngOnInit ( ) { this . createCodeForm ( ) ; } /**
     * Creates and sets code form.
     */ createCodeForm ( ) { this . codeForm = this . formBuilder . group ( { 'name' : [ this . codeData . name , Validators . required ] } ) ; } /**
     * Submits the code form and updates code,
     * if successful redirects to view updated code.
     */ submit ( ) { this . systemService . updateCode ( this . codeForm . value , this . codeData . id ) . subscribe ( ( response ) => { this . router . navigate ( [ '../../' , response . resourceId ] , { relativeTo : this . route } ) ; } ) ; } }