iptdevs-design-system 3.1.879 → 3.1.882

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3695,33 +3695,90 @@ class CodFormStepOneComponent extends CodFormSteps {
3695
3695
  this.codFormStepOne.controls['course_type'].valueChanges
3696
3696
  .subscribe(value => this.communicatorService.setCurrentCourseType(value));
3697
3697
  this.communicatorService.setCurrentAgreement(this.localStorageCOD.getCodFormData(1, 'agreement_by_category'));
3698
- if (changes['initialData'] && this.initialData != null && this.dataPreviusCodData === null || this.dataPreviusCodData != null && this.isEditCod === false && this.isRenovation === false) {
3698
+ console.log('Changes detected:', changes);
3699
+ console.log("this.initialData", this.initialData);
3700
+ console.log("this.dataPreviusCodData", this.dataPreviusCodData);
3701
+ console.log("this.isEditCod", this.isEditCod);
3702
+ console.log("this.isRenovation", this.isRenovation);
3703
+ // Lógica principal de cambios
3704
+ if (changes['initialData'] || changes['dataPreviusCodData']) {
3705
+ this.handleDataChanges(changes);
3706
+ }
3707
+ this.cdRef.detectChanges();
3708
+ // const shouldProcessInitialData = changes['initialData'] &&
3709
+ // this.initialData != null &&
3710
+ // this.dataPreviusCodData === null;
3711
+ // const shouldProcessPreviusData = this.dataPreviusCodData != null &&
3712
+ // this.isEditCod === false &&
3713
+ // this.isRenovation === false;
3714
+ // if (shouldProcessInitialData || shouldProcessPreviusData) {
3715
+ // this.processData(this.initialData);
3716
+ // this.cdRef.detectChanges();
3717
+ // console.log("Entro en this.processData con initialData");
3718
+ // } else {
3719
+ // // Manejo más controlado del "else"
3720
+ // console.log("entre en el else que borra todo en null");
3721
+ // this.codFormStepOne.controls['academic_plan'].setValue(null);
3722
+ // this.codFormStepOne.controls['course_type'].setValue(null);
3723
+ // this.codFormStepOne.controls['agreement_by_category'].setValue(null);
3724
+ // this.codFormStepOne.controls['english_level'].setValue(null);
3725
+ // this.codFormStepOne.controls['availible_courses'].setValue(null);
3726
+ // this.codFormStepOne.controls['course_modality'].setValue(null);
3727
+ // }
3728
+ // if (changes['initialData'] && this.initialData != null && this.dataPreviusCodData === null || this.dataPreviusCodData != null && this.isEditCod === false && this.isRenovation === false) {
3729
+ // this.processData(this.initialData);
3730
+ // console.log("Entro en this.processData con initialData");
3731
+ // this.cdRef.detectChanges();
3732
+ // }else{
3733
+ // this.codFormStepOne.controls['academic_plan'].setValue(null);
3734
+ // this.codFormStepOne.controls['course_type'].setValue(null);
3735
+ // this.codFormStepOne.controls['agreement_by_category'].setValue(null);
3736
+ // this.codFormStepOne.controls['english_level'].setValue(null);
3737
+ // this.codFormStepOne.controls['availible_courses'].setValue(null);
3738
+ // this.codFormStepOne.controls['course_modality'].setValue(null);
3739
+ // }
3740
+ // if (changes['dataPreviusCodData'] && this.dataPreviusCodData != null && this.isEditCod && this.isRenovation === false ) {
3741
+ // this.processData(this.dataPreviusCodData);
3742
+ // console.log("Entro en this.processData con dataPreviusCodData");
3743
+ // if (this.isEditCod && !this.dataPreviusCodData.edit_course_payment) {
3744
+ // this.isDisabledSel = true;
3745
+ // } else {
3746
+ // this.isDisabledSel = false;
3747
+ // }
3748
+ // this.cdRef.detectChanges();
3749
+ // }else if(changes['dataPreviusCodData'] && this.dataPreviusCodData != null && !this.isEditCod && this.courseSelectRenovation && this.isRenovation === true ){
3750
+ // this.setDataCodRenovationSelect();
3751
+ // this.isDisabledSel= true
3752
+ // this.cdRef.detectChanges();
3753
+ // }
3754
+ }
3755
+ handleDataChanges(changes) {
3756
+ // Caso 1: Hay initialData y NO hay dataPreviusCodData
3757
+ if (changes['initialData']?.currentValue && !this.dataPreviusCodData) {
3758
+ console.log("Procesando initialData");
3699
3759
  this.processData(this.initialData);
3700
- this.cdRef.detectChanges();
3701
- }
3702
- else {
3703
- this.codFormStepOne.controls['academic_plan'].setValue(null);
3704
- this.codFormStepOne.controls['course_type'].setValue(null);
3705
- this.codFormStepOne.controls['agreement_by_category'].setValue(null);
3706
- this.codFormStepOne.controls['english_level'].setValue(null);
3707
- this.codFormStepOne.controls['availible_courses'].setValue(null);
3708
- this.codFormStepOne.controls['course_modality'].setValue(null);
3760
+ return;
3709
3761
  }
3710
- if (changes['dataPreviusCodData'] && this.dataPreviusCodData != null && this.isEditCod && this.isRenovation === false) {
3711
- this.processData(this.dataPreviusCodData);
3712
- if (this.isEditCod && !this.dataPreviusCodData.edit_course_payment) {
3713
- this.isDisabledSel = true;
3762
+ // Caso 2: Hay dataPreviusCodData
3763
+ if (changes['dataPreviusCodData']?.currentValue) {
3764
+ // Subcaso 2.1: Es edición
3765
+ if (this.isEditCod && !this.isRenovation) {
3766
+ console.log("Procesando dataPreviusCodData en modo edición");
3767
+ this.processData(this.dataPreviusCodData);
3768
+ this.isDisabledSel = !this.dataPreviusCodData.edit_course_payment;
3769
+ return;
3714
3770
  }
3715
- else {
3716
- this.isDisabledSel = false;
3771
+ // Subcaso 2.2: Es renovación
3772
+ if (!this.isEditCod && this.isRenovation && this.courseSelectRenovation) {
3773
+ console.log("Procesando dataPreviusCodData en modo renovación");
3774
+ this.setDataCodRenovationSelect();
3775
+ this.isDisabledSel = true;
3776
+ return;
3717
3777
  }
3718
- this.cdRef.detectChanges();
3719
- }
3720
- else if (changes['dataPreviusCodData'] && this.dataPreviusCodData != null && !this.isEditCod && this.courseSelectRenovation && this.isRenovation === true) {
3721
- this.setDataCodRenovationSelect();
3722
- this.isDisabledSel = true;
3723
- this.cdRef.detectChanges();
3724
3778
  }
3779
+ // Caso 3: Ninguna condición anterior se cumplió (reset controlado)
3780
+ console.log("Reseteando formulario (condición no reconocida)");
3781
+ this.resetForm();
3725
3782
  }
3726
3783
  processData(data) {
3727
3784
  const { codFormStepOne } = this;
@@ -3806,9 +3863,9 @@ class CodFormStepOneComponent extends CodFormSteps {
3806
3863
  if (academicPlan) {
3807
3864
  this.selectAcademicPlan(academicPlan);
3808
3865
  }
3809
- const agreementByCategory = this.codFormStepOne.controls['agreement_by_category'].value;
3810
- const englishLevel = this.codFormStepOne.controls['english_level'].value;
3811
- const courseModality = this.codFormStepOne.controls['course_modality'].value;
3866
+ const agreementByCategory = parseInt(this.codFormStepOne.controls['agreement_by_category'].value);
3867
+ const englishLevel = parseInt(this.codFormStepOne.controls['english_level'].value);
3868
+ const courseModality = parseInt(this.codFormStepOne.controls['course_modality'].value);
3812
3869
  if (agreementByCategory && englishLevel && courseModality) {
3813
3870
  console.log("se llama getAvailibleCourses desde setValuesByLocalStorage");
3814
3871
  this.getAvailibleCourses();
@@ -3822,18 +3879,24 @@ class CodFormStepOneComponent extends CodFormSteps {
3822
3879
  this.changeStepEvent.emit(1);
3823
3880
  }
3824
3881
  resetForm() {
3825
- this.resetLocalStorage(this.controls);
3826
- this.codFormStepOne.reset();
3882
+ // this.resetLocalStorage(this.controls);
3883
+ // this.codFormStepOne.reset();
3884
+ this.codFormStepOne.controls['academic_plan'].setValue(null);
3885
+ this.codFormStepOne.controls['course_type'].setValue(null);
3886
+ this.codFormStepOne.controls['agreement_by_category'].setValue(null);
3887
+ this.codFormStepOne.controls['english_level'].setValue(null);
3888
+ this.codFormStepOne.controls['availible_courses'].setValue(null);
3889
+ this.codFormStepOne.controls['course_modality'].setValue(null);
3827
3890
  }
3828
3891
  // Eventos de los selects
3829
3892
  selectAcademicPlan(academic_plan) {
3830
3893
  if (academic_plan !== 'Plan') {
3831
- this.codFormStepOne.controls['academic_plan'].setValue(academic_plan);
3894
+ this.codFormStepOne.controls['academic_plan'].setValue(parseInt(academic_plan));
3832
3895
  // this.codFormStepOne.controls['agreement_by_category'].setValue(null);
3833
3896
  // this.codFormStepOne.controls['school_name'].setValue(null);
3834
3897
  // this.codFormStepOne.controls['course_type'].setValue(null);
3835
- this.getCourseType(academic_plan);
3836
- this.getAgreementByPlan(academic_plan);
3898
+ this.getCourseType(parseInt(academic_plan));
3899
+ this.getAgreementByPlan(parseInt(academic_plan));
3837
3900
  }
3838
3901
  else {
3839
3902
  this.codFormStepOne.controls['academic_plan'].setValue(null);