Skip to content

Commit

Permalink
Issue #SH-603 merge: Merge pull request #1045 from NavKumarV/release-…
Browse files Browse the repository at this point in the history
…3.1.0-school-2

Issue #SH-603 fix: adding validation message
  • Loading branch information
swayangjit authored Jul 9, 2020
2 parents 9e7cc0f + a01c82b commit a8d9ab1
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 42 deletions.
17 changes: 11 additions & 6 deletions src/app/components/common-forms/common-forms.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,18 @@
</ion-item>

<ng-container *ngIf="field.asyncValidation?.trigger">
<div class="verification-btn" [hidden]="formControl.status === 'VALID' || formControl.status !== 'PENDING' || !formControl.value">
<ion-button class="ion-text-capitalize"
shape="round"
#validationTrigger
[attr.data-marker]="field.asyncValidation.marker">
<div class="async-validator" [hidden]="formControl.status === 'VALID' || formControl.status !== 'PENDING' || !formControl.value">
<div class="cf-error" *ngIf="field.asyncValidation?.message">
{{ field.asyncValidation.message | translate }}
</div>
<div class="verification-btn">
<ion-button class="ion-text-capitalize"
shape="round"
#validationTrigger
[attr.data-marker]="field.asyncValidation.marker">
{{field.asyncValidation.trigger}}
</ion-button>
</ion-button>
</div>
</div>
</ng-container>
</ng-container>
Expand Down
4 changes: 4 additions & 0 deletions src/app/components/common-forms/common-forms.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,8 @@ ion-checkbox {

.required-star{
color: red;
}

.async-validator{
margin: 0 16px;
}
1 change: 1 addition & 0 deletions src/app/components/common-forms/field-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface FieldConfig<T> {
}[];
asyncValidation?: {
marker: string,
message?: string,
trigger?: string,
asyncValidatorFactory?: AsyncValidatorFactory
};
Expand Down
2 changes: 1 addition & 1 deletion src/app/profile/profile.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
</div>
</div>

<div class="self-declare-teacher-details" *ngIf="selfDeclaredTeacherDetails?.schoolName || selfDeclaredTeacherDetails?.udiseId || selfDeclaredTeacherDetails?.teacherId">
<div class="self-declare-teacher-details" *ngIf="selfDeclaredTeacherDetails?.state || selfDeclaredTeacherDetails?.district || selfDeclaredTeacherDetails?.mobile || selfDeclaredTeacherDetails?.teacherId">
<div class="container" *ngIf = "selfDeclaredTeacherDetails?.state">
<div>{{'STATE' | translate }}:</div>
<div class="bolder">{{selfDeclaredTeacherDetails?.state}}</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,10 @@ export class SelfDeclaredTeacherEditPage {
stateCode = stateDetails && stateDetails.id;
}
if (!isFormLoaded) {
this.initialExternalIds[childConfig.code] = stateCode;
this.initialExternalIds[childConfig.code] = {
name: this.commonUtilService.translateMessage(childConfig.templateOptions.label) || '',
value: stateCode
};
}
childConfig.templateOptions.options = this.buildStateListClosure(stateCode);
} else if (childConfig.templateOptions['dataSrc'].params.id === 'district') {
Expand All @@ -172,7 +175,10 @@ export class SelfDeclaredTeacherEditPage {
}

if (!isFormLoaded) {
this.initialExternalIds[childConfig.code] = districtDetails && districtDetails.id;
this.initialExternalIds[childConfig.code] = {
name: this.commonUtilService.translateMessage(childConfig.templateOptions.label) || '',
value: districtDetails && districtDetails.id
} ;
}
childConfig.templateOptions.options = this.buildDistrictListClosure(districtDetails && districtDetails.id, isFormLoaded);
}
Expand All @@ -182,29 +188,27 @@ export class SelfDeclaredTeacherEditPage {
if (childConfig.asyncValidation) {
childConfig = this.assignDefaultValue(childConfig, isFormLoaded);

const telemetryData = {
type: InteractType.TOUCH,
subType: '',
env: Environment.USER,
pageId: PageId.TEACHER_SELF_DECLARATION,
id: ''
};
const initialValue = this.initialExternalIds[childConfig.code] && this.initialExternalIds[childConfig.code].value;

if (childConfig.asyncValidation.marker === 'MOBILE_OTP_VALIDATION') {
const telemetryData = {
type: InteractType.TOUCH,
subType: '',
env: Environment.USER,
pageId: PageId.TEACHER_SELF_DECLARATION,
id: ID.VALIDATE_MOBILE
};
telemetryData['id'] = ID.VALIDATE_MOBILE;

childConfig.asyncValidation.asyncValidatorFactory =
this.formValidationAsyncFactory.mobileVerificationAsyncFactory(
childConfig, this.profile, this.initialExternalIds[childConfig.code], telemetryData
childConfig, this.profile, initialValue, telemetryData
);
} else if (childConfig.asyncValidation.marker === 'EMAIL_OTP_VALIDATION') {
const telemetryData = {
type: InteractType.TOUCH,
subType: '',
env: Environment.USER,
pageId: PageId.TEACHER_SELF_DECLARATION,
id: ID.VALIDATE_EMAIL
};
telemetryData['id'] = ID.VALIDATE_EMAIL;
childConfig.asyncValidation.asyncValidatorFactory =
this.formValidationAsyncFactory.emailVerificationAsyncFactory(
childConfig, this.profile, this.initialExternalIds[childConfig.code], telemetryData
childConfig, this.profile, initialValue, telemetryData
);
}
return childConfig;
Expand Down Expand Up @@ -260,7 +264,10 @@ export class SelfDeclaredTeacherEditPage {
}

if (!isFormLoaded) {
this.initialExternalIds[childConfig.code] = childConfig.default || undefined;
this.initialExternalIds[childConfig.code] = {
name: this.commonUtilService.translateMessage(childConfig.templateOptions.label) || '',
value: childConfig.default || undefined
};
}
return childConfig;
}
Expand Down Expand Up @@ -447,17 +454,9 @@ export class SelfDeclaredTeacherEditPage {
getUpdatedValues(formVal) {
const telemetryValue = [];

this.profile['userLocations'].forEach(ele => {
if (ele.type === 'state' && ele.id !== formVal.state) {
telemetryValue.push('State');
}
if (ele.type === 'district' && ele.id !== formVal.district) {
telemetryValue.push('District');
}
});

for (const data in this.initialExternalIds) {
if (data !== 'state' && data !== 'district' && this.initialExternalIds[data].value !== formVal[data]) {
if (this.initialExternalIds[data] && this.initialExternalIds[data].value !== null &&
this.initialExternalIds[data].value !== undefined && this.initialExternalIds[data].value !== formVal[data]) {
telemetryValue.push(this.initialExternalIds[data].name);
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/app/search/search.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,9 @@ export class SearchPage implements OnInit, AfterViewInit, OnDestroy {
displayDialCodeResult.push(dialCodeCourseResultObj);
}
}
this.generateImpressionEvent(displayDialCodeResult[0].dialCodeResult);
if (displayDialCodeResult.length && displayDialCodeResult[0].dialCodeResult) {
this.generateImpressionEvent(displayDialCodeResult[0].dialCodeResult);
}
let isParentCheckStarted = false;
if (dialCodeResultObj.dialCodeResult.length === 1 && dialCodeResultObj.dialCodeResult[0].content.length === 1
&& isAllContentMappedToCollection) {
Expand Down
5 changes: 4 additions & 1 deletion src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -799,5 +799,8 @@
"COURSE_COMPLETION_POPUP_DESC": "You will be notified on your registered contact details about the course certificate within 7 days",
"COURSE_COMPLETION_POPUP_NO_CERTIFICATE": "Note: This course does not have a certificate",
"CONGRATULATIONS": "Congratulations!",
"SPECIAL_CHARACTERS_NOT_SUPPORTED": "Special characters not supported"
"SPECIAL_CHARACTERS_NOT_SUPPORTED": "Special characters not supported",
"PLEASE_VALIDATE_YOUR_MOBILE_NUMBER": "Please validate your mobile number",
"PLEASE_VALIDATE_YOUR_EMAIL_ADDRESS": "Please validate your email address",
"ERROR_OTP_LIMIT_EXCEEDED": "You have exceeded the maximum limit for OTP, Please try after some time."
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,13 @@ export class FormValidationAsyncFactory {
return false;
}
} catch (e) {
if (e.hasOwnProperty(e) === 'ERROR_RATE_LIMIT_EXCEEDED') {
this.commonUtilService.showToast('You have exceeded the maximum limit for OTP, Please try after some time.');
} else if (e.message === 'CANCEL') {
throw e;
if (e && e.response && e.response.body && e.response.body.params && e.response.body.params.err &&
e.response.body.params.err === 'ERROR_RATE_LIMIT_EXCEEDED') {
this.commonUtilService.showToast('ERROR_OTP_LIMIT_EXCEEDED');
} else if (e.message !== 'CANCEL') {
this.commonUtilService.showToast('SOMETHING_WENT_WRONG');
}
throw e;
return false;
} finally {
if (loader) {
Expand Down

0 comments on commit a8d9ab1

Please sign in to comment.