Fairoj : Sales PD Image Section fetching issue fixed and error form field focus is implemented
This commit is contained in:
parent
6b1102fcb1
commit
edd0801be9
5
.gitignore
vendored
5
.gitignore
vendored
@ -8,6 +8,8 @@
|
||||
/node_modules
|
||||
/.sourcemaps
|
||||
/platforms
|
||||
/plugins
|
||||
/www
|
||||
|
||||
# IDEs and editors
|
||||
/.idea
|
||||
@ -19,4 +21,5 @@
|
||||
*.sublime-workspace
|
||||
|
||||
|
||||
# IDE - VSCode
|
||||
# IDE - VSCode
|
||||
.vscode
|
||||
@ -1,5 +1,5 @@
|
||||
<!-- 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" >
|
||||
<div *ngIf="quesAnsForm.controls['questions']">
|
||||
<div formArrayName="questions">
|
||||
@ -139,8 +139,8 @@
|
||||
<span
|
||||
*ngFor="let group_ques of parent_ques.controls.questions_group['controls'];let g_i=index;let g_l=last"
|
||||
[formGroupName]="g_i">
|
||||
<mat-accordion *ngIf="parent_ques.get('group_type').value != '6'">
|
||||
<mat-expansion-panel [expanded]="step === g_i" >
|
||||
<mat-accordion *ngIf="parent_ques.get('group_type').value != '6'" #accordion="matAccordion">
|
||||
<mat-expansion-panel [expanded]="step === g_i" #mapanel="matExpansionPanel">
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>
|
||||
{{parent_ques.get('group_title').value}} {{g_i+1}}
|
||||
@ -348,11 +348,11 @@
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
</ion-col>
|
||||
</ion-col> -->
|
||||
<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> {{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> {{submit_btn ? 'Complete' : 'Save'}} </button>
|
||||
</ion-col>
|
||||
<ion-spinner name="dots" color="optblue" style="font-size: 24px;width:50px;height: 50px;" *ngIf="spinner_access"></ion-spinner>
|
||||
</ion-buttons>
|
||||
|
||||
@ -31,11 +31,18 @@ ques-template {
|
||||
.hr, hr{
|
||||
font-size: 25px;
|
||||
}
|
||||
.btn-no-pad{
|
||||
padding: 8px 8px 8px 5px;
|
||||
// .btn-no-pad{
|
||||
// padding: 8px 8px 8px 5px;
|
||||
|
||||
}
|
||||
// }
|
||||
.save-btn{
|
||||
margin-top: 3%;
|
||||
}
|
||||
// .mat-input-invalid .mat-input-placeholder {
|
||||
// color: red;
|
||||
// }
|
||||
|
||||
// .mat-input-invalid .mat-input-ripple {
|
||||
// background-color: red;
|
||||
// }
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { Component, Input, EventEmitter, Output, group } from '@angular/core';
|
||||
import { FormGroup, FormArray, FormBuilder, FormControl } from '@angular/forms';
|
||||
import { Component, Input, EventEmitter, Output, group, ViewChild, ElementRef } from '@angular/core';
|
||||
import { FormGroup, FormArray, FormBuilder, FormControl,FormControlName } from '@angular/forms';
|
||||
import { QuesServiceProvider } from '../../providers/ques-service/ques-service';
|
||||
import { SalesPdProvider } from '../../providers/sales-pd/sales-pd';
|
||||
import { Camera } from '@ionic-native/camera';
|
||||
@ -11,8 +11,16 @@ import { Subject } from 'rxjs';
|
||||
import { LoadingProvider } from '../../../../providers/common-provider/loading';
|
||||
import { NavController } from 'ionic-angular/navigation/nav-controller';
|
||||
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.
|
||||
*
|
||||
@ -40,6 +48,8 @@ export class QuesTemplateComponent {
|
||||
original_result_data: any={is_complete:''};
|
||||
spinner_access:boolean=false
|
||||
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) {
|
||||
console.log('Hello QuesTemplateComponent Component');
|
||||
this.text = 'Hello World';
|
||||
@ -138,7 +148,7 @@ export class QuesTemplateComponent {
|
||||
}
|
||||
// ---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
|
||||
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]
|
||||
@ -171,6 +181,7 @@ export class QuesTemplateComponent {
|
||||
checkGroupandPatchValues(){
|
||||
let modified=this.original_result_data
|
||||
modified.questions.forEach((parent_ques,p_i)=>{
|
||||
// FOR ADDING THE GROUP QUES TO DISPLAY WITHOUT CONSIDERING INDEX 0
|
||||
if(parent_ques.is_repeatable == '1'){
|
||||
parent_ques.questions_group.forEach((group_ques,g_i)=>{
|
||||
if(g_i != 0){
|
||||
@ -182,6 +193,7 @@ export class QuesTemplateComponent {
|
||||
}
|
||||
})
|
||||
}
|
||||
// FOR CREATING A SUBFIELD FOR CHOOSED OPTION OTHERS
|
||||
else {
|
||||
let control=this.quesAnsForm.get('questions')['controls'][p_i]
|
||||
|
||||
@ -222,23 +234,26 @@ this.proceedonChangeProperty(modified)
|
||||
this.cameraProvider.addWatermarks(res).then(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
|
||||
this.salesPDProvider.getData_fromLocal('sales_pd_id_PRIMARYKEY').then(key_value=>{
|
||||
storage_param.sales_pd_id=key_value
|
||||
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")
|
||||
}
|
||||
else{
|
||||
this.salesPDProvider.clear_local_key('sec'+storage_param.section_id)
|
||||
this.toastProvider.lenderappmessage("Something went wrong");
|
||||
}
|
||||
},err=>{
|
||||
this.salesPDProvider.clear_local_key('sec'+storage_param.section_id)
|
||||
console.log("error",err);
|
||||
this.toastProvider.lenderappmessage('Network Error')
|
||||
})
|
||||
@ -300,21 +315,24 @@ this.proceedonChangeProperty(modified)
|
||||
this.cameraProvider.addWatermarks(res).then(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
|
||||
this.salesPDProvider.saveSalesPDImage(params).subscribe(apiresult=>{
|
||||
if(apiresult['dataStatus']){
|
||||
storage_param.questions=this.quesAnsForm.getRawValue().questions
|
||||
this.salesPDProvider.getData_fromLocal('sales_pd_id_PRIMARYKEY').then(key_value=>{
|
||||
storage_param.sales_pd_id=key_value
|
||||
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{
|
||||
this.salesPDProvider.clear_local_key('sec'+storage_param.section_id)
|
||||
this.toastProvider.lenderappmessage("Something went wrong");
|
||||
}
|
||||
},err=>{
|
||||
this.salesPDProvider.clear_local_key('sec'+storage_param.section_id)
|
||||
console.log("error",err);
|
||||
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
|
||||
if(flag != 0){
|
||||
if(this.quesAnsForm.invalid){
|
||||
@ -838,6 +877,11 @@ this.proceedonChangeProperty(modified)
|
||||
msg="Please take the necessary pictures"
|
||||
}
|
||||
this.toastProvider.lenderappmessage(msg)
|
||||
// this.Accordion.displayMode
|
||||
if(this.matExpansionPanel!= undefined){
|
||||
this.matExpansionPanel.open()
|
||||
}
|
||||
this.findInvalidControls()
|
||||
return
|
||||
}
|
||||
let checkProperty=this.onSubmitProperty()
|
||||
@ -863,7 +907,7 @@ this.proceedonChangeProperty(modified)
|
||||
return;
|
||||
}
|
||||
console.log(this.quesAnsForm.dirty)
|
||||
if(this.quesAnsForm.dirty){
|
||||
// if(this.quesAnsForm.dirty){
|
||||
if(this.local_ques_JSON.section_id == 1 || this.submit_btn){
|
||||
this.salesPDProvider.getData_fromLocal('sales_pd_id_PRIMARYKEY').then(result=>{
|
||||
if(result != null && !this.submit_btn){
|
||||
@ -877,22 +921,23 @@ this.proceedonChangeProperty(modified)
|
||||
else{
|
||||
this.sendSectiontoApi(storage_param)
|
||||
}
|
||||
}
|
||||
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))){
|
||||
this.sendSectiontoApi(storage_param)
|
||||
}
|
||||
else{
|
||||
this.spinner_access=false
|
||||
this.insertSectionDataLocally(storage_param)
|
||||
}
|
||||
}
|
||||
else{
|
||||
this.sendDatatoApi(storage_param)
|
||||
}
|
||||
// }
|
||||
// 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))){
|
||||
// this.sendSectiontoApi(storage_param)
|
||||
// }
|
||||
// else{
|
||||
// this.spinner_access=false
|
||||
// this.insertSectionDataLocally(storage_param)
|
||||
// }
|
||||
// }
|
||||
// else{
|
||||
// this.sendDatatoApi(storage_param)
|
||||
// }
|
||||
}
|
||||
sendSectiontoApi(params){
|
||||
this.salesPDProvider.saveSalesPDSection(params).subscribe(response=>{
|
||||
if(this.local_ques_JSON.section_id != 9){
|
||||
if(response.dataStatus){
|
||||
this.toastProvider.lenderappmessage("Saved Successfully..");
|
||||
setTimeout(()=>{
|
||||
@ -903,7 +948,7 @@ this.proceedonChangeProperty(modified)
|
||||
else{
|
||||
this.spinner_access=false
|
||||
}
|
||||
|
||||
}
|
||||
},err=>this.spinner_access=false)
|
||||
}
|
||||
sendDatatoApi(section_data?){
|
||||
@ -1047,5 +1092,34 @@ this.proceedonChangeProperty(modified)
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
</ion-header>
|
||||
|
||||
<!-- 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"
|
||||
style="width:100%;height:85%; overflow:scroll;display:flex;-webkit-overflow-scrolling: touch; display: -webkit-flex;">
|
||||
|
||||
@ -23,6 +23,7 @@ export class ReportViewer {
|
||||
pdf_sanatized: any;
|
||||
currentZoom: any;
|
||||
isLoaded: boolean = false;
|
||||
doubleTap:boolean=false
|
||||
|
||||
constructor(public navCtrl: NavController, public navParams: NavParams,public sanitizer: DomSanitizer,private viewCtrl:ViewController) {
|
||||
this.pdf =navParams.get('report_link') ;
|
||||
@ -40,6 +41,7 @@ export class ReportViewer {
|
||||
if(this.zoom > 1)
|
||||
this.zoom -= 0.20;
|
||||
}
|
||||
|
||||
|
||||
|
||||
nextPage() {
|
||||
@ -61,6 +63,18 @@ export class ReportViewer {
|
||||
pinchout(event: any): void {
|
||||
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) {
|
||||
this.totalPages = pdfData.numPages;
|
||||
|
||||
@ -18,34 +18,37 @@ export class QuesServiceProvider {
|
||||
console.log('Hello QuesServiceProvider Provider');
|
||||
this.datepipe=new DatePipe('en-US')
|
||||
}
|
||||
assignFormControl_array(formgroup:FormGroup,ques_data:any){
|
||||
console.log(formgroup,ques_data)
|
||||
const control:any=formgroup.get('questions') as FormArray
|
||||
ques_data.forEach((val,index)=>{
|
||||
console.log("quees",val)
|
||||
if(val.hasOwnProperty('is_repeatable') && val.is_repeatable == '1'){
|
||||
control.push(this._fb.group({ "is_repeatable":[val.is_repeatable || null],
|
||||
"group_title":[val.group_title || null],"group_type":[val.group_type || null]}))
|
||||
// FOR CREATING A FORM CONTROL DYNAMICALLY
|
||||
assignFormControl_array(formgroup: FormGroup, ques_data: any) {
|
||||
console.log(formgroup, ques_data)
|
||||
const control: any = formgroup.get('questions') as FormArray
|
||||
ques_data.forEach((val, index) => {
|
||||
console.log("quees", val)
|
||||
if (val.hasOwnProperty('is_repeatable') && val.is_repeatable == '1') {
|
||||
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
|
||||
|
||||
|
||||
// control.push(this.createValue(temp))
|
||||
|
||||
control.controls[index].addControl('questions_group',this._fb.array([]))
|
||||
|
||||
let childControl:any=control.controls[index].get('questions_group') as FormArray
|
||||
|
||||
childControl.push(this._fb.group({'questions':this._fb.array([])}))
|
||||
console.log("cc",childControl,control,index)
|
||||
let sub_childControl:any=childControl.controls[0].get('questions') as FormArray
|
||||
val.question.forEach((group_indi,arr_index)=>{
|
||||
// if(group_indi.api_properties != null && typeof(group_indi.api_properties) == 'object'){
|
||||
console.log("api pro",val.api_properties)
|
||||
control.controls[index].addControl('questions_group', this._fb.array([]))
|
||||
|
||||
let childControl: any = control.controls[index].get('questions_group') as FormArray
|
||||
|
||||
childControl.push(this._fb.group({ 'questions': this._fb.array([]) }))
|
||||
console.log("cc", childControl, control, index)
|
||||
let sub_childControl: any = childControl.controls[0].get('questions') as FormArray
|
||||
val.question.forEach((group_indi, arr_index) => {
|
||||
// if(group_indi.api_properties != null && typeof(group_indi.api_properties) == 'object'){
|
||||
console.log("api pro", val.api_properties)
|
||||
// let param
|
||||
// val.api_properties.forEach(val=>param=val)
|
||||
// console.log(param)
|
||||
group_indi.raw_validations=group_indi.validations
|
||||
group_indi.raw_validations = group_indi.validations
|
||||
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'){
|
||||
// sub_childControl.controls[arr_index].removeControl('answer_value');
|
||||
// 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))
|
||||
// }
|
||||
|
||||
if(group_indi.api_properties != null){
|
||||
this.apiPropertiesCall(group_indi).then(res=>{
|
||||
if(res != false){
|
||||
group_indi.answers=[]
|
||||
// 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))
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
if (group_indi.api_properties != null) {
|
||||
this.apiPropertiesCall(group_indi).then(res => {
|
||||
if (res != false) {
|
||||
group_indi.answers = []
|
||||
// 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))
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
// else{
|
||||
// setTimeout(()=>{
|
||||
// sub_childControl.push(this.createValue(group_indi))
|
||||
// },200)
|
||||
// }
|
||||
// sub_childControl.push(this.createValue(group_indi))
|
||||
})
|
||||
// sub_childControl.push(this.createValue(group_indi))
|
||||
})
|
||||
// }
|
||||
// else{
|
||||
// sub_childControl.push(this.createValue(group_indi))
|
||||
// }
|
||||
// setTimeout(()=>{
|
||||
|
||||
// },500)
|
||||
|
||||
console.log("dd112",formgroup,childControl)
|
||||
// let key_list=Object.keys(val)
|
||||
// console.log(Object.keys(val))
|
||||
// key_list.forEach(key=>{
|
||||
// childControl.controls
|
||||
// })
|
||||
|
||||
// },500)
|
||||
|
||||
console.log("dd112", formgroup, childControl)
|
||||
// let key_list=Object.keys(val)
|
||||
// console.log(Object.keys(val))
|
||||
// key_list.forEach(key=>{
|
||||
// childControl.controls
|
||||
// })
|
||||
}
|
||||
else{
|
||||
else {
|
||||
// console.log("con",control)
|
||||
// let key_list=Object.keys(val)
|
||||
// console.log(Object.keys(val))
|
||||
// let curr_object
|
||||
// console.log("apikd",typeof(val.api_properties))
|
||||
// if(val.api_properties != null && typeof(val.api_properties) == 'object'){
|
||||
val.raw_validations=val.validations
|
||||
control.push(this.createValue(val))
|
||||
// for checkbox remove the form control and add the formarray for multiple values
|
||||
this.addAdditionalControl(val,control,index)
|
||||
// if(val.type == '5'){
|
||||
// control.controls[index].removeControl('answer_value');
|
||||
// console.log("loop",index,control);
|
||||
// control.controls[index].addControl('answer_value',this._fb.array([]))
|
||||
// }
|
||||
// if(val.type == '1'){
|
||||
// control.controls[index].addControl('field_type',new FormControl(val.field_type))
|
||||
// }
|
||||
// if(val.type == '8'){
|
||||
// control.controls[index].addControl('select_search',new FormControl(val.field_type))
|
||||
// }
|
||||
if(val.api_properties!= null){
|
||||
this.apiPropertiesCall(val).then(res=>{
|
||||
console.log("chekc",res)
|
||||
if(res != false){
|
||||
// val.answers=[]
|
||||
// val.answers=this.convertArrayNames(val.api_properties.fields,res)
|
||||
control.controls[index]['controls'].answers.setValue(this.convertArrayNames(val.api_properties.fields,res))
|
||||
|
||||
val.raw_validations = val.validations
|
||||
control.push(this.createValue(val))
|
||||
// for checkbox remove the form control and add the formarray for multiple values
|
||||
this.addAdditionalControl(val, control, index)
|
||||
// if(val.type == '5'){
|
||||
// control.controls[index].removeControl('answer_value');
|
||||
// console.log("loop",index,control);
|
||||
// control.controls[index].addControl('answer_value',this._fb.array([]))
|
||||
// }
|
||||
// if(val.type == '1'){
|
||||
// control.controls[index].addControl('field_type',new FormControl(val.field_type))
|
||||
// }
|
||||
// if(val.type == '8'){
|
||||
// control.controls[index].addControl('select_search',new FormControl(val.field_type))
|
||||
// }
|
||||
if (val.api_properties != null) {
|
||||
this.apiPropertiesCall(val).then(res => {
|
||||
console.log("chekc", res)
|
||||
if (res != false) {
|
||||
// val.answers=[]
|
||||
// val.answers=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(()=>{
|
||||
// control.push(this.createValue(val))
|
||||
// },200)
|
||||
// }
|
||||
|
||||
// }
|
||||
// else{
|
||||
// control.push(this.createValue(val))
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// else{
|
||||
// setTimeout(()=>{
|
||||
// control.push(this.createValue(val))
|
||||
// },200)
|
||||
// }
|
||||
|
||||
// }
|
||||
// else{
|
||||
// control.push(this.createValue(val))
|
||||
// }
|
||||
console.log(formgroup)
|
||||
|
||||
|
||||
}
|
||||
},err=>console.log(err))
|
||||
}, err => console.log(err))
|
||||
return formgroup
|
||||
}
|
||||
// END OF FORM CREATION
|
||||
|
||||
// FOR CREATING THE FORM CONTROL FOR SPECIFIC FORM ARRAY
|
||||
createValue(data){
|
||||
let is_amt_in_words=false
|
||||
let answer_value_loc='';
|
||||
@ -178,6 +177,9 @@ export class QuesServiceProvider {
|
||||
"group_title":[data.group_title || null]
|
||||
})
|
||||
}
|
||||
// END OF CREATEVALUE FUN
|
||||
|
||||
// FOR REQUESTING THE API AUTOMATICALLY FROM JSON
|
||||
apiPropertiesCall(val){
|
||||
return new Promise((resolve,reject)=>{
|
||||
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){
|
||||
let val1=[]
|
||||
let modified_json = data_from_api.map(
|
||||
@ -211,39 +216,41 @@ export class QuesServiceProvider {
|
||||
}
|
||||
});
|
||||
return modified_json
|
||||
|
||||
}
|
||||
// END OF CONVERTARRAYNAMES FUN--
|
||||
|
||||
getAnswerValue(value_obj){
|
||||
if(value_obj != null && value_obj.hasOwnProperty('answer_value')){
|
||||
let return_value={flag:1,values:''};
|
||||
let user_det:any=localStorage.getItem("user_details")
|
||||
user_det=JSON.parse(user_det);
|
||||
switch(value_obj.answer_value){
|
||||
case 'CURRENT_USER':
|
||||
console.log("current user",user_det)
|
||||
return_value.values=user_det.user_first_name+' '+user_det.user_last_name
|
||||
break;
|
||||
case "CURRENT_DESIGNATION":
|
||||
console.log("current user",user_det)
|
||||
return_value=user_det.role_name
|
||||
break;
|
||||
case "CURRENT_DATE":
|
||||
let date=new Date()
|
||||
return_value.values=this.datepipe.transform(date,'dd-MM-yyyy, h:mm:ss a')
|
||||
break;
|
||||
case "GET_FY_YEARS":
|
||||
return_value.values=this.getCurrentFyYears()
|
||||
return_value.flag=2
|
||||
break;
|
||||
default:
|
||||
return_value.values=''
|
||||
break
|
||||
}
|
||||
return return_value
|
||||
// --- FOR SETTING THE VALUE DEFAULT WITH DISABLED AND GENERATE THE ANSWERS FOR FIELDS(EX. refer 'GET_FY_YEARS' switch)
|
||||
getAnswerValue(value_obj) {
|
||||
if (value_obj != null && value_obj.hasOwnProperty('answer_value')) {
|
||||
let return_value = { flag: 1, values: '' };
|
||||
let user_det: any = localStorage.getItem("user_details")
|
||||
user_det = JSON.parse(user_det);
|
||||
switch (value_obj.answer_value) {
|
||||
case 'CURRENT_USER':
|
||||
console.log("current user", user_det)
|
||||
return_value.values = user_det.user_first_name + ' ' + user_det.user_last_name
|
||||
break;
|
||||
case "CURRENT_DESIGNATION":
|
||||
return_value.values = user_det.designation_name != null ? user_det.designation_name : ''
|
||||
break;
|
||||
case "CURRENT_DATE":
|
||||
let date = new Date()
|
||||
return_value.values = this.datepipe.transform(date, 'dd-MM-yyyy, h:mm:ss a')
|
||||
break;
|
||||
case "GET_FY_YEARS":
|
||||
return_value.values = this.getCurrentFyYears()
|
||||
return_value.flag = 2
|
||||
break;
|
||||
default:
|
||||
return_value.values = ''
|
||||
break
|
||||
}
|
||||
return ''
|
||||
return return_value
|
||||
}
|
||||
return ''
|
||||
}
|
||||
// --END OF GETANSWERVALUE FUN
|
||||
|
||||
addAdditionalControl(data,curr_control,curr_index,purpose?){
|
||||
|
||||
//FOR CHECKBOX CHANGE THE VALUE STORAGE AS ARRAY
|
||||
@ -269,6 +276,8 @@ export class QuesServiceProvider {
|
||||
//FOR SETTING THE VALIDATORS
|
||||
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){
|
||||
console.log("entered",data);
|
||||
if(data.hasOwnProperty('validations') && data.validations.length > 0 ){
|
||||
@ -302,6 +311,9 @@ export class QuesServiceProvider {
|
||||
console.log("after setting validators",curr_control)
|
||||
}
|
||||
}
|
||||
// END OF SETTINGARRAYOFVALIDATORS FUN
|
||||
|
||||
// FOR GETTING THE VALIDATION VALUE
|
||||
getvalidatorValue(value_obj){
|
||||
if(value_obj != null && value_obj.hasOwnProperty('value')){
|
||||
let value_of_validator
|
||||
@ -317,6 +329,9 @@ export class QuesServiceProvider {
|
||||
return this.setValueForValidator(value_obj)
|
||||
}
|
||||
}
|
||||
// END OF GETVALIDATORVALUE FUN
|
||||
|
||||
// FOR GENERATING THE FY YEAR FIELD ANSWERS
|
||||
getCurrentFyYears(){
|
||||
let month=new Date().getMonth()
|
||||
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}))
|
||||
}
|
||||
// END OF GETCURRFYYEARS FUN
|
||||
|
||||
// FOR CREATING THE CORRECT VALIDATION
|
||||
setValueForValidator(value_obj){
|
||||
console.log("setvlaue of validator",value_obj.validator,typeof(value_obj.validator))
|
||||
let return_value
|
||||
@ -367,5 +385,6 @@ export class QuesServiceProvider {
|
||||
return false
|
||||
}
|
||||
}
|
||||
// END OF SETVALUEFORVALIDATOR FUN
|
||||
|
||||
}
|
||||
|
||||
@ -157,5 +157,7 @@ current_section:any;
|
||||
getSalesPDSectionData(params){
|
||||
return this.http.post(this.apiUrl+'getSalesPDSectionData',{records:params})
|
||||
}
|
||||
|
||||
clear_local_key(key){
|
||||
return this.storage.remove(key)
|
||||
}
|
||||
}
|
||||
|
||||
@ -47060,7 +47060,7 @@ exports.MessageHandler = MessageHandler;
|
||||
/******/ ]);
|
||||
});
|
||||
//# 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)))
|
||||
|
||||
/***/ })
|
||||
|
||||
|
||||
@ -28686,10 +28686,6 @@ ques-template .hr, ques-template hr {
|
||||
font-size: 25px;
|
||||
}
|
||||
|
||||
ques-template .btn-no-pad {
|
||||
padding: 8px 8px 8px 5px;
|
||||
}
|
||||
|
||||
ques-template .save-btn {
|
||||
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
1244
www/build/vendor.js
1244
www/build/vendor.js
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -1,9 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" dir="ltr">
|
||||
<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">
|
||||
<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">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user