From f439f2ebd766d639e031f8621ad10b172588b4d5 Mon Sep 17 00:00:00 2001 From: NandiniAV Date: Tue, 5 Jul 2022 11:16:21 +0530 Subject: [PATCH 1/3] Disabled explore button for faq guest --- .../src/lib/btn-page-back/btn-page-back.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/ws-widget/collection/src/lib/btn-page-back/btn-page-back.component.html b/library/ws-widget/collection/src/lib/btn-page-back/btn-page-back.component.html index 6b5da444d..f5fe34f0d 100644 --- a/library/ws-widget/collection/src/lib/btn-page-back/btn-page-back.component.html +++ b/library/ws-widget/collection/src/lib/btn-page-back/btn-page-back.component.html @@ -3,7 +3,7 @@
- + diff --git a/project/ws/app/src/lib/routes/profile-v3/routes/roles-and-activities/roles-and-activities.component.ts b/project/ws/app/src/lib/routes/profile-v3/routes/roles-and-activities/roles-and-activities.component.ts index ce18f91af..50f5c9a1c 100644 --- a/project/ws/app/src/lib/routes/profile-v3/routes/roles-and-activities/roles-and-activities.component.ts +++ b/project/ws/app/src/lib/routes/profile-v3/routes/roles-and-activities/roles-and-activities.component.ts @@ -72,7 +72,7 @@ export class RolesAndActivitiesComponent implements OnInit, OnDestroy { } this.rolesAndActivityService.createRoles(reqObj).subscribe(res => { if (res) { - this.snackBar.open('updated Successfully!!') + this.snackBar.open('Updated successfully') this.userRoles.push({ id: role.value, description: role.value, @@ -121,7 +121,7 @@ export class RolesAndActivitiesComponent implements OnInit, OnDestroy { updateDeleteRoles(reqObj: any) { this.rolesAndActivityService.createRoles(reqObj).subscribe(res => { if (res) { - this.snackBar.open('updated Successfully!!') + this.snackBar.open('Updated successfully') this.createRole.reset() this.selectedActivity = [] this.configSvc.updateGlobalProfile(true) From e449251dc6bb7e4d16e606366b32c97c4327b3ff Mon Sep 17 00:00:00 2001 From: "christopher.fernandes" Date: Wed, 6 Jul 2022 18:04:48 +0530 Subject: [PATCH 3/3] Task #58821: Added hierachy fields in signup page --- .../public-signup.component.html | 112 +++++++- .../public-signup.component.scss | 1 - .../public-signup/public-signup.component.ts | 251 ++++++++++++++---- .../public/public-signup/signup.service.ts | 24 +- 4 files changed, 332 insertions(+), 56 deletions(-) diff --git a/src/app/routes/public/public-signup/public-signup.component.html b/src/app/routes/public/public-signup/public-signup.component.html index ca83c8707..eb556b4d7 100644 --- a/src/app/routes/public/public-signup/public-signup.component.html +++ b/src/app/routes/public/public-signup/public-signup.component.html @@ -166,6 +166,116 @@

+ + + + Center + + + State + + +
+
+ + + + + {{typeValueStartCase}} is mandatory + + + You must enter value from suggested list only. + + + + + {{ option.orgname }} + + +
+ +
+ + + + + Department is mandatory + + + You must enter value from suggested list only. + + + + + {{ option.orgname }} + + +
+ +
+ + + + + Organisation is mandatory + + + You must enter value from suggested list only. + + + + + {{ option.orgname }} + + +
+
{ @@ -62,6 +64,10 @@ export class PublicSignupComponent implements OnInit, OnDestroy { portalID = '' confirm = false disableBtn = false + ministeries: any[] = [] + masterMinisteries!: Observable | undefined + orgs: any[] = [] + masterOrgs!: Observable | undefined private subscriptionContact: Subscription | null = null private recaptchaSubscription!: Subscription @@ -81,14 +87,18 @@ export class PublicSignupComponent implements OnInit, OnDestroy { lastname: new FormControl('', [Validators.required, Validators.pattern(this.namePatern)]), position: new FormControl('', [Validators.required, forbiddenNamesValidatorPosition(this.masterPositions)]), email: new FormControl('', [Validators.required, Validators.pattern(this.emailWhitelistPattern)]), - department: new FormControl('', [Validators.required, forbiddenNamesValidator(this.masterDepartments)]), + // department: new FormControl('', [Validators.required, forbiddenNamesValidator(this.masterDepartments)]), confirmBox: new FormControl(false, [Validators.required]), + type: new FormControl('ministry', [Validators.required]), + ministry: new FormControl('', [Validators.required, forbiddenNamesValidator(this.masterMinisteries)]), + department: new FormControl('', [forbiddenNamesValidator(this.masterDepartments)]), + organisation: new FormControl('', [forbiddenNamesValidator(this.masterOrgs)]), // recaptchaReactive: new FormControl(null, [Validators.required]), }) } ngOnInit() { - this.fetchDepartments() + this.fetchDropDownValues('ministry') const instanceConfig = this.configSvc.instanceConfig this.positionsOriginal = this.configSvc.positions || [] this.onPositionsChange() @@ -100,39 +110,109 @@ export class PublicSignupComponent implements OnInit, OnDestroy { if (isPlatformBrowser(this._platformId)) { this._document.body.classList.add('cs-recaptcha') } + + // tslint:disable-next-line: no-non-null-assertion + this.registrationForm.get('type')!.valueChanges.subscribe((value: any) => { + if (value) { + this.fetchDropDownValues(value) + } + }) } - fetchDepartments() { - this.signupSvc.getDepartments().subscribe( - (res: any) => { - if (res && res.result) { - this.masterDepartmentsOriginal = res.result.content - this.onDepartmentsChange() + get typeValueStartCase() { + // tslint:disable-next-line: no-non-null-assertion + return _.startCase(this.registrationForm.get('type')!.value) + } + + get typeValue() { + // tslint:disable-next-line: no-non-null-assertion + return this.registrationForm.get('type')!.value + } + + fetchDropDownValues(type: string) { + this.clearValues() + if (type === 'state') { + this.signupSvc.getStatesOrMinisteries('state').subscribe(res => { + if (res && res.result && res.result && res.result.response && res.result.response.content) { + this.ministeries = res.result.response.content + this.onMinisteriesChange() } - }, - (err: any) => { - this.loggerSvc.error('USER RATING FETCH ERROR >', err) - } - ) + }) + } + if (type === 'ministry') { + this.signupSvc.getStatesOrMinisteries('ministry').subscribe(res => { + if (res && res.result && res.result && res.result.response && res.result.response.content) { + this.ministeries = res.result.response.content + this.onMinisteriesChange() + } + }) + } } - onDepartmentsChange(): void { + clearValues() { + // tslint:disable-next-line: no-non-null-assertion + this.registrationForm.get('ministry')!.setValue('') + // tslint:disable-next-line: no-non-null-assertion + this.registrationForm.get('department')!.setValue('') + // tslint:disable-next-line: no-non-null-assertion + this.registrationForm.get('organisation')!.setValue('') + } + onMinisteriesChange() { + // tslint:disable-next-line: no-non-null-assertion + this.masterMinisteries = this.registrationForm.get('ministry')!.valueChanges + .pipe( + debounceTime(500), + distinctUntilChanged(), + startWith(''), + map(value => typeof (value) === 'string' ? value : (value && value.orgname ? value.orgname : '')), + map(orgname => orgname ? this.filterMinisteries(orgname) : this.ministeries.slice()) + ) + + this.masterMinisteries.subscribe((event: any) => { + // tslint:disable-next-line: no-non-null-assertion + this.registrationForm.get('ministry')!.setValidators([Validators.required, forbiddenNamesValidator(event)]) + this.registrationForm.updateValueAndValidity() + }) + } + + onDepartmentChange() { // tslint:disable-next-line: no-non-null-assertion this.masterDepartments = this.registrationForm.get('department')!.valueChanges .pipe( debounceTime(500), distinctUntilChanged(), startWith(''), - map(value => typeof (value) === 'string' ? value : (value && value.name ? value.name : '')), - map(name => name ? this.filterDepartments(name) : this.masterDepartmentsOriginal.slice()) + map(value => typeof (value) === 'string' ? value : (value && value.orgname ? value.orgname : '')), + map(orgname => orgname ? this.filterDepartments(orgname) : this.departments.slice()) ) - this.masterDepartments.subscribe((event: any) => { - // tslint:disable-next-line: no-non-null-assertion - this.registrationForm.get('department')!.setValidators([Validators.required, forbiddenNamesValidator(event)]) - this.registrationForm.updateValueAndValidity() - }) + this.masterDepartments.subscribe((event: any) => { + // tslint:disable-next-line: no-non-null-assertion + this.registrationForm.get('department')!.setValidators([forbiddenNamesValidator(event)]) + // tslint:disable-next-line: no-non-null-assertion + // this.registrationForm.get('department')!.setValidators(null) + this.registrationForm.updateValueAndValidity() + }) + } + onOrgsChange() { + // tslint:disable-next-line: no-non-null-assertion + this.masterOrgs = this.registrationForm.get('organisation')!.valueChanges + .pipe( + debounceTime(500), + distinctUntilChanged(), + startWith(''), + map(value => typeof (value) === 'string' ? value : (value && value.orgname ? value.orgname : '')), + map(orgname => orgname ? this.filterOrgs(orgname) : this.orgs.slice()) + ) + + this.masterOrgs.subscribe((event: any) => { + // tslint:disable-next-line: no-non-null-assertion + this.registrationForm.get('organisation')!.setValidators([forbiddenNamesValidator(event)]) + // tslint:disable-next-line: no-non-null-assertion + // this.registrationForm.get('organisation')!.setValidators(null) + this.registrationForm.updateValueAndValidity() + }) } onPositionsChange() { @@ -153,12 +233,28 @@ export class PublicSignupComponent implements OnInit, OnDestroy { }) } - private filterDepartments(name: string): any { - if (name) { - const filterValue = name.toLowerCase() - return this.masterDepartmentsOriginal.filter((option: any) => option.channel.toLowerCase().includes(filterValue)) + filterMinisteries(orgname: string) { + if (orgname) { + const filterValue = orgname.toLowerCase() + return this.ministeries.filter((option: any) => option.orgname.toLowerCase().includes(filterValue)) + } + return this.ministeries + } + + filterDepartments(orgname: string) { + if (orgname) { + const filterValue = orgname.toLowerCase() + return this.departments.filter((option: any) => option.orgname.toLowerCase().includes(filterValue)) } - return this.masterDepartmentsOriginal + return this.departments + } + + filterOrgs(orgname: string) { + if (orgname) { + const filterValue = orgname.toLowerCase() + return this.orgs.filter((option: any) => option.orgname.toLowerCase().includes(filterValue)) + } + return this.orgs } private filterPositions(name: string): any { @@ -176,19 +272,6 @@ export class PublicSignupComponent implements OnInit, OnDestroy { }) } - ngOnDestroy() { - if (this.subscriptionContact) { - this.subscriptionContact.unsubscribe() - } - if (this.recaptchaSubscription) { - this.recaptchaSubscription.unsubscribe() - } - - if (isPlatformBrowser(this._platformId)) { - this._document.body.classList.remove('cs-recaptcha') - } - } - displayFn = (value: any) => { return value ? value.channel : undefined } @@ -205,15 +288,36 @@ export class PublicSignupComponent implements OnInit, OnDestroy { // tslint:disable-next-line: no-console console.log('captcha validation success') - // perform signup operations - const req = { - firstName: this.registrationForm.value.firstname || '', - lastName: this.registrationForm.value.lastname || '', - email: this.registrationForm.value.email || '', - deptId: this.registrationForm.value.department.identifier || '', - deptName: this.registrationForm.value.department.channel || '', - position: this.registrationForm.value.position.name || '', - source: `${environment.name}.${this.portalID}` || '', + // to get the org details from either ministry/state, or department or organisation which ever user has filled + let hierarchyObj + let req: any + if (this.registrationForm.value.ministry) { + hierarchyObj = this.registrationForm.value.ministry + if (this.registrationForm.value.department) { + hierarchyObj = this.registrationForm.value.department + if (this.registrationForm.value.organisation) { + hierarchyObj = this.registrationForm.value.organisation + } + } + } + // console.log('hierarchyObj: ', hierarchyObj) + if (hierarchyObj) { + req = { + firstName: this.registrationForm.value.firstname || '', + lastName: this.registrationForm.value.lastname || '', + email: this.registrationForm.value.email || '', + // deptId: this.registrationForm.value.department.identifier || '', + // deptName: this.registrationForm.value.department.channel || '', + position: this.registrationForm.value.position.name || '', + source: `${environment.name}.${this.portalID}` || '', + orgName: hierarchyObj.orgname || '', + channel: hierarchyObj.orgname || '', + organisationType: hierarchyObj.sborgtype || '', + organisationSubType: hierarchyObj.sbsuborgtype || '', + mapId: hierarchyObj.mapid || '', + sbRootOrgId: hierarchyObj.sbrootorgid, + sbOrgId: hierarchyObj.sborgid, + } } // console.log('req: ', req) @@ -260,4 +364,53 @@ export class PublicSignupComponent implements OnInit, OnDestroy { dialogRef.afterClosed().subscribe((_result: any) => { }) } -} \ No newline at end of file + + ministrySelected(value: any) { + if (value && value.mapid) { + this.signupSvc.getDeparmentsOfState(value.mapid).subscribe(res => { + if (res && res.result && res.result && res.result.response && res.result.response.content) { + this.departments = res.result.response.content + + // to reset department and organisation values when minstry/state is changed + // tslint:disable-next-line: no-non-null-assertion + this.registrationForm.get('department')!.setValue('') + // tslint:disable-next-line: no-non-null-assertion + this.registrationForm.get('organisation')!.setValue('') + this.onDepartmentChange() + } + }) + } + } + + departmentSelected(value: any) { + if (value && value.mapid) { + this.signupSvc.getOrgsOfDepartment(value.mapid).subscribe(res => { + if (res && res.result && res.result && res.result.response && res.result.response.content) { + this.orgs = res.result.response.content + + // to reset organisation values when department is changed + // tslint:disable-next-line: no-non-null-assertion + this.registrationForm.get('organisation')!.setValue('') + this.onOrgsChange() + } + }) + } + } + + displayFnState = (value: any) => { + return value ? value.orgname : undefined + } + + ngOnDestroy() { + if (this.subscriptionContact) { + this.subscriptionContact.unsubscribe() + } + if (this.recaptchaSubscription) { + this.recaptchaSubscription.unsubscribe() + } + + if (isPlatformBrowser(this._platformId)) { + this._document.body.classList.remove('cs-recaptcha') + } + } +} diff --git a/src/app/routes/public/public-signup/signup.service.ts b/src/app/routes/public/public-signup/signup.service.ts index d10673278..e4dc4343e 100644 --- a/src/app/routes/public/public-signup/signup.service.ts +++ b/src/app/routes/public/public-signup/signup.service.ts @@ -3,8 +3,11 @@ import { Observable } from 'rxjs' import { HttpClient } from '@angular/common/http' const API_END_POINTS = { - GET_DEPARTMENTS: `/api/user/registration/v1/getDeptDetails`, + // GET_DEPARTMENTS: `/api/user/registration/v1/getDeptDetails`, REGISTER: `/api/user/registration/v1/register`, + GET_ALL_STATES: '/apis/public/v8/org/v1/list', + GET_DEPARTMENTS_OF_STATE: '/apis/public/v8/org/v1/list', + GET_ORGS_OF_DEPT: '/apis/public/v8/org/v1/list', } @Injectable({ @@ -14,13 +17,24 @@ export class SignupService { constructor(private http: HttpClient) { } - getDepartments(): Observable { - return this.http.get(API_END_POINTS.GET_DEPARTMENTS) - } + // getDepartments(): Observable { + // return this.http.get(API_END_POINTS.GET_DEPARTMENTS) + // } register(req: any) { return this.http.post( API_END_POINTS.REGISTER, req ) } -} \ No newline at end of file + + getStatesOrMinisteries(type: string): Observable { + return this.http.get(`${API_END_POINTS.GET_ALL_STATES}/${type}`) + } + getDeparmentsOfState(stateId: string): Observable { + return this.http.get(`${API_END_POINTS.GET_DEPARTMENTS_OF_STATE}/${stateId}`) + } + getOrgsOfDepartment(deptId: string): Observable { + return this.http.get(`${API_END_POINTS.GET_ORGS_OF_DEPT}/${deptId}`) + } + +}