blob: 4e751b83457777398c53c34a08d8c955b5edfe1e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
import { Component, OnInit, Input, SimpleChange } from '@angular/core';
import { RunService } from '../run.service';
import { ActivatedRoute } from '@angular/router';
@Component({
selector: 'app-run-report-form-fields',
templateUrl: './run-report-form-fields.component.html',
styleUrls: ['./run-report-form-fields.component.css']
})
export class RunReportFormFieldsComponent implements OnInit {
@Input("formFieldList") formFieldList : {}[];
@Input("reportId") reportId : string;
formFieldListValueArr : any[];
finalQueryParamsObj : {};
navigateToRun : boolean;
reportMode : string;
queryString : string;
constructor(private _runService : RunService, private _route : ActivatedRoute ) {
this.formFieldListValueArr = new Array();
this.finalQueryParamsObj = new Object();
this.navigateToRun = false;
this.queryString = "";
}
ngOnInit() {
this._route.params.subscribe(params => {
this.reportId = params["reportId"];
});
this._runService.getReportData(this.reportId)
.subscribe((response) => {
if(response["formFieldList"].length > 0)
{
this.formFieldList = response["formFieldList"];
this.reportMode = "FormField";
}
else
{
this.reportMode = "Regular";
this.navigateToRun = true;
}
console.log(this.navigateToRun);
});
}
ngDoCheck()
{
if(this.navigateToRun == false)
{
this.formFieldListValueArr = this.formFieldListValueArr;
for(let i=0; i<this.formFieldList.length; i++)
{
if(this.formFieldListValueArr[i])
{
this.finalQueryParamsObj[this.formFieldList[i]["fieldId"]] = this.formFieldListValueArr[i];
}
}
console.log(this.formFieldListValueArr);
console.log(this.finalQueryParamsObj);
}
}
getQueryString()
{
return this.queryString;
}
runReport()
{
this._runService.getReportData(this.reportId)
.subscribe((response) => {
this.navigateToRun = false;
if(response["formFieldList"].length > 0)
{
this.formFieldList = response["formFieldList"];
this.reportMode = "FormField";
for(let i=0; i<this.formFieldList.length; i++)
{
if(this.formFieldListValueArr[i])
{
this.finalQueryParamsObj[this.formFieldList[i]["fieldId"]] = this.formFieldListValueArr[i];
}
}
this.queryString="";
for(let k=0; k<Object.keys(this.finalQueryParamsObj).length; k++)
{
this.queryString = this.queryString + "&" + Object.keys(this.finalQueryParamsObj)[k] + "=" + this.finalQueryParamsObj[Object.keys(this.finalQueryParamsObj)[k]];
}
console.log(this.queryString);
this.navigateToRun = true;
console.log(this.navigateToRun);
}
else
{
this.navigateToRun = true;
this.reportMode = "Regular";
}
});
// this._runService.getReportDataWithFormFields(this.finalQueryParamsObj, this.reportId)
// .subscribe((responseFormFields) => {
// console.log(responseFormFields);
// });
}
}
|