summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.ts')
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.ts800
1 files changed, 0 insertions, 800 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.ts
deleted file mode 100644
index c0856b44..00000000
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.ts
+++ /dev/null
@@ -1,800 +0,0 @@
-import {Component, OnInit, Input, SimpleChange, SystemJsNgModuleLoader, OnDestroy} from '@angular/core';
-import {RunService} from '../run.service';
-import {ActivatedRoute, Router} from '@angular/router';
-import {inlineInterpolate} from '@angular/core/src/view';
-import {copyStyles} from '@angular/animations/browser/src/util';
-import {split} from 'ts-node';
-import * as cloneDeep from 'lodash/cloneDeep';
-
-@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, OnDestroy {
- @Input('formFieldList') formFieldList: {}[];
- @Input('reportId') reportId: string;
- staticFormFieldList: {}[] = [];
- formFieldListValueArr: any[];
- saveFormFieldGroups: any[];
- finalQueryParamsObj: {};
- navigateToRun: boolean;
- reportMode: string;
- queryString: string;
- reportName: string;
- reportSubTitle: string;
- showSpinner: boolean;
- showLabel: boolean;
- runDashboardReport: boolean;
- DashboardReportObj: {}[] = [];
- triggerFormFieldArr = [];
- initialObject = {};
- formFieldGroupObjList: {}[] = [];
- toggleFormFieldRenderArr: {}[] = [];
- groupSelectValue = '';
- oldGroupSelectValue = '';
- unCommonCnt = 0;
- commonCount = 0;
- totalCommonCount = 0;
- totalCount = 0;
- errorMessage = '';
- stackTrace = '';
- error = false;
- iSDashboardReport = '';
- hitCnt = 0;
- directCallQueryParams: any = '';
- calledWithFormFields = false;
- showformFiledSpinner = false;
- actualformFieldValues: any[];
- allowEdit: boolean;
- runReportAgain: boolean;
- tempFieldValues = [];
- firstRun = false;
- saveFormFieldListValueArr: any[];
- saveGroupSelectValue = '';
- avoidDoCheck = false;
- toolTipPosition = 'right';
- isResetAllowed: boolean;
- save: {}[];
- unCommonGropusList: any[];
- commonFormFields: any[];
- formFieldListValueMap: any;
- saveFormFieldListValueMap: any;
- chartType = '';
-
- constructor(private _runService: RunService, private _route: ActivatedRoute, private _router: Router) {
- this.formFieldListValueArr = [];
- this.saveFormFieldListValueArr = [];
- this.saveFormFieldGroups = [];
- this.finalQueryParamsObj = {};
- this.navigateToRun = false;
- this.queryString = '';
- this.showSpinner = false;
- this.showLabel = false;
- this.runDashboardReport = false;
- this.showformFiledSpinner = false;
- this.runReportAgain = false;
- this.tempFieldValues = [];
- this.isResetAllowed = false;
- this.unCommonGropusList = [];
- this.commonFormFields = [];
- this.formFieldListValueMap = new Map<any, any>();
- this.saveFormFieldListValueMap = new Map<any, any>();
- this.chartType = '';
- }
-
- ngOnDestroy(): void {
- this.createNewObject();
- this.showSpinner = false;
- }
-
- createNewObject() {
- this.staticFormFieldList = [];
- this.formFieldListValueArr = [];
- this.saveFormFieldGroups = [];
- this.saveFormFieldListValueArr = [];
- this.finalQueryParamsObj = {};
- this.navigateToRun = false;
- this.reportMode = '';
- this.queryString = '';
- this.reportName = '';
- this.reportSubTitle='';
- this.showSpinner = true;
- this.showLabel = false;
- this.runDashboardReport = false;
- this.DashboardReportObj = [];
- this.triggerFormFieldArr = [];
- this.initialObject = {};
- this.formFieldGroupObjList = [];
- this.toggleFormFieldRenderArr = [];
- this.groupSelectValue = '';
- this.oldGroupSelectValue = '';
- this.unCommonCnt = 0;
- this.totalCommonCount = 0;
- this.commonCount = 0;
- this.totalCount = 0;
- this.errorMessage = '';
- this.stackTrace = '';
- this.error = false;
- this.iSDashboardReport = '';
- this.hitCnt = 0;
- this.directCallQueryParams = '';
- this.calledWithFormFields = false;
- this.showformFiledSpinner = false;
- this.allowEdit = false;
- this.runReportAgain = false;
- this.isResetAllowed = false;
- this.unCommonGropusList = [];
- this.commonFormFields = [];
- this.formFieldListValueMap = new Map<any, any>();
- this.saveFormFieldListValueMap = new Map<any, any>();
- this.chartType = '';
- }
-
- ngOnInit() {
-
- this.showSpinner = true;
- this.navigateToRun = false;
- this._route.params.subscribe(params => {
- this.reportId = params['reportId'];
- this.createNewObject();
- this.groupSelectValue = params['groupSelectValue'];
- if (this.groupSelectValue === undefined) {
- this.groupSelectValue = '';
- }
- if (params['queryParameters']) {
- this.directCallQueryParams = params['queryParameters'];
- this.calledWithFormFields = true;
- this.populateQueryParams(params['queryParameters']);
- }
- this.loadPage();
- });
-
- }
-
- populateQueryParams(queryParams: any) {
- this.actualformFieldValues = this.directCallQueryParams.substring(1, this.directCallQueryParams.length).split('&');
- for (const ff of this.actualformFieldValues) {
- const formfiledArray = ff.split('=');
- const formFieldId = formfiledArray[0];
- const formFieldObj = formfiledArray[1];
- this.finalQueryParamsObj[formFieldId] = formFieldObj;
- }
- this.queryString = this.directCallQueryParams;
- }
-
- loadPage() {
- this._runService.getDefinitionPageDetails(+this.reportId)
- .subscribe((responseDefPage) => {
- this.reportName = responseDefPage['reportName'];
- this.reportSubTitle = responseDefPage['reportSubTitle'];
- this.chartType = responseDefPage['chartType'];
- if (responseDefPage['reportType'] !== 'Dashboard') {
- if (this.calledWithFormFields == false) {
- this._runService.getReportData(this.reportId)
- .subscribe((response) => {
- if (response['errormessage']) {
- this.allowEdit = response['allowEdit'];
- this.showError(response);
- } else {
- this.allowEdit = response['allowEdit'];
- this.reportName = response['reportName'];
- if (response['formFieldList'].length > 0) {
- this.fetchAndPopulateFormFields(response, this.reportId);
- this.showformFiledSpinner = true;
- } else {
- this.formFieldList = response['formFieldList'];
- this.reportMode = 'Regular';
- this.navigateToRun = true;
- this.showformFiledSpinner = false;
-
- }
- this.showSpinner = false;
- }
- });
- } else if (this.calledWithFormFields == true) {
- this._runService.getReportData(this.reportId)
- .subscribe((response) => {
- if (response['errormessage']) {
- this.showError(response);
- } else {
- this.error = false;
- this.reportName = response['reportName'];
- this.allowEdit = response['allowEdit'];
- if (response['formFieldList'].length > 0) {
- this.setDefaultFieldGroupValueForNonSelected(response['formFieldList']);
- this.generateQueryString();
- this.fetchAndPopulateFormFields(response, this.reportId);
- this.formFieldListValueMap = new Map<any, any>();
- for (const ff of response['formFieldList']) {
- if (this.finalQueryParamsObj[ff.fieldId]) {
- if (ff.validationType == 'DATE') {
- const dateVal = this.finalQueryParamsObj[ff.fieldId];
- this.formFieldListValueMap.set(ff.fieldId, new Date(dateVal.toString().replace(/%2F/g, '/')));
- } else if (ff.fieldType == 'LIST_MULTI_SELECT') {
- const multiSelectArray = [];
- let multiVal = this.finalQueryParamsObj[ff.fieldId];
- multiVal = multiVal.toString().replace(/%2F/g, '/');
- multiVal = multiVal.toString().replace('+', ' ');
- multiSelectArray.push(multiVal);
- this.formFieldListValueMap.set(ff.fieldId, multiSelectArray);
- } else {
- let multiVal = this.finalQueryParamsObj[ff.fieldId];
- multiVal = multiVal.toString().replace(/%2F/g, '/');
- multiVal = multiVal.toString().split('+').join(' ');
- this.formFieldListValueMap.set(ff.fieldId, multiVal);
- }
- } else {
- if (ff.fieldType == 'LIST_MULTI_SELECT') {
- const multiSelectArray = [];
- this.formFieldListValueMap.set(ff.fieldId, multiSelectArray);
- } else {
- this.formFieldListValueMap.set(ff.fieldId, '');
- }
- }
- }
- this.error = false;
- this.navigateToRun = true;
- this.showformFiledSpinner = true;
- this.directCallQueryParams = '';
- } else {
- this.reportMode = 'Regular';
- this.navigateToRun = true;
- this.showformFiledSpinner = false;
-
- }
- this.showSpinner = false;
-
- }
- });
- } else {
- this.reportMode = 'FormField';
- this.navigateToRun = true;
- this.showSpinner = false;
- this.showformFiledSpinner = true;
- }
- } else {
- if (this.calledWithFormFields == false) {
- this.iSDashboardReport = 'Dashboard';
- this.reportName = responseDefPage['reportName'];
- this.DashboardReportObj = JSON.parse(responseDefPage['dashboardLayoutJSON']);
- let i = 0;
- let subReportId = '';
- const tempDashboardArray = [];
- for (let dash = 0; dash < this.DashboardReportObj.length ; dash++) {
- if (this.DashboardReportObj[dash]['hasContent']['hideDisplay'] !== true) {
- tempDashboardArray.push(this.DashboardReportObj[dash]);
- }
- }
- this.DashboardReportObj = [];
- this.DashboardReportObj = tempDashboardArray;
- while (this.DashboardReportObj[i]) {
- subReportId = this.DashboardReportObj[i]['hasContent']['id'].split('#')[1];
- i++;
- break;
- }
- this._runService.getReportData(subReportId)
- .subscribe((response) => {
- if (response['errormessage']) {
- this.showError(response);
- this.allowEdit = response['allowEdit'];
- } else {
- this.allowEdit = response['allowEdit'];
- if (response['formFieldList'].length > 0) {
- this.fetchAndPopulateFormFields(response, subReportId);
- } else {
- this.navigateToRun = true;
- }
- this.runDashboardReport = true;
- this.showSpinner = false;
- this.showformFiledSpinner = true;
- }
- });
- this.showSpinner = false;
- this.showformFiledSpinner = true;
- } else if (this.calledWithFormFields == true) {
- this.iSDashboardReport = 'Dashboard';
- this.reportName = responseDefPage['reportName'];
- this.DashboardReportObj = JSON.parse(responseDefPage['dashboardLayoutJSON']);
- const tempDashboardArray = [];
- for (let dash = 0; dash < this.DashboardReportObj.length ; dash++) {
- if (this.DashboardReportObj[dash]['hasContent']['hideDisplay'] !== true) {
- tempDashboardArray.push(this.DashboardReportObj[dash]);
- }
- }
- this.DashboardReportObj = [];
- this.DashboardReportObj = tempDashboardArray;
- let subReportId = '';
- for (const dashboard of this.DashboardReportObj) {
- let temp = '';
- temp = dashboard['hasContent']['id'].split('#')[1];
- subReportId = temp;
- this.directCallQueryParams = '';
- this.runDashboardReport = true;
- this.navigateToRun = true;
- this.showSpinner = false;
- }
- }
- }
- });
- }
-
- toggleChangeWhenCalledWithFromFields(){
- this.calledWithFormFields = false;
- }
-
- async ngDoCheck() {
-
- if (this.formFieldList !== undefined) {
-
- if (this.groupSelectValue !== this.oldGroupSelectValue) {
- // this.formFieldListValueArr.splice(this.commonCount-1, this.formFieldListValueArr.length)
- this.removePrevioustoggleGroupData();
- this.oldGroupSelectValue = this.groupSelectValue;
- this.formFieldGroupObjList = [];
- this.saveFormFieldGroups = [];
- this.formFieldGroupObjList = cloneDeep(this.save);
- this.saveFormFieldGroups = cloneDeep(this.save);
- for (const formFieldGroupObjItem of this.formFieldGroupObjList) {
- if (formFieldGroupObjItem['name'] == this.groupSelectValue) {
- this.toggleFormFieldRenderArr = formFieldGroupObjItem['formFieldList'];
- }
-
- }
- if (this.toggleFormFieldRenderArr.length > 0) {
- for (let i = 0; i < this.toggleFormFieldRenderArr.length; i++) {
- const formFieldObj = this.toggleFormFieldRenderArr[i];
- if (formFieldObj['triggerOtherFormFields'] === true) {
- const formFieldId = formFieldObj['fieldId'];
- this.triggerFormFieldArr.push(formFieldId);
- this.initialObject[formFieldId] = '1';
- this.finalQueryParamsObj[formFieldId] = '1';
- }
- }
- }
-
- if(this.calledWithFormFields != true){
- for (const formFieldGroupObjItem of this.saveFormFieldGroups) {
- if (formFieldGroupObjItem['name'] == this.groupSelectValue) {
- this.toggleFormFieldRenderArr = formFieldGroupObjItem['formFieldList'];
- for (let ffGrpValue = 0; ffGrpValue < formFieldGroupObjItem['formFieldList'].length; ffGrpValue++) {
- if (formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'].length > 0) {
- for (let ffValue = 0; ffValue < formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'].length; ffValue++) {
- if (formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldType'] == 'LIST_BOX' && formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'].length > 0) {
- let isAdded = false;
- for (let ffValue = 0; ffValue < formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'].length; ffValue++) {
- if (formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'][ffValue]['defaultValue'] == true) {
- this.formFieldListValueMap.set(formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldId'], formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'][ffValue]['id']);
- isAdded = true;
- }
- }
- if (!isAdded) {
- this.formFieldListValueMap.set(formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldId'], '');
- }
- } else if ((formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldType'] == 'LIST_MULTI_SELECT' || formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldType'] == 'TEXT') && formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'].length > 0) {
- let isAdded = false;
- for (let ffValue = 0; ffValue < formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'].length; ffValue++) {
-
- if (formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'][ffValue]['defaultValue'] == true) {
- const multiSelectArray = [];
- multiSelectArray.push(formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'][ffValue]['id']);
- this.formFieldListValueMap.set(formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldId'], multiSelectArray);
- isAdded = true;
- }
- }
- if (!isAdded) {
- this.formFieldListValueMap.set(formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldId'], '');
- }
- } else if (formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldType'] == 'Select Field Type' && formFieldGroupObjItem['formFieldList'][ffGrpValue]['validationType'] == 'NONE') {
- let isAdded = false;
- for (let ffValue = 0; ffValue < formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'].length; ffValue++) {
-
- if (formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'][ffValue]['defaultValue'] == true) {
- this.formFieldListValueMap.set(formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldId'], formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'][ffValue]['id']);
- isAdded = true;
- }
- }
- if (!isAdded) {
- this.formFieldListValueArr[this.totalCommonCount + ffGrpValue] = '';
- }
- } else {
- this.formFieldListValueMap.set(formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldId'], '');
- }
- }
- } else {
- this.formFieldListValueMap.set(formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldId'], '');
- }
- }
- }
- }
- }
- if (this.formFieldGroupObjList.length > 0) {
- for (let ffl = 0; ffl < this.formFieldList.length; ffl++) {
- for (let ffgl = 0; ffgl < this.formFieldGroupObjList.length; ffgl++) {
- const inList = this.formFieldGroupObjList[ffgl]['formFieldList'];
-
- for (let inl = 0; inl < inList.length; inl++) {
- let cntr = 0;
- if (inList[inl]['fieldId'] == this.formFieldList[ffl]['fieldId']) {
- cntr++;
- }
- if (cntr == 0) {
- this.finalQueryParamsObj[inList[inl]['fieldId']] = '-1';
- }
- }
-
- }
- }
- }
- }
- for (const tffr of this.toggleFormFieldRenderArr) {
- if (this.formFieldListValueMap.get(tffr['fieldId']) || this.formFieldListValueMap.get(tffr['fieldId']) == "") {
- if (tffr['validationType'] == 'DATE') {
- this.finalQueryParamsObj[tffr['fieldId']] = this.convertDate(this.formFieldListValueMap.get(tffr['fieldId']));
- } else if (this.formFieldListValueMap.get(tffr['fieldId']) == "") {
-
- if (tffr['fieldType'] == 'LIST_MULTI_SELECT') {
- let multiSelectValue = '';
- for (let ffValue = 0; ffValue < tffr['formFieldValues'].length; ffValue++) {
- multiSelectValue = multiSelectValue + tffr['formFieldValues'][ffValue]['id'] + '|';
- }
- if (multiSelectValue != '') {
- multiSelectValue = multiSelectValue.substring(0, multiSelectValue.length - 1);
- }
- this.finalQueryParamsObj[tffr['fieldId']] = multiSelectValue;
-
- } else {
- this.finalQueryParamsObj[tffr['fieldId']] = '';
- }
- } else {
- this.finalQueryParamsObj[tffr['fieldId']] = this.formFieldListValueMap.get(tffr['fieldId']);
- for (const trigElement of this.triggerFormFieldArr) {
- if (this.initialObject[trigElement] !== this.finalQueryParamsObj[trigElement]) {
- this.initialObject[trigElement] = this.finalQueryParamsObj[trigElement];
- this.generateQueryString();
- await this.delay(1000);
- console.log('Afterp: ' + new Date().toString());
- this._runService.refreshFormFields(this.reportId, this.queryString)
- .subscribe((responseRefreshFF) => {
- for (let rrff = 0; rrff < responseRefreshFF['formFieldList'].length; rrff++) {
- for (let innerTFRR = 0; innerTFRR < this.toggleFormFieldRenderArr.length; innerTFRR++) {
- if (responseRefreshFF['formFieldList'][rrff]['fieldId'] == this.toggleFormFieldRenderArr[innerTFRR]['fieldId']) {
- this.toggleFormFieldRenderArr[innerTFRR] = responseRefreshFF['formFieldList'][rrff];
- }
- }
- }
- });
- this.initialObject[trigElement] = this.finalQueryParamsObj[trigElement];
- }
- }
-
- }
- }
- }
-
- if (this.reportMode !== 'Regular' && this.reportMode !== 'Dashboard') {
- for (const ffvalue of this.formFieldList) {
- if (this.formFieldListValueMap.get(ffvalue['fieldId'])) {
- if (ffvalue['validationType'] == 'DATE') {
- this.finalQueryParamsObj[ffvalue['fieldId']] = this.convertDate(this.formFieldListValueMap.get(ffvalue['fieldId']));
- } else {
- this.finalQueryParamsObj[ffvalue['fieldId']] = this.formFieldListValueMap.get(ffvalue['fieldId']);
- for (const trigElement of this.triggerFormFieldArr) {
- if (this.initialObject[trigElement] !== this.finalQueryParamsObj[trigElement]) {
- this.initialObject[trigElement] = this.finalQueryParamsObj[trigElement];
- this.generateQueryString();
- await this.delay(1000);
- console.log('Afterp: ' + new Date().toString());
- this._runService.refreshFormFields(this.reportId, this.queryString)
- .subscribe((responseRefreshFF) => {
-
- for (let rrff = 0; rrff < responseRefreshFF['formFieldList'].length; rrff++) {
- for (let innerFFL = 0; innerFFL < this.formFieldList.length; innerFFL++) {
- if (responseRefreshFF['formFieldList'][rrff]['fieldId'] == this.formFieldList[innerFFL]['fieldId']) {
- this.formFieldList[innerFFL] = responseRefreshFF['formFieldList'][rrff];
- }
- }
- }
- });
- }
- }
-
- }
- }
- }
-
- }
- }
- if (this.firstRun) {
- this.saveGroupSelectValue = this.groupSelectValue;
- this.saveFormFieldListValueMap = cloneDeep(this.formFieldListValueMap);
- }
- this.firstRun = false;
- }
-
- convertDate(str) {
- const date = new Date(str),
- mnth = ('0' + (date.getMonth() + 1)).slice(-2),
- day = ('0' + date.getDate()).slice(-2);
- return [mnth, day, date.getFullYear()].join('/');
- }
-
- getQueryString() {
- if (this.directCallQueryParams !== '') {
- return this.directCallQueryParams;
- } else {
- return this.queryString;
- }
- }
-
- fetchAndPopulateFormFields(respObj: any, ffReportId: string) {
- this._runService.getFormFieldGroupsData(ffReportId)
- .subscribe((responseFormFieldGroups) => {
- this.firstRun = true;
- this.showformFiledSpinner = false;
- this.formFieldGroupObjList = JSON.parse(responseFormFieldGroups['formFieldGroupsJSON']);
- this.saveFormFieldGroups = JSON.parse(responseFormFieldGroups['formFieldGroupsJSON']);
- this.formFieldList = respObj['formFieldList'];
- this.staticFormFieldList = respObj['formFieldList'];
- this.reportMode = 'FormField';
- this.totalCount = this.formFieldList.length;
- if (this.formFieldGroupObjList !== null) {
- for (let ffgl = 0; ffgl < this.formFieldGroupObjList.length; ffgl++) {
- for (let itemFFGL = 0; itemFFGL < this.formFieldGroupObjList[ffgl]['formFieldList'].length; itemFFGL++) {
- const formFieldGroupItem = this.formFieldGroupObjList[ffgl]['formFieldList'][itemFFGL];
- for (let fflg = 0; fflg < this.formFieldList.length; fflg++) {
- if (formFieldGroupItem['id'] == this.formFieldList[fflg]['fieldId']) {
- this.formFieldGroupObjList[ffgl]['formFieldList'][itemFFGL] = this.formFieldList[fflg];
- this.saveFormFieldGroups[ffgl]['formFieldList'][itemFFGL] = this.formFieldList[fflg];
-
- if (this.formFieldList[fflg]['triggerOtherFormFields'] === true) {
- const formFieldId = this.formFieldList[fflg]['fieldId'];
- this.triggerFormFieldArr.push(formFieldId);
- this.initialObject[formFieldId] = [];
- this.finalQueryParamsObj[formFieldId] = [];
- }
- this.formFieldList.splice(fflg, 1);
- this.unCommonGropusList.push(formFieldGroupItem);
- this.unCommonCnt++;
- }
- }
- }
- }
- }
- if(this.calledWithFormFields != true){
- for (let checkRadio = 0; checkRadio < this.formFieldList.length; checkRadio++) {
- if (this.formFieldList[checkRadio]['fieldDisplayName'] == 'selectCriteria') {
- for (let ffValue = 0; ffValue < this.formFieldList[checkRadio]['formFieldValues'].length; ffValue++) {
- if (this.formFieldList[checkRadio]['formFieldValues'][ffValue]['defaultValue'] == true) {
- this.groupSelectValue = this.formFieldList[checkRadio]['formFieldValues'][ffValue]['name'];
- }
- }
- this.oldGroupSelectValue = this.groupSelectValue;
- }
- }
- }
- this.commonCount = this.totalCount - this.unCommonCnt;
- this.totalCommonCount = this.commonCount;
- console.log(this.unCommonGropusList);
- console.log(this.formFieldList);
- for (let i = 0; i < this.formFieldList.length; i++) {
- const formFieldObj = this.formFieldList[i];
- if (formFieldObj['formFieldValues'] != null && this.calledWithFormFields != true) {
- if (formFieldObj['validationType'] == 'DATE' && formFieldObj['formFieldValues'].length > 0) {
- const date = formFieldObj['formFieldValues'][0]['id'];
- this.formFieldListValueMap.set(formFieldObj['fieldId'], new Date(date));
- } else if (formFieldObj['fieldType'] == 'LIST_BOX' && formFieldObj['formFieldValues'].length > 0) {
- let isAdded = false;
- for (let ffValue = 0; ffValue < formFieldObj['formFieldValues'].length; ffValue++) {
- if (formFieldObj['formFieldValues'][ffValue]['defaultValue'] == true) {
- this.formFieldListValueMap.set(formFieldObj['fieldId'], formFieldObj['formFieldValues'][ffValue]['id']);
- isAdded = true;
- }
- }
- if (!isAdded) {
- this.formFieldListValueMap.set(formFieldObj['fieldId'], '');
- }
- } else if ((formFieldObj['fieldType'] == 'LIST_MULTI_SELECT' || formFieldObj['fieldType'] == 'TEXT') && formFieldObj['formFieldValues'].length > 0) {
- let isAdded = false;
- for (let ffValue = 0; ffValue < formFieldObj['formFieldValues'].length; ffValue++) {
-
- if (formFieldObj['formFieldValues'][ffValue]['defaultValue'] == true) {
- const multiSelectArray = [];
- multiSelectArray.push(formFieldObj['formFieldValues'][ffValue]['id']);
- this.formFieldListValueMap.set(formFieldObj['fieldId'], multiSelectArray);
- isAdded = true;
- }
- }
- if (!isAdded) {
- this.formFieldListValueMap.set(formFieldObj['fieldId'], '');
- }
- } else if (formFieldObj['fieldDisplayName'] == 'DefaultRadio') {
- this.formFieldListValueMap.set(formFieldObj['fieldId'], '');
-
- } else {
- this.formFieldListValueMap.set(formFieldObj['fieldId'], '');
- }
- }
-
- if (formFieldObj['triggerOtherFormFields'] === true) {
- const formFieldId = formFieldObj['fieldId'];
- this.triggerFormFieldArr.push(formFieldId);
- this.initialObject[formFieldId] = [];
- this.finalQueryParamsObj[formFieldId] = [];
- }
- }
-
- console.log(this.formFieldListValueMap);
-
- if(this.calledWithFormFields != true){
- if (this.formFieldGroupObjList !== null) {
- for (const formFieldGroupObjItem of this.formFieldGroupObjList) {
- if (formFieldGroupObjItem['name'] == this.groupSelectValue) {
- this.toggleFormFieldRenderArr = formFieldGroupObjItem['formFieldList'];
- for (let ffGrpValue = 0; ffGrpValue < formFieldGroupObjItem['formFieldList'].length; ffGrpValue++) {
- if (formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'].length > 0) {
- for (let ffValue = 0; ffValue < formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'].length; ffValue++) {
- if (formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'][ffValue]['defaultValue'] == true) {
- if (formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldType'] == 'LIST_MULTI_SELECT') {
- const multiSelectArray = [];
- multiSelectArray.push(formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'][ffValue]['id']);
- this.formFieldListValueMap.set(formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldId'], multiSelectArray);
- } else {
- this.formFieldListValueMap.set(formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldId'], formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'][ffValue]['id']);
- }
- }
- }
- } else {
- this.formFieldListValueMap.set(formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldId'], '');
-
- }
- }
- }
-
- }
- }
- }
- console.log('finalMap', this.formFieldListValueMap);
- if (this.formFieldGroupObjList !== null) {
- if (this.formFieldGroupObjList.length > 0) {
- for (let ffl = 0; ffl < this.formFieldList.length; ffl++) {
- for (let ffgl = 0; ffgl < this.formFieldGroupObjList.length; ffgl++) {
- const inList = this.formFieldGroupObjList[ffgl]['formFieldList'];
-
- for (let inl = 0; inl < inList.length; inl++) {
- let cntr = 0;
- if (inList[inl]['fieldId'] == this.formFieldList[ffl]['fieldId']) {
- cntr++;
- }
- if (cntr == 0) {
- this.finalQueryParamsObj[inList[inl]['fieldId']] = '-1';
- }
- }
-
- }
- }
- }
- }
- this.save = cloneDeep(this.formFieldGroupObjList);
- });
- }
-
- generateQueryString() {
-
- this.queryString = '';
- for (let k = 0; k < Object.keys(this.finalQueryParamsObj).length; k++) {
- if (typeof (this.finalQueryParamsObj[Object.keys(this.finalQueryParamsObj)[k]]) == 'object') {
- const key = Object.keys(this.finalQueryParamsObj)[k];
- let qstr = '';
- let l = 0;
- while (this.finalQueryParamsObj[key][l]) {
- if (l === 0) {
- qstr = qstr + this.finalQueryParamsObj[Object.keys(this.finalQueryParamsObj)[k]][l];
- } else {
- qstr = qstr + '|' + this.finalQueryParamsObj[Object.keys(this.finalQueryParamsObj)[k]][l];
- }
- l++;
- }
- if (qstr !== '') {
- this.queryString = this.queryString + '&' + Object.keys(this.finalQueryParamsObj)[k] + '=' + qstr;
- }
- } else {
- if (typeof (this.finalQueryParamsObj[Object.keys(this.finalQueryParamsObj)[k]]) == 'string') {
- this.queryString = this.queryString + '&' + Object.keys(this.finalQueryParamsObj)[k] + '=' + this.finalQueryParamsObj[Object.keys(this.finalQueryParamsObj)[k]];
- } else {
- this.queryString = this.queryString + '&' + Object.keys(this.finalQueryParamsObj)[k] + '=' + this.finalQueryParamsObj[Object.keys(this.finalQueryParamsObj)[k]];
- }
- }
-
- }
-
- }
-
- showError(Errresponse: any) {
- this.errorMessage = Errresponse['errormessage'];
- this.stackTrace = Errresponse['stacktrace'];
- this.error = true;
- this.showSpinner = false;
- }
-
- runReport() {
- this.hitCnt++;
- this.showSpinner = true;
- if (this.iSDashboardReport !== 'Dashboard') {
- if (this.formFieldList.length > 0) {
- this.reportMode = 'FormField';
- this.generateQueryString();
- } else {
- this.reportMode = 'Regular';
- }
- this.showSpinner = false;
- } else {
- this.generateQueryString();
- this.showSpinner = false;
- }
- this.runReportAgain = !this.runReportAgain;
- this.navigateToRun = true;
- }
-
- editReport(reportId: string) {
- this._router.navigate(['v2/app/reports', 'Edit', reportId]);
- }
-
- showLabelFn() {
- this.showLabel = !this.showLabel;
- }
-
- setDefaultFieldGroupValueForNonSelected(formFieldsList: any) {
- this.tempFieldValues = [];
- const map = new Map<string, string>();
- for (const value in this.finalQueryParamsObj) {
- map.set(value, this.finalQueryParamsObj[value]);
- }
- for (const ffl of formFieldsList) {
- if (!map.get(ffl['fieldId']) && ffl['formFieldValues'].length === 1) {
- this.tempFieldValues = ffl['formFieldValues'];
- if (ffl['fieldDisplayName'] == this.tempFieldValues[0]['name']) {
- this.finalQueryParamsObj[ffl['fieldId']] = '-1';
- }
- }
- }
- }
-
- resetFormFieldValues() {
- sessionStorage.clear();
- const myItem = localStorage.getItem('id');
- localStorage.clear();
- localStorage.setItem('id', myItem);
- if (this.formFieldGroupObjList != null) {
- this._router.navigateByUrl('v2/app/refresh', {skipLocationChange: true}).then(() =>
- this._router.navigate(['v2/app/run', this.reportId]));
- } else {
- this.avoidDoCheck = true;
- this.formFieldListValueMap = new Map<any, any>();
- this.finalQueryParamsObj = [];
- if (this.calledWithFormFields == false) {
- this.formFieldListValueMap = cloneDeep(this.saveFormFieldListValueMap);
- }
-
- }
- }
-
- private delay(ms: number) {
- return new Promise(resolve => setTimeout(resolve, ms));
- }
-
- private removePrevioustoggleGroupData() {
- for (const formFieldGroupObjItem of this.formFieldGroupObjList) {
- if (formFieldGroupObjItem['name'] == this.oldGroupSelectValue) {
- for (let ffGrpValue = 0; ffGrpValue < formFieldGroupObjItem['formFieldList'].length; ffGrpValue++) {
- this.finalQueryParamsObj[formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldId']] = '-1';
- this.formFieldListValueMap.delete(formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldId']);
- this.triggerFormFieldArr= [];
- }
-
- }
- }
- }
-}
-
-