summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/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/form-fields/form-fields.component.ts')
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.ts194
1 files changed, 172 insertions, 22 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.ts
index e8a60849..8d2ce96c 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.ts
@@ -1,4 +1,4 @@
-import {Component, OnInit, Input, Inject} from '@angular/core';
+import {Component, OnInit, Input, Inject, ChangeDetectorRef} from '@angular/core';
import {FormFieldsService} from './form-fields.service';
import {MatDialog, MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog';
import {Observable} from 'rxjs';
@@ -52,12 +52,21 @@ export class FormFieldsComponent implements OnInit {
queryObj: {};
validateResponseString: string;
showVerifySpinner: boolean;
- Groups: {}[] = [];
+ Groups: any;
isDefaultSql: boolean;
showConfirmButton: boolean;
-
-
- constructor(private _formFieldsService: FormFieldsService, public dialog: MatDialog, private _snackBar: MatSnackBar) {
+ showReOrderButton: boolean;
+ orderSeqArray: any;
+ showDateRange: any;
+ rangeStartDate :any;
+ rangeEndDate :any;
+ rangeStartDateSQL :any;
+ rangeEndDateSQL:any;
+ isDefaultSqlRange:boolean;
+ isFFDate: boolean;
+
+
+ constructor(private _formFieldsService: FormFieldsService, public dialog: MatDialog, private _snackBar: MatSnackBar,private changeDetectorRefs: ChangeDetectorRef) {
this.formFieldsListObj = [];
this.postMoveUpwrdObj = {};
this.postDownwardObj = {};
@@ -72,19 +81,49 @@ export class FormFieldsComponent implements OnInit {
this.showVerifySpinner = false;
this.Groups = [];
this.isDefaultSql = false;
+ this.showReOrderButton = false;
+ this.orderSeqArray = [];
+ this.showDateRange = false;
+ this.isDefaultSqlRange = false;
+ this.rangeStartDate ='';
+ this.rangeEndDate='';
+ this.rangeStartDateSQL ='';
+ this.rangeEndDateSQL='';
+ this.isFFDate = false;
}
ngOnInit() {
this._formFieldsService.getListOfFormFields()
.subscribe((responseFormFields) => {
for (let m = 0; m < responseFormFields.length; m++) {
- responseFormFields[m]['orderSeq'] = m + 1;
this.formFieldsListObj.push(responseFormFields[m]);
}
+ this.formFieldsListObj = this.formFieldsListObj.sort(function (a, b) {
+ if ((a['orderSeq']) === (b['orderSeq'])) {
+ return a;
+ } else {
+ return (a['orderSeq']) - (b['orderSeq']);
+ }
+ });
+ for (let ff = 0; ff < this.formFieldsListObj.length; ff++) {
+ let val = this.formFieldsListObj[ff]['orderSeq'];
+ this.orderSeqArray.push(val);
+ }
+ if (this.orderSeqArray.includes(null) || this.orderSeqArray.length !== new Set(this.orderSeqArray).size) {
+ this.reOrder();
+ }
this._formFieldsService.getFormFieldGroupsData(this.reportId1)
.subscribe((responseGroupsData) => {
this.Groups = JSON.parse(responseGroupsData['formFieldGroupsJSON']);
+ this.Groups = this.Groups.sort(function (a, b) {
+ if ((a['orderSeq']) === (b['orderSeq'])) {
+ return a;
+ } else {
+ return (a['orderSeq']) - (b['orderSeq']);
+ }
+ });
+
});
});
}
@@ -124,11 +163,6 @@ export class FormFieldsComponent implements OnInit {
this.postMoveUpwrdObj['orderSeq'] = this.orderSeqOfUp;
this.postDownwardObj['orderSeq'] = this.orderSeqOfDown;
- console.log(this.postDownwardObj);
- console.log(this.postMoveUpwrdObj);
- this.postMoveUpwrdObj['lastUpdatedFieldId'] = this.postDownwardObj['fieldId'];
- this.postDownwardObj['lastUpdatedFieldId'] = this.postMoveUpwrdObj['fieldId'];
-
this._formFieldsService.postFormFieldData(this.postDownwardObj, this.reportId1)
.subscribe((responsePostn) => {
if (responsePostn['message']) {
@@ -148,6 +182,7 @@ export class FormFieldsComponent implements OnInit {
}
}
this.showSpinner = false;
+ this.updateGroupOnOrderChange();
});
}
});
@@ -156,10 +191,23 @@ export class FormFieldsComponent implements OnInit {
});
});
+ }
-
+ updateGroupOnOrderChange() {
+ let formfieldsMap: Map<string, string> = new Map();
+ for (let i = 0; i < this.formFieldsListObj.length; i++) {
+ formfieldsMap.set(this.formFieldsListObj[i]['id'], this.formFieldsListObj[i]['orderSeq']);
+ }
+ for (let k = 0; k < this.Groups.length; k++) {
+ let element = this.Groups[k];
+ for (let l = 0; l < element['formFieldList'].length; l++) {
+ element['formFieldList'][l]['orderSeq'] = formfieldsMap.get(element['formFieldList'][l]['id']);
+ }
+ }
+ this.saveFormFieldGroups();
}
+
moveDownward(n: number) {
this.showSpinner = true;
@@ -176,13 +224,6 @@ export class FormFieldsComponent implements OnInit {
this.postMoveUpwrdObj['orderSeq'] = this.orderSeqOfUp;
this.postDownwardObj['orderSeq'] = this.orderSeqOfDown;
-
- console.log(this.postDownwardObj);
- console.log(this.postMoveUpwrdObj);
-
- this.postMoveUpwrdObj['lastUpdatedFieldId'] = this.postDownwardObj['fieldId'];
- this.postDownwardObj['lastUpdatedFieldId'] = this.postMoveUpwrdObj['fieldId'];
-
this._formFieldsService.postFormFieldData(this.postDownwardObj, this.reportId1)
.subscribe((responsePostn) => {
if (responsePostn['message']) {
@@ -194,7 +235,6 @@ export class FormFieldsComponent implements OnInit {
this._formFieldsService.getListOfFormFields()
.subscribe((finalListResponse) => {
for (let k = 0; k < finalListResponse.length; k++) {
- // this.formFieldsListObj.push(finalListResponse[k]);
for (let m = 0; m < finalListResponse.length; m++) {
if (finalListResponse[m]['orderSeq'] == k + 1) {
this.formFieldsListObj.push(finalListResponse[m]);
@@ -202,6 +242,7 @@ export class FormFieldsComponent implements OnInit {
}
}
this.showSpinner = false;
+ this.updateGroupOnOrderChange();
});
}
});
@@ -230,11 +271,54 @@ export class FormFieldsComponent implements OnInit {
this.openEditDialog(group);
}
+
+ setDate($event : any){
+ const mnth = ('0' + ($event.getMonth() + 1)).slice(-2);
+ const day = ('0' + $event.getDate()).slice(-2);
+ let temp = [mnth, day, $event.getFullYear()].join('/');
+ temp = temp+' '+ '00:00:00';
+
+ return temp;
+
+ }
edit(id: string) {
this._formFieldsService.getFormFieldData(id)
.subscribe((responseFormFieldData) => {
- this.validationType = responseFormFieldData['validationType'];
+ this.validationType = responseFormFieldData["validationType"];
+ this.showDateRange = false;
+ if(this.validationType ==='DATE'){
+ this.showDateRange = true;
+ if (responseFormFieldData['rangeStartDate'] != null) {
+ if (responseFormFieldData['rangeStartDate'] != '')
+ this.rangeStartDate = new Date(responseFormFieldData['rangeStartDate']); else {
+ this.rangeStartDate = '';
+ }
+ } else {
+ this.rangeStartDate = '';
+ }
+ if (responseFormFieldData['rangeEndDate'] != null) {
+ if (responseFormFieldData['rangeEndDate'] != '')
+ this.rangeEndDate = new Date(responseFormFieldData['rangeEndDate']);
+ else {
+ this.rangeEndDate = '';
+ }
+ } else {
+ this.rangeEndDate = '';
+ }
+ this.rangeStartDateSQL = responseFormFieldData['rangeStartDateSQL'];
+ this.rangeEndDateSQL = responseFormFieldData['rangeEndDateSQL'];
+ if ((this.rangeStartDate == '' && this.rangeEndDate == '')) {
+ this.isDefaultSqlRange = true;
+ } else {
+
+ this.isDefaultSqlRange = false;
+ }
+
+ if ((this.rangeStartDate == '' && this.rangeEndDate == '' && this.rangeEndDateSQL == '' && this.rangeStartDateSQL == '')) {
+ this.isDefaultSqlRange = false;
+ }
+ }
if (responseFormFieldData['visible'] === true) {
this.visible = 'YES';
} else {
@@ -298,9 +382,15 @@ export class FormFieldsComponent implements OnInit {
this.isDefaultSql = false;
this.predefinedValueList = [];
this.defaultValue = '';
-
+ this.orderSeq = null;
this.showDialog = true;
this.closable = true;
+ this.isDefaultSqlRange = false;
+ this.rangeStartDate ='';
+ this.rangeEndDate='';
+ this.rangeStartDateSQL ='';
+ this.rangeEndDateSQL='';
+ this.showDateRange='';
this.mode = 'Add';
@@ -340,7 +430,30 @@ export class FormFieldsComponent implements OnInit {
this.showSpinner = true;
this.showDialog = false;
this.finalPOSTObj['validationType'] = this.validationType;
+ if (this.validationType === 'DATE') {
+ if (this.rangeStartDate != null && this.rangeStartDate != '') {
+ this.finalPOSTObj['rangeStartDate'] = this.setDate(this.rangeStartDate);
+ } else {
+ this.finalPOSTObj['rangeStartDate'] = '';
+ }
+ if (this.rangeEndDate != null && this.rangeEndDate != '') {
+ this.finalPOSTObj['rangeEndDate'] = this.setDate(this.rangeEndDate);
+ } else {
+ this.finalPOSTObj['rangeEndDate'] = '';
+ }
+ this.finalPOSTObj['rangeStartDateSQL'] = this.rangeStartDateSQL;
+ this.finalPOSTObj['rangeEndDateSQL'] = this.rangeEndDateSQL;
+ }
+
+ if (this.isDefaultSqlRange) {
+ this.finalPOSTObj['rangeStartDate'] = '';
+ this.finalPOSTObj['rangeEndDate'] = '';
+ }
+ if (!this.isDefaultSqlRange) {
+ this.finalPOSTObj['rangeStartDateSQL'] = '';
+ this.finalPOSTObj['rangeEndDateSQL'] = '';
+ }
if (this.visible == 'YES') {
this.finalPOSTObj['visible'] = true;
} else {
@@ -363,6 +476,8 @@ export class FormFieldsComponent implements OnInit {
this.finalPOSTObj['defaultValue'] = this.defaultValue;
+ this.finalPOSTObj['defaultValue'] = this.defaultValue;
+
if (this.fieldDefaultSQL != '' && this.fieldDefaultSQL != null) {
this.finalPOSTObj['defaultValue'] = '';
}
@@ -443,6 +558,24 @@ export class FormFieldsComponent implements OnInit {
this.validateResponseString = responseDefaultSQL['data']['elements'];
this.showVerifySpinner = false;
});
+ } else if (SQLType == 'startDateRange' || SQLType =='endDateRange'){
+
+ if(SQLType == 'startDateRange'){
+ this.queryObj = {
+ query: this.rangeStartDateSQL
+ };
+ }
+ if(SQLType == 'endDateRange'){
+ this.queryObj = {
+ query: this.rangeEndDateSQL
+ };
+ }
+ this._formFieldsService.verifySQL(this.queryObj)
+ .subscribe((responseDefaultSQL) => {
+ this.validateResponseString = responseDefaultSQL['data']['elements'];
+ this.showVerifySpinner = false;
+ });
+
} else {
this.queryObj = {
query: this.fieldSQL
@@ -527,6 +660,23 @@ export class FormFieldsComponent implements OnInit {
});
}
+ reOrder() {
+ this._formFieldsService.reOrderFFValues()
+ .subscribe((response) => {
+ console.log(response);
+ this.formFieldsListObj = [];
+ for (let k = 0; k < response.length; k++) {
+ for (let m = 0; m < response.length; m++) {
+ if (response[m]['orderSeq'] == k + 1) {
+ this.formFieldsListObj.push(response[m]);
+ }
+ }
+ }
+ this.showSpinner = false;
+ this.showReOrderButton = false;
+ this.updateGroupOnOrderChange();
+ });
+ }
openEditDialog(groupInfo: any) {
const multiSelectArray = [];