1 import { Component, OnInit, Input, SimpleChange } from '@angular/core';
2 import { RunService } from '../run.service';
3 import { ActivatedRoute } from '@angular/router';
6 selector: 'app-run-report-form-fields',
7 templateUrl: './run-report-form-fields.component.html',
8 styleUrls: ['./run-report-form-fields.component.css']
10 export class RunReportFormFieldsComponent implements OnInit {
12 @Input("formFieldList") formFieldList : {}[];
13 @Input("reportId") reportId : string;
16 formFieldListValueArr : any[];
17 finalQueryParamsObj : {};
18 navigateToRun : boolean;
22 constructor(private _runService : RunService, private _route : ActivatedRoute ) {
23 this.formFieldListValueArr = new Array();
24 this.finalQueryParamsObj = new Object();
25 this.navigateToRun = false;
26 this.queryString = "";
31 this._route.params.subscribe(params => {
33 this.reportId = params["reportId"];
36 this._runService.getReportData(this.reportId)
37 .subscribe((response) => {
39 if(response["formFieldList"].length > 0)
41 this.formFieldList = response["formFieldList"];
42 this.reportMode = "FormField";
46 this.reportMode = "Regular";
47 this.navigateToRun = true;
51 console.log(this.navigateToRun);
58 if(this.navigateToRun == false)
60 this.formFieldListValueArr = this.formFieldListValueArr;
62 for(let i=0; i<this.formFieldList.length; i++)
64 if(this.formFieldListValueArr[i])
66 this.finalQueryParamsObj[this.formFieldList[i]["fieldId"]] = this.formFieldListValueArr[i];
69 console.log(this.formFieldListValueArr);
70 console.log(this.finalQueryParamsObj);
77 return this.queryString;
82 this._runService.getReportData(this.reportId)
83 .subscribe((response) => {
84 this.navigateToRun = false;
85 if(response["formFieldList"].length > 0)
87 this.formFieldList = response["formFieldList"];
88 this.reportMode = "FormField";
90 for(let i=0; i<this.formFieldList.length; i++)
92 if(this.formFieldListValueArr[i])
94 this.finalQueryParamsObj[this.formFieldList[i]["fieldId"]] = this.formFieldListValueArr[i];
99 for(let k=0; k<Object.keys(this.finalQueryParamsObj).length; k++)
101 this.queryString = this.queryString + "&" + Object.keys(this.finalQueryParamsObj)[k] + "=" + this.finalQueryParamsObj[Object.keys(this.finalQueryParamsObj)[k]];
104 console.log(this.queryString);
105 this.navigateToRun = true;
106 console.log(this.navigateToRun);
110 this.navigateToRun = true;
111 this.reportMode = "Regular";
120 // this._runService.getReportDataWithFormFields(this.finalQueryParamsObj, this.reportId)
121 // .subscribe((responseFormFields) => {
122 // console.log(responseFormFields);