Fairoj : Sales PD Image Section fetching issue fixed and error form field focus is implemented

This commit is contained in:
venbatechnologies@gmail.com 2020-01-08 19:01:13 +05:30
parent 6b1102fcb1
commit edd0801be9
15 changed files with 1180 additions and 958 deletions

5
.gitignore vendored
View File

@ -8,6 +8,8 @@
/node_modules /node_modules
/.sourcemaps /.sourcemaps
/platforms /platforms
/plugins
/www
# IDEs and editors # IDEs and editors
/.idea /.idea
@ -19,4 +21,5 @@
*.sublime-workspace *.sublime-workspace
# IDE - VSCode # IDE - VSCode
.vscode

View File

@ -1,5 +1,5 @@
<!-- Generated template for the QuesTemplateComponent component --> <!-- Generated template for the QuesTemplateComponent component -->
<div *ngIf="questions_JSON.questions.length > 0"> <div *ngIf="questions_JSON.questions.length > 0" #whole_form>
<form [formGroup]="quesAnsForm" > <form [formGroup]="quesAnsForm" >
<div *ngIf="quesAnsForm.controls['questions']"> <div *ngIf="quesAnsForm.controls['questions']">
<div formArrayName="questions"> <div formArrayName="questions">
@ -139,8 +139,8 @@
<span <span
*ngFor="let group_ques of parent_ques.controls.questions_group['controls'];let g_i=index;let g_l=last" *ngFor="let group_ques of parent_ques.controls.questions_group['controls'];let g_i=index;let g_l=last"
[formGroupName]="g_i"> [formGroupName]="g_i">
<mat-accordion *ngIf="parent_ques.get('group_type').value != '6'"> <mat-accordion *ngIf="parent_ques.get('group_type').value != '6'" #accordion="matAccordion">
<mat-expansion-panel [expanded]="step === g_i" > <mat-expansion-panel [expanded]="step === g_i" #mapanel="matExpansionPanel">
<mat-expansion-panel-header> <mat-expansion-panel-header>
<mat-panel-title> <mat-panel-title>
{{parent_ques.get('group_title').value}} {{g_i+1}} {{parent_ques.get('group_title').value}} {{g_i+1}}
@ -348,11 +348,11 @@
</div> </div>
</div> </div>
<ion-buttons end class="save-btn"> <ion-buttons end class="save-btn">
<ion-col *ngIf="!spinner_access"> <!-- <ion-col *ngIf="!spinner_access">
<button class="btn-no-pad" medium ion-button round outline color="optblue" (click)="onSubmit(0)">Save as Draft</button> <button class="btn-no-pad" medium ion-button round outline color="optblue" (click)="onSubmit(0)">Save as Draft</button>
</ion-col> </ion-col> -->
<ion-col *ngIf="!spinner_access"> <ion-col *ngIf="!spinner_access">
<button class="btn-no-pad" medium ion-button type="submit" round color="optblue" (click)="onSubmit(1)"><ion-icon style="color:gray;font-size: 24px;" name="md-arrow-dropright-circle"></ion-icon>&nbsp; {{submit_btn ? 'Complete' : 'Proceed'}} </button> <button class="btn-no-pad" medium ion-button type="submit" round color="optblue" (click)="onSubmit(1)"><ion-icon style="color:gray;font-size: 24px;" name="md-arrow-dropright-circle"></ion-icon>&nbsp; {{submit_btn ? 'Complete' : 'Save'}} </button>
</ion-col> </ion-col>
<ion-spinner name="dots" color="optblue" style="font-size: 24px;width:50px;height: 50px;" *ngIf="spinner_access"></ion-spinner> <ion-spinner name="dots" color="optblue" style="font-size: 24px;width:50px;height: 50px;" *ngIf="spinner_access"></ion-spinner>
</ion-buttons> </ion-buttons>

View File

@ -31,11 +31,18 @@ ques-template {
.hr, hr{ .hr, hr{
font-size: 25px; font-size: 25px;
} }
.btn-no-pad{ // .btn-no-pad{
padding: 8px 8px 8px 5px; // padding: 8px 8px 8px 5px;
} // }
.save-btn{ .save-btn{
margin-top: 3%; margin-top: 3%;
} }
// .mat-input-invalid .mat-input-placeholder {
// color: red;
// }
// .mat-input-invalid .mat-input-ripple {
// background-color: red;
// }
} }

View File

@ -1,5 +1,5 @@
import { Component, Input, EventEmitter, Output, group } from '@angular/core'; import { Component, Input, EventEmitter, Output, group, ViewChild, ElementRef } from '@angular/core';
import { FormGroup, FormArray, FormBuilder, FormControl } from '@angular/forms'; import { FormGroup, FormArray, FormBuilder, FormControl,FormControlName } from '@angular/forms';
import { QuesServiceProvider } from '../../providers/ques-service/ques-service'; import { QuesServiceProvider } from '../../providers/ques-service/ques-service';
import { SalesPdProvider } from '../../providers/sales-pd/sales-pd'; import { SalesPdProvider } from '../../providers/sales-pd/sales-pd';
import { Camera } from '@ionic-native/camera'; import { Camera } from '@ionic-native/camera';
@ -11,8 +11,16 @@ import { Subject } from 'rxjs';
import { LoadingProvider } from '../../../../providers/common-provider/loading'; import { LoadingProvider } from '../../../../providers/common-provider/loading';
import { NavController } from 'ionic-angular/navigation/nav-controller'; import { NavController } from 'ionic-angular/navigation/nav-controller';
import { Section1,Section2,Section3,Section4,Section5,Section6,Section7,Section8,Section9 } from '../../pages/home/home'; import { Section1,Section2,Section3,Section4,Section5,Section6,Section7,Section8,Section9 } from '../../pages/home/home';
import { MatAccordion, MatExpansionPanel } from '@angular/material';
// const originFormControlNameNgOnChanges = FormControlName.prototype.ngOnChanges;
// FormControlName.prototype.ngOnChanges = function () {
// const result = originFormControlNameNgOnChanges.apply(this, arguments);
// this.control.nativeElement = this.valueAccessor._elementRef.nativeElement;
// return result;
// };
/** /**
* Generated class for the QuesTemplateComponent component. * Generated class for the QuesTemplateComponent component.
* *
@ -40,6 +48,8 @@ export class QuesTemplateComponent {
original_result_data: any={is_complete:''}; original_result_data: any={is_complete:''};
spinner_access:boolean=false spinner_access:boolean=false
raw_data_Section: any={status:''}; raw_data_Section: any={status:''};
@ViewChild('accordion') Accordion: MatAccordion
@ViewChild('mapanel') matExpansionPanel:MatExpansionPanel
constructor(private _fb:FormBuilder,private questionService:QuesServiceProvider,private salesPDProvider:SalesPdProvider,private camera:Camera,private cameraProvider:CameraProvider,private constantProvider:ConstantsProvider,private toastProvider:ToastProvider,private loadingProvider:LoadingProvider,private navCtrl:NavController) { constructor(private _fb:FormBuilder,private questionService:QuesServiceProvider,private salesPDProvider:SalesPdProvider,private camera:Camera,private cameraProvider:CameraProvider,private constantProvider:ConstantsProvider,private toastProvider:ToastProvider,private loadingProvider:LoadingProvider,private navCtrl:NavController) {
console.log('Hello QuesTemplateComponent Component'); console.log('Hello QuesTemplateComponent Component');
this.text = 'Hello World'; this.text = 'Hello World';
@ -138,7 +148,7 @@ export class QuesTemplateComponent {
} }
// ---END OF ON CHANGE PROPERTIES--- // ---END OF ON CHANGE PROPERTIES---
// ----FOR SUBFIELD GENERATION---- // ----FOR SUBFIELD GENERATION IN GROUP QUES----
let control=this.quesAnsForm.get('questions')['controls'][p_i].get('questions_group')['controls'][g_i].get('questions')['controls'][s_i] as FormArray let control=this.quesAnsForm.get('questions')['controls'][p_i].get('questions_group')['controls'][g_i].get('questions')['controls'][s_i] as FormArray
if (control.value.answers != null && control.value.answers.length > 0) { if (control.value.answers != null && control.value.answers.length > 0) {
let answer_value_obj=local_value_obj.questions[p_i].questions_group[g_i].questions[s_i] let answer_value_obj=local_value_obj.questions[p_i].questions_group[g_i].questions[s_i]
@ -171,6 +181,7 @@ export class QuesTemplateComponent {
checkGroupandPatchValues(){ checkGroupandPatchValues(){
let modified=this.original_result_data let modified=this.original_result_data
modified.questions.forEach((parent_ques,p_i)=>{ modified.questions.forEach((parent_ques,p_i)=>{
// FOR ADDING THE GROUP QUES TO DISPLAY WITHOUT CONSIDERING INDEX 0
if(parent_ques.is_repeatable == '1'){ if(parent_ques.is_repeatable == '1'){
parent_ques.questions_group.forEach((group_ques,g_i)=>{ parent_ques.questions_group.forEach((group_ques,g_i)=>{
if(g_i != 0){ if(g_i != 0){
@ -182,6 +193,7 @@ export class QuesTemplateComponent {
} }
}) })
} }
// FOR CREATING A SUBFIELD FOR CHOOSED OPTION OTHERS
else { else {
let control=this.quesAnsForm.get('questions')['controls'][p_i] let control=this.quesAnsForm.get('questions')['controls'][p_i]
@ -222,23 +234,26 @@ this.proceedonChangeProperty(modified)
this.cameraProvider.addWatermarks(res).then(watermarkedImage => { this.cameraProvider.addWatermarks(res).then(watermarkedImage => {
single_ques.controls.answer_value.setValue(watermarkedImage) single_ques.controls.answer_value.setValue(watermarkedImage)
let storage_param=this.questions_JSON
//SENDING SINGLE IMAGE TO API WITH PRIMARY KEY
let params={"fk_sales_pd_id":"","img":watermarkedImage,"img_name":single_ques.value.question_key}
let storage_param=this.questions_JSON
this.salesPDProvider.saveSalesPDImage(params).subscribe(apiresult=>{
if(apiresult['dataStatus']){
storage_param.questions=this.quesAnsForm.getRawValue().questions storage_param.questions=this.quesAnsForm.getRawValue().questions
this.salesPDProvider.getData_fromLocal('sales_pd_id_PRIMARYKEY').then(key_value=>{ this.salesPDProvider.getData_fromLocal('sales_pd_id_PRIMARYKEY').then(key_value=>{
storage_param.sales_pd_id=key_value storage_param.sales_pd_id=key_value
this.salesPDProvider.insertData_Replace('sec'+storage_param.section_id,storage_param) this.salesPDProvider.insertData_Replace('sec'+storage_param.section_id,storage_param)
}) })
//SENDING SINGLE IMAGE TO API WITH PRIMARY KEY
let params={"fk_sales_pd_id":"","img":watermarkedImage,"img_name":single_ques.value.question_key}
this.salesPDProvider.saveSalesPDImage(params).subscribe(apiresult=>{
if(apiresult['dataStatus']){
console.log("image saved successfully") console.log("image saved successfully")
} }
else{ else{
this.salesPDProvider.clear_local_key('sec'+storage_param.section_id)
this.toastProvider.lenderappmessage("Something went wrong"); this.toastProvider.lenderappmessage("Something went wrong");
} }
},err=>{ },err=>{
this.salesPDProvider.clear_local_key('sec'+storage_param.section_id)
console.log("error",err); console.log("error",err);
this.toastProvider.lenderappmessage('Network Error') this.toastProvider.lenderappmessage('Network Error')
}) })
@ -300,21 +315,24 @@ this.proceedonChangeProperty(modified)
this.cameraProvider.addWatermarks(res).then(watermarkedImage=>{ this.cameraProvider.addWatermarks(res).then(watermarkedImage=>{
parent_control.controls.answer_value.setValue(watermarkedImage) parent_control.controls.answer_value.setValue(watermarkedImage)
//SENDING SINGLE IMAGE TO API WITH PRIMARY KEY
let params={"fk_sales_pd_id":"","img":watermarkedImage,"img_name":parent_control.value.question_key}
let storage_param=this.questions_JSON let storage_param=this.questions_JSON
this.salesPDProvider.saveSalesPDImage(params).subscribe(apiresult=>{
if(apiresult['dataStatus']){
storage_param.questions=this.quesAnsForm.getRawValue().questions storage_param.questions=this.quesAnsForm.getRawValue().questions
this.salesPDProvider.getData_fromLocal('sales_pd_id_PRIMARYKEY').then(key_value=>{ this.salesPDProvider.getData_fromLocal('sales_pd_id_PRIMARYKEY').then(key_value=>{
storage_param.sales_pd_id=key_value storage_param.sales_pd_id=key_value
this.salesPDProvider.insertData_Replace('sec'+storage_param.section_id,storage_param) this.salesPDProvider.insertData_Replace('sec'+storage_param.section_id,storage_param)
}) })
//SENDING SINGLE IMAGE TO API WITH PRIMARY KEY
let params={"fk_sales_pd_id":"","img":watermarkedImage,"img_name":parent_control.value.question_key}
this.salesPDProvider.saveSalesPDImage(params).subscribe(apiresult=>{
if(apiresult['dataStatus']){
} }
else{ else{
this.salesPDProvider.clear_local_key('sec'+storage_param.section_id)
this.toastProvider.lenderappmessage("Something went wrong"); this.toastProvider.lenderappmessage("Something went wrong");
} }
},err=>{ },err=>{
this.salesPDProvider.clear_local_key('sec'+storage_param.section_id)
console.log("error",err); console.log("error",err);
this.toastProvider.lenderappmessage('Network Error') this.toastProvider.lenderappmessage('Network Error')
}) })
@ -830,6 +848,27 @@ this.proceedonChangeProperty(modified)
} }
public findInvalidControls() {
const controls = this.quesAnsForm.get('questions')['controls'];
console.log(controls)
for (const name in controls) {
if (controls[name].invalid) {
let invalidFields = [].slice.call(document.getElementsByClassName('ng-invalid'));
let firstInvalidField;
for(let val in invalidFields){
if( invalidFields[val].nodeName == 'MAT-FORM-FIELD'){ //INPUT FOR INPUT FIELD
firstInvalidField=invalidFields[val]
break;
}
}
if(firstInvalidField != undefined){
firstInvalidField.scrollIntoView(true)
}
break;
}
}
// return invalid;
}
onSubmit(flag){ //1-Submit 0-Draft onSubmit(flag){ //1-Submit 0-Draft
if(flag != 0){ if(flag != 0){
if(this.quesAnsForm.invalid){ if(this.quesAnsForm.invalid){
@ -838,6 +877,11 @@ this.proceedonChangeProperty(modified)
msg="Please take the necessary pictures" msg="Please take the necessary pictures"
} }
this.toastProvider.lenderappmessage(msg) this.toastProvider.lenderappmessage(msg)
// this.Accordion.displayMode
if(this.matExpansionPanel!= undefined){
this.matExpansionPanel.open()
}
this.findInvalidControls()
return return
} }
let checkProperty=this.onSubmitProperty() let checkProperty=this.onSubmitProperty()
@ -863,7 +907,7 @@ this.proceedonChangeProperty(modified)
return; return;
} }
console.log(this.quesAnsForm.dirty) console.log(this.quesAnsForm.dirty)
if(this.quesAnsForm.dirty){ // if(this.quesAnsForm.dirty){
if(this.local_ques_JSON.section_id == 1 || this.submit_btn){ if(this.local_ques_JSON.section_id == 1 || this.submit_btn){
this.salesPDProvider.getData_fromLocal('sales_pd_id_PRIMARYKEY').then(result=>{ this.salesPDProvider.getData_fromLocal('sales_pd_id_PRIMARYKEY').then(result=>{
if(result != null && !this.submit_btn){ if(result != null && !this.submit_btn){
@ -877,22 +921,23 @@ this.proceedonChangeProperty(modified)
else{ else{
this.sendSectiontoApi(storage_param) this.sendSectiontoApi(storage_param)
} }
} // }
else if(!this.submit_btn){ // else if(!this.submit_btn){
if(flag == 1 && ((this.raw_data_Section.hasOwnProperty('status') && this.raw_data_Section.status == '0') || (this.original_result_data.hasOwnProperty('is_complete') && this.original_result_data.is_complete == 0))){ // if(flag == 1 && ((this.raw_data_Section.hasOwnProperty('status') && this.raw_data_Section.status == '0') || (this.original_result_data.hasOwnProperty('is_complete') && this.original_result_data.is_complete == 0))){
this.sendSectiontoApi(storage_param) // this.sendSectiontoApi(storage_param)
} // }
else{ // else{
this.spinner_access=false // this.spinner_access=false
this.insertSectionDataLocally(storage_param) // this.insertSectionDataLocally(storage_param)
} // }
} // }
else{ // else{
this.sendDatatoApi(storage_param) // this.sendDatatoApi(storage_param)
} // }
} }
sendSectiontoApi(params){ sendSectiontoApi(params){
this.salesPDProvider.saveSalesPDSection(params).subscribe(response=>{ this.salesPDProvider.saveSalesPDSection(params).subscribe(response=>{
if(this.local_ques_JSON.section_id != 9){
if(response.dataStatus){ if(response.dataStatus){
this.toastProvider.lenderappmessage("Saved Successfully.."); this.toastProvider.lenderappmessage("Saved Successfully..");
setTimeout(()=>{ setTimeout(()=>{
@ -903,7 +948,7 @@ this.proceedonChangeProperty(modified)
else{ else{
this.spinner_access=false this.spinner_access=false
} }
}
},err=>this.spinner_access=false) },err=>this.spinner_access=false)
} }
sendDatatoApi(section_data?){ sendDatatoApi(section_data?){
@ -1047,5 +1092,34 @@ this.proceedonChangeProperty(modified)
this.emitter.emit(section_data) this.emitter.emit(section_data)
}) })
} }
ngOnDestroy(){
console.clear()
console.log("dirty check",this.quesAnsForm.dirty)
if(this.local_ques_JSON.section_id == 9){
// FOR SENDING THE IMAGE SECTION (SECTION ID 9) JSON Structure
let form_structure=this.quesAnsForm.getRawValue().questions
form_structure.forEach(parent_ques=>{
if(parent_ques.hasOwnProperty('is_repeatable') && parent_ques.is_repeatable != '1'){
if(parent_ques.answer_value != '' && parent_ques.answer_value != null){
parent_ques.answer_value = 'SAVED'
}
}
else{
parent_ques.questions_group.forEach(group_ques=>{
group_ques.questions.forEach(single_ques=>{
if(single_ques.answer_value != '' && single_ques.answer_value != null){
single_ques.answer_value = 'SAVED'
}
})
})
}
})
let sectionApi_param=this.questions_JSON
sectionApi_param.questions=form_structure
sectionApi_param.is_complete=1
this.sendSectiontoApi(sectionApi_param)
}
}
} }

View File

@ -22,7 +22,7 @@
</ion-header> </ion-header>
<!-- add the pinchin and pinchout events --> <!-- add the pinchin and pinchout events -->
<ion-content (pinchin)="pinchin($event)" (pinchout)="pinchout($event)"> <ion-content (pinchin)="pinchin($event)" (pinchout)="pinchout($event)" (tap)="tapped($event)">
<!-- <pdf-viewer [src]="pdf" [page]="page" (after-load-complete)="afterLoadComplete($event)" [render-text]="true" [show-all]="false" [zoom]="zoom" [original-size]="false" <!-- <pdf-viewer [src]="pdf" [page]="page" (after-load-complete)="afterLoadComplete($event)" [render-text]="true" [show-all]="false" [zoom]="zoom" [original-size]="false"
style="width:100%;height:85%; overflow:scroll;display:flex;-webkit-overflow-scrolling: touch; display: -webkit-flex;"> style="width:100%;height:85%; overflow:scroll;display:flex;-webkit-overflow-scrolling: touch; display: -webkit-flex;">

View File

@ -23,6 +23,7 @@ export class ReportViewer {
pdf_sanatized: any; pdf_sanatized: any;
currentZoom: any; currentZoom: any;
isLoaded: boolean = false; isLoaded: boolean = false;
doubleTap:boolean=false
constructor(public navCtrl: NavController, public navParams: NavParams,public sanitizer: DomSanitizer,private viewCtrl:ViewController) { constructor(public navCtrl: NavController, public navParams: NavParams,public sanitizer: DomSanitizer,private viewCtrl:ViewController) {
this.pdf =navParams.get('report_link') ; this.pdf =navParams.get('report_link') ;
@ -40,6 +41,7 @@ export class ReportViewer {
if(this.zoom > 1) if(this.zoom > 1)
this.zoom -= 0.20; this.zoom -= 0.20;
} }
nextPage() { nextPage() {
@ -61,6 +63,18 @@ export class ReportViewer {
pinchout(event: any): void { pinchout(event: any): void {
this.zoom += 0.04; this.zoom += 0.04;
} }
tapped(event:any):void{
if(event.tapCount == 2){
if(!this.doubleTap){
this.zoom += 0.20;
this.doubleTap=!this.doubleTap
}
else{
this.zoom -= 0.20;
this.doubleTap=!this.doubleTap
}
}
}
afterLoadComplete(pdfData: any) { afterLoadComplete(pdfData: any) {
this.totalPages = pdfData.numPages; this.totalPages = pdfData.numPages;

View File

@ -18,34 +18,37 @@ export class QuesServiceProvider {
console.log('Hello QuesServiceProvider Provider'); console.log('Hello QuesServiceProvider Provider');
this.datepipe=new DatePipe('en-US') this.datepipe=new DatePipe('en-US')
} }
assignFormControl_array(formgroup:FormGroup,ques_data:any){ // FOR CREATING A FORM CONTROL DYNAMICALLY
console.log(formgroup,ques_data) assignFormControl_array(formgroup: FormGroup, ques_data: any) {
const control:any=formgroup.get('questions') as FormArray console.log(formgroup, ques_data)
ques_data.forEach((val,index)=>{ const control: any = formgroup.get('questions') as FormArray
console.log("quees",val) ques_data.forEach((val, index) => {
if(val.hasOwnProperty('is_repeatable') && val.is_repeatable == '1'){ console.log("quees", val)
control.push(this._fb.group({ "is_repeatable":[val.is_repeatable || null], if (val.hasOwnProperty('is_repeatable') && val.is_repeatable == '1') {
"group_title":[val.group_title || null],"group_type":[val.group_type || null]})) control.push(this._fb.group({
"is_repeatable": [val.is_repeatable || null],
"group_title": [val.group_title || null], "group_type": [val.group_type || null]
}))
// let temp=val // let temp=val
// control.push(this.createValue(temp)) // control.push(this.createValue(temp))
control.controls[index].addControl('questions_group',this._fb.array([])) control.controls[index].addControl('questions_group', this._fb.array([]))
let childControl:any=control.controls[index].get('questions_group') as FormArray let childControl: any = control.controls[index].get('questions_group') as FormArray
childControl.push(this._fb.group({'questions':this._fb.array([])})) childControl.push(this._fb.group({ 'questions': this._fb.array([]) }))
console.log("cc",childControl,control,index) console.log("cc", childControl, control, index)
let sub_childControl:any=childControl.controls[0].get('questions') as FormArray let sub_childControl: any = childControl.controls[0].get('questions') as FormArray
val.question.forEach((group_indi,arr_index)=>{ val.question.forEach((group_indi, arr_index) => {
// if(group_indi.api_properties != null && typeof(group_indi.api_properties) == 'object'){ // if(group_indi.api_properties != null && typeof(group_indi.api_properties) == 'object'){
console.log("api pro",val.api_properties) console.log("api pro", val.api_properties)
// let param // let param
// val.api_properties.forEach(val=>param=val) // val.api_properties.forEach(val=>param=val)
// console.log(param) // console.log(param)
group_indi.raw_validations=group_indi.validations group_indi.raw_validations = group_indi.validations
sub_childControl.push(this.createValue(group_indi)) sub_childControl.push(this.createValue(group_indi))
this.addAdditionalControl(group_indi,sub_childControl,arr_index) this.addAdditionalControl(group_indi, sub_childControl, arr_index)
// if(group_indi.type == '5'){ // if(group_indi.type == '5'){
// sub_childControl.controls[arr_index].removeControl('answer_value'); // sub_childControl.controls[arr_index].removeControl('answer_value');
// console.log("loop",arr_index,sub_childControl); // console.log("loop",arr_index,sub_childControl);
@ -58,94 +61,90 @@ export class QuesServiceProvider {
// sub_childControl.controls[index].addControl('select_search',new FormControl(val.field_type)) // sub_childControl.controls[index].addControl('select_search',new FormControl(val.field_type))
// } // }
if(group_indi.api_properties != null){ if (group_indi.api_properties != null) {
this.apiPropertiesCall(group_indi).then(res=>{ this.apiPropertiesCall(group_indi).then(res => {
if(res != false){ if (res != false) {
group_indi.answers=[] group_indi.answers = []
// group_indi.answers=this.convertArrayNames(val.api_properties.fields,res) // group_indi.answers=this.convertArrayNames(val.api_properties.fields,res)
sub_childControl.controls[arr_index]['controls'].answers.setValue(this.convertArrayNames(group_indi.api_properties.fields,res)) sub_childControl.controls[arr_index]['controls'].answers.setValue(this.convertArrayNames(group_indi.api_properties.fields, res))
} }
}) })
} }
// else{ // else{
// setTimeout(()=>{ // setTimeout(()=>{
// sub_childControl.push(this.createValue(group_indi)) // sub_childControl.push(this.createValue(group_indi))
// },200) // },200)
// } // }
// sub_childControl.push(this.createValue(group_indi)) // sub_childControl.push(this.createValue(group_indi))
}) })
// } // }
// else{ // else{
// sub_childControl.push(this.createValue(group_indi)) // sub_childControl.push(this.createValue(group_indi))
// } // }
// setTimeout(()=>{ // setTimeout(()=>{
// },500) // },500)
console.log("dd112",formgroup,childControl) console.log("dd112", formgroup, childControl)
// let key_list=Object.keys(val) // let key_list=Object.keys(val)
// console.log(Object.keys(val)) // console.log(Object.keys(val))
// key_list.forEach(key=>{ // key_list.forEach(key=>{
// childControl.controls // childControl.controls
// }) // })
} }
else{ else {
// console.log("con",control) // console.log("con",control)
// let key_list=Object.keys(val) // let key_list=Object.keys(val)
// console.log(Object.keys(val)) // console.log(Object.keys(val))
// let curr_object // let curr_object
// console.log("apikd",typeof(val.api_properties)) // console.log("apikd",typeof(val.api_properties))
// if(val.api_properties != null && typeof(val.api_properties) == 'object'){ // if(val.api_properties != null && typeof(val.api_properties) == 'object'){
val.raw_validations=val.validations val.raw_validations = val.validations
control.push(this.createValue(val)) control.push(this.createValue(val))
// for checkbox remove the form control and add the formarray for multiple values // for checkbox remove the form control and add the formarray for multiple values
this.addAdditionalControl(val,control,index) this.addAdditionalControl(val, control, index)
// if(val.type == '5'){ // if(val.type == '5'){
// control.controls[index].removeControl('answer_value'); // control.controls[index].removeControl('answer_value');
// console.log("loop",index,control); // console.log("loop",index,control);
// control.controls[index].addControl('answer_value',this._fb.array([])) // control.controls[index].addControl('answer_value',this._fb.array([]))
// } // }
// if(val.type == '1'){ // if(val.type == '1'){
// control.controls[index].addControl('field_type',new FormControl(val.field_type)) // control.controls[index].addControl('field_type',new FormControl(val.field_type))
// } // }
// if(val.type == '8'){ // if(val.type == '8'){
// control.controls[index].addControl('select_search',new FormControl(val.field_type)) // control.controls[index].addControl('select_search',new FormControl(val.field_type))
// } // }
if(val.api_properties!= null){ if (val.api_properties != null) {
this.apiPropertiesCall(val).then(res=>{ this.apiPropertiesCall(val).then(res => {
console.log("chekc",res) console.log("chekc", res)
if(res != false){ if (res != false) {
// val.answers=[] // val.answers=[]
// val.answers=this.convertArrayNames(val.api_properties.fields,res) // val.answers=this.convertArrayNames(val.api_properties.fields,res)
control.controls[index]['controls'].answers.setValue(this.convertArrayNames(val.api_properties.fields,res)) control.controls[index]['controls'].answers.setValue(this.convertArrayNames(val.api_properties.fields, res))
}
}, err => console.log(err))
} }
},err=>console.log(err)) // else{
} // setTimeout(()=>{
// else{ // control.push(this.createValue(val))
// setTimeout(()=>{ // },200)
// control.push(this.createValue(val)) // }
// },200)
// } // }
// else{
// } // control.push(this.createValue(val))
// else{ // }
// control.push(this.createValue(val))
// }
console.log(formgroup) console.log(formgroup)
} }
},err=>console.log(err)) }, err => console.log(err))
return formgroup return formgroup
} }
// END OF FORM CREATION
// FOR CREATING THE FORM CONTROL FOR SPECIFIC FORM ARRAY
createValue(data){ createValue(data){
let is_amt_in_words=false let is_amt_in_words=false
let answer_value_loc=''; let answer_value_loc='';
@ -178,6 +177,9 @@ export class QuesServiceProvider {
"group_title":[data.group_title || null] "group_title":[data.group_title || null]
}) })
} }
// END OF CREATEVALUE FUN
// FOR REQUESTING THE API AUTOMATICALLY FROM JSON
apiPropertiesCall(val){ apiPropertiesCall(val){
return new Promise((resolve,reject)=>{ return new Promise((resolve,reject)=>{
if(val.api_properties != null && typeof(val.api_properties) == 'object'){ if(val.api_properties != null && typeof(val.api_properties) == 'object'){
@ -200,6 +202,9 @@ export class QuesServiceProvider {
} }
}) })
} }
// END OF API PROPERTIES CALL
// ---FOR CONVERTING THE ANSWER KEYS UNIQUE
convertArrayNames(fieldName,data_from_api){ convertArrayNames(fieldName,data_from_api){
let val1=[] let val1=[]
let modified_json = data_from_api.map( let modified_json = data_from_api.map(
@ -211,39 +216,41 @@ export class QuesServiceProvider {
} }
}); });
return modified_json return modified_json
} }
// END OF CONVERTARRAYNAMES FUN--
getAnswerValue(value_obj){ // --- FOR SETTING THE VALUE DEFAULT WITH DISABLED AND GENERATE THE ANSWERS FOR FIELDS(EX. refer 'GET_FY_YEARS' switch)
if(value_obj != null && value_obj.hasOwnProperty('answer_value')){ getAnswerValue(value_obj) {
let return_value={flag:1,values:''}; if (value_obj != null && value_obj.hasOwnProperty('answer_value')) {
let user_det:any=localStorage.getItem("user_details") let return_value = { flag: 1, values: '' };
user_det=JSON.parse(user_det); let user_det: any = localStorage.getItem("user_details")
switch(value_obj.answer_value){ user_det = JSON.parse(user_det);
case 'CURRENT_USER': switch (value_obj.answer_value) {
console.log("current user",user_det) case 'CURRENT_USER':
return_value.values=user_det.user_first_name+' '+user_det.user_last_name console.log("current user", user_det)
break; return_value.values = user_det.user_first_name + ' ' + user_det.user_last_name
case "CURRENT_DESIGNATION": break;
console.log("current user",user_det) case "CURRENT_DESIGNATION":
return_value=user_det.role_name return_value.values = user_det.designation_name != null ? user_det.designation_name : ''
break; break;
case "CURRENT_DATE": case "CURRENT_DATE":
let date=new Date() let date = new Date()
return_value.values=this.datepipe.transform(date,'dd-MM-yyyy, h:mm:ss a') return_value.values = this.datepipe.transform(date, 'dd-MM-yyyy, h:mm:ss a')
break; break;
case "GET_FY_YEARS": case "GET_FY_YEARS":
return_value.values=this.getCurrentFyYears() return_value.values = this.getCurrentFyYears()
return_value.flag=2 return_value.flag = 2
break; break;
default: default:
return_value.values='' return_value.values = ''
break break
}
return return_value
} }
return '' return return_value
} }
return ''
}
// --END OF GETANSWERVALUE FUN
addAdditionalControl(data,curr_control,curr_index,purpose?){ addAdditionalControl(data,curr_control,curr_index,purpose?){
//FOR CHECKBOX CHANGE THE VALUE STORAGE AS ARRAY //FOR CHECKBOX CHANGE THE VALUE STORAGE AS ARRAY
@ -269,6 +276,8 @@ export class QuesServiceProvider {
//FOR SETTING THE VALIDATORS //FOR SETTING THE VALIDATORS
this.settingArrayofValidators(data,curr_control.controls[curr_index],curr_index) this.settingArrayofValidators(data,curr_control.controls[curr_index],curr_index)
} }
// FOR SETTING THE ARRAY OF VALIDATORS COMING FROM JSON Temp,
settingArrayofValidators(data,curr_control,curr_index){ settingArrayofValidators(data,curr_control,curr_index){
console.log("entered",data); console.log("entered",data);
if(data.hasOwnProperty('validations') && data.validations.length > 0 ){ if(data.hasOwnProperty('validations') && data.validations.length > 0 ){
@ -302,6 +311,9 @@ export class QuesServiceProvider {
console.log("after setting validators",curr_control) console.log("after setting validators",curr_control)
} }
} }
// END OF SETTINGARRAYOFVALIDATORS FUN
// FOR GETTING THE VALIDATION VALUE
getvalidatorValue(value_obj){ getvalidatorValue(value_obj){
if(value_obj != null && value_obj.hasOwnProperty('value')){ if(value_obj != null && value_obj.hasOwnProperty('value')){
let value_of_validator let value_of_validator
@ -317,6 +329,9 @@ export class QuesServiceProvider {
return this.setValueForValidator(value_obj) return this.setValueForValidator(value_obj)
} }
} }
// END OF GETVALIDATORVALUE FUN
// FOR GENERATING THE FY YEAR FIELD ANSWERS
getCurrentFyYears(){ getCurrentFyYears(){
let month=new Date().getMonth() let month=new Date().getMonth()
let year=new Date().getFullYear() let year=new Date().getFullYear()
@ -333,6 +348,9 @@ export class QuesServiceProvider {
} }
return fy.map(val=>({answer:val.fy_year,answer_id:val.fy_year})) return fy.map(val=>({answer:val.fy_year,answer_id:val.fy_year}))
} }
// END OF GETCURRFYYEARS FUN
// FOR CREATING THE CORRECT VALIDATION
setValueForValidator(value_obj){ setValueForValidator(value_obj){
console.log("setvlaue of validator",value_obj.validator,typeof(value_obj.validator)) console.log("setvlaue of validator",value_obj.validator,typeof(value_obj.validator))
let return_value let return_value
@ -367,5 +385,6 @@ export class QuesServiceProvider {
return false return false
} }
} }
// END OF SETVALUEFORVALIDATOR FUN
} }

View File

@ -157,5 +157,7 @@ current_section:any;
getSalesPDSectionData(params){ getSalesPDSectionData(params){
return this.http.post(this.apiUrl+'getSalesPDSectionData',{records:params}) return this.http.post(this.apiUrl+'getSalesPDSectionData',{records:params})
} }
clear_local_key(key){
return this.storage.remove(key)
}
} }

View File

@ -47060,7 +47060,7 @@ exports.MessageHandler = MessageHandler;
/******/ ]); /******/ ]);
}); });
//# sourceMappingURL=pdf.worker.js.map //# sourceMappingURL=pdf.worker.js.map
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(107).Buffer, __webpack_require__(86), __webpack_require__(376))) /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(107).Buffer, __webpack_require__(87), __webpack_require__(376)))
/***/ }) /***/ })

View File

@ -28686,10 +28686,6 @@ ques-template .hr, ques-template hr {
font-size: 25px; font-size: 25px;
} }
ques-template .btn-no-pad {
padding: 8px 8px 8px 5px;
}
ques-template .save-btn { ques-template .save-btn {
margin-top: 3%; margin-top: 3%;
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,9 +1,6 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en" dir="ltr"> <html lang="en" dir="ltr">
<head> <head>
<script data-ionic="inject">
(function(w){var i=w.Ionic=w.Ionic||{};i.version='3.9.2';i.angular='5.0.3';i.staticDir='build/';})(window);
</script>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Ionic App</title> <title>Ionic App</title>
<meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> <meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">