/** Angular Imports */ import { Component , OnInit } from '@angular/core' ; import { ActivatedRoute , Router } from '@angular/router' ; import { MatDialog } from '@angular/material/dialog' ; /** Custom Services */ import { OrganizationService } from 'app/organization/organization.service' ; /** Custom Components */ import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component' ; /**
 * View Adhoc Query Component.
 */ @ Component ( { selector : 'mifosx-view-adhoc-query' , templateUrl : './view-adhoc-query.component.html' , styleUrls : [ './view-adhoc-query.component.scss' ] } ) export class ViewAdhocQueryComponent implements OnInit { /** Adhoc query data. */ adhocQueryData : any ; param { OrganizationService } organizationService param { ActivatedRoute } route param { Router } router param { MatDialog } dialog constructor ( private organizationService , private route , private router , private dialog ) { this . route . data . subscribe ( ( data ) => { this . adhocQueryData = data . adhocQuery ; } ) ; } ngOnInit ( ) { } returns { string } get reportRunFrequency ( ) : string { for ( const reportRunFrequency of this . adhocQueryData . reportRunFrequencies ) { if ( reportRunFrequency . id === this . adhocQueryData . reportRunFrequency ) { return reportRunFrequency . value ; } } } /**
     * Deletes the adhoc query and redirects to adhoc queries.
     */ deleteAdhocQuery ( ) { const deleteAdhocQueryDialogRef = this . dialog . open ( DeleteDialogComponent , { data : { deleteContext : `adhoc query ${ this . adhocQueryData . id }` } } ) ; deleteAdhocQueryDialogRef . afterClosed ( ) . subscribe ( ( response ) => { if ( response . delete ) { this . organizationService . deleteAdhocQuery ( this . adhocQueryData . id ) . subscribe ( ( ) => { this . router . navigate ( [ '/organization/adhoc-query' ] ) ; } ) ; } } ) ; } }