Skip to content

Commit

Permalink
lmendoza/sep-24
Browse files Browse the repository at this point in the history
  • Loading branch information
leomendoza123 committed Sep 25, 2024
1 parent a9d5479 commit 9803bd9
Show file tree
Hide file tree
Showing 12 changed files with 168 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Inject, Injectable } from '@angular/core'
import { WINDOW } from 'src/app/cdk/window'
import { environment } from 'src/environments/environment'

export type journeyType = 'orcid_registration' | 'orcid_update_emails'
export type JourneyType = 'orcid_registration' | 'orcid_update_emails'
@Injectable({
providedIn: 'root',
})
Expand All @@ -18,7 +18,7 @@ export class CustomEventService {
* @param journeyType The type of the journey (e.g., 'orcid_registration', 'orcid_update_emails').
* @param attributes Additional attributes to store with the journey
*/
startJourney(journeyType: journeyType, attributes: any = {}): void {
startJourney(journeyType: JourneyType, attributes: any = {}): void {


// Record the start time and initial attributes
Expand All @@ -41,7 +41,7 @@ export class CustomEventService {
* @param additionalAttributes Any additional attributes related to the event.
*/
recordEvent(
journeyType: journeyType,
journeyType: JourneyType,
eventName: string,
additionalAttributes: any = {}
): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { Component, forwardRef, Input, OnInit, ViewChild } from '@angular/core'
import {
Component,
forwardRef,
Input,
OnDestroy,
OnInit,
ViewChild,
} from '@angular/core'
import {
FormBuilder,
FormControl,
Expand All @@ -14,7 +21,7 @@ import {
import { Register2Service } from 'src/app/core/register2/register2.service'
import { OrcidValidators } from 'src/app/validators'

import { first, switchMap, tap } from 'rxjs/operators'
import { first, switchMap, takeUntil, tap } from 'rxjs/operators'
import { ReactivationService } from '../../../core/reactivation/reactivation.service'
import { ReactivationLocal } from '../../../types/reactivation.local'
import { BaseForm } from '../BaseForm'
Expand All @@ -27,7 +34,7 @@ import {
AffiliationType,
Organization,
} from 'src/app/types/record-affiliation.endpoint'
import { EMPTY, Observable, of } from 'rxjs'
import { EMPTY, Observable, of, Subject } from 'rxjs'
import { RecordAffiliationService } from 'src/app/core/record-affiliations/record-affiliations.service'
import { dateMonthYearValidator } from 'src/app/shared/validators/date/date.validator'
import { RegisterStateService } from '../../register-state.service'
Expand Down Expand Up @@ -70,14 +77,18 @@ export class MyErrorStateMatcher implements ErrorStateMatcher {
},
],
})
export class FormCurrentEmploymentComponent extends BaseForm implements OnInit {
export class FormCurrentEmploymentComponent
extends BaseForm
implements OnInit, OnDestroy
{
// matcher = new MyErrorStateMatcher()
selectedOrganizationFromDatabase: Organization
displayOrganizationHint: boolean
requireOrganizationDisambiguatedDataOnRefresh = false
private _type: AffiliationType
affiliationFound = false
rorIdHasBeenMatched: boolean
destroy = new Subject()

@Input()
public get type(): AffiliationType {
Expand Down Expand Up @@ -129,15 +140,24 @@ export class FormCurrentEmploymentComponent extends BaseForm implements OnInit {
this.isMobile = platform.columns4 || platform.columns8
})
}
ngOnDestroy(): void {
this.destroy.next()
}

ngOnInit() {
this.registerStateService.getNextButtonClickFor('c2').subscribe(() => {
this.nextButtonWasClicked = true
this._registerObservabilityService.stepC2NextButtonClicked(this.form)
})
this.registerStateService.getSkipButtonClickFor('c2').subscribe(() => {
this._registerObservabilityService.stepC2SkipButtonClicked(this.form)
})
this.registerStateService
.getNextButtonClickFor('c2')
.pipe(takeUntil(this.destroy))
.subscribe(() => {
this.nextButtonWasClicked = true
this._registerObservabilityService.stepC2NextButtonClicked(this.form)
})
this.registerStateService
.getSkipButtonClickFor('c2')
.pipe(takeUntil(this.destroy))
.subscribe(() => {
this._registerObservabilityService.stepC2SkipButtonClicked(this.form)
})
this.registerStateService.matchOrganization$.subscribe((organization) => {
this.organization = organization
this.form.patchValue({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
Component,
forwardRef,
Input,
OnDestroy,
OnInit,
ViewChild,
} from '@angular/core'
Expand All @@ -24,6 +25,8 @@ import { LiveAnnouncer } from '@angular/cdk/a11y'
import { environment } from 'src/environments/environment'
import { RegisterObservabilityService } from '../../register-observability.service'
import { RegisterStateService } from '../../register-state.service'
import { Subject } from 'rxjs'
import { takeUntil } from 'rxjs/operators'

@Component({
selector: 'app-form-password',
Expand All @@ -48,7 +51,7 @@ import { RegisterStateService } from '../../register-state.service'
],
preserveWhitespaces: true,
})
export class FormPasswordComponent extends BaseForm implements OnInit {
export class FormPasswordComponent extends BaseForm implements OnInit, OnDestroy {
labelInfo = $localize`:@@register.ariaLabelInfoPassword:info about password`
labelClose = $localize`:@@register.ariaLabelClose:close`
labelConfirmPassword = $localize`:@@register.confirmYourPassword:Confirm your password`
Expand All @@ -67,12 +70,12 @@ export class FormPasswordComponent extends BaseForm implements OnInit {
@Input() personalData: RegisterForm
nextButtonWasClicked: boolean


currentValidate8orMoreCharactersStatus: boolean
ccurentValidateAtLeastALetterOrSymbolStatus: boolean
currentValidateAtLeastANumber: boolean
passwordsValidAreValidAlreadyChecked: any
_currentAccesibilityError: string
destroy = new Subject()
constructor(
private _register: Register2Service,
private _liveAnnouncer: LiveAnnouncer,
Expand All @@ -83,10 +86,13 @@ export class FormPasswordComponent extends BaseForm implements OnInit {
super()
}
ngOnInit() {
this._registerStateService.getNextButtonClickFor('b').subscribe((value) => {
this.nextButtonWasClicked = true
this._registerObservability.stepBNextButtonClicked(this.form)
})
this._registerStateService
.getNextButtonClickFor('b')
.pipe(takeUntil(this.destroy))
.subscribe((value) => {
this.nextButtonWasClicked = true
this._registerObservability.stepBNextButtonClicked(this.form)
})
this.form = new UntypedFormGroup(
{
password: new UntypedFormControl('', {
Expand Down Expand Up @@ -222,6 +228,7 @@ export class FormPasswordComponent extends BaseForm implements OnInit {
}
this._currentAccesibilityError = value
if (!value) {
this._registerObservability.reportRegisterEvent('password_valid')
this.announce(
$localize`:@@register.allPasswordContrainsArMet:All password constraints are met`
)
Expand Down Expand Up @@ -254,6 +261,7 @@ export class FormPasswordComponent extends BaseForm implements OnInit {
const validStatus = this.confirmPasswordValid && this.passwordValid

if (!this.passwordsValidAreValidAlreadyChecked && validStatus) {
this._registerObservability.reportRegisterEvent('password_match')
this.announce(
$localize`:@@register.passwordAreValid:Your passwords match`
)
Expand Down Expand Up @@ -305,4 +313,8 @@ export class FormPasswordComponent extends BaseForm implements OnInit {
}
this._liveAnnouncer.announce(announcement, 'assertive')
}

ngOnDestroy(): void {
this.destroy.next()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
forwardRef,
Inject,
Input,
OnDestroy,
OnInit,
ViewChild,
} from '@angular/core'
Expand All @@ -30,6 +31,7 @@ import {
startWith,
switchMap,
take,
takeUntil,
} from 'rxjs/operators'
import { ReactivationService } from '../../../core/reactivation/reactivation.service'
import { ReactivationLocal } from '../../../types/reactivation.local'
Expand All @@ -51,7 +53,8 @@ import { ErrorHandlerService } from 'src/app/core/error-handler/error-handler.se
import { ERROR_REPORT } from 'src/app/errors'
import { RegisterStateService } from '../../register-state.service'
import { RegisterObservabilityService } from '../../register-observability.service'
export class MyErrorStateMatcher implements ErrorStateMatcher {
import { Subject } from 'rxjs'
export class MyErrorStateMatcher implements ErrorStateMatcher{
isErrorState(
control: FormControl | null,
form: FormGroupDirective | NgForm | null
Expand Down Expand Up @@ -87,7 +90,10 @@ export class MyErrorStateMatcher implements ErrorStateMatcher {
},
],
})
export class FormPersonalComponent extends BaseForm implements OnInit {
export class FormPersonalComponent
extends BaseForm
implements OnInit, OnDestroy
{
matcher = new MyErrorStateMatcher()
@Input() reactivation: ReactivationLocal
@ViewChild(FormGroupDirective) formGroupDir: FormGroupDirective
Expand All @@ -105,6 +111,7 @@ export class FormPersonalComponent extends BaseForm implements OnInit {
emailsAreValidAlreadyChecked: boolean
registerBackendErrors: RegisterBackendErrors
nextButtonWasClicked: boolean
destroy = new Subject()

constructor(
private _register: Register2Service,
Expand All @@ -121,6 +128,9 @@ export class FormPersonalComponent extends BaseForm implements OnInit {
) {
super()
}
ngOnDestroy(): void {
this.destroy.next()
}

emails: UntypedFormGroup = new UntypedFormGroup({})
additionalEmails: UntypedFormGroup = new UntypedFormGroup({
Expand All @@ -131,10 +141,13 @@ export class FormPersonalComponent extends BaseForm implements OnInit {
})

ngOnInit() {
this._registerStateService.getNextButtonClickFor('a').subscribe((value) => {
this.nextButtonWasClicked = true
this._registerObservability.stepANextButtonClicked(this.form)
})
this._registerStateService
.getNextButtonClickFor('a')
.pipe(takeUntil(this.destroy))
.subscribe((value) => {
this.nextButtonWasClicked = true
this._registerObservability.stepANextButtonClicked(this.form)
})
this.emails = new UntypedFormGroup(
{
email: new UntypedFormControl('', {
Expand Down Expand Up @@ -318,7 +331,9 @@ export class FormPersonalComponent extends BaseForm implements OnInit {
const validStatus = this.emailConfirmationValid && this.emailValid
if (!this.emailsAreValidAlreadyChecked && validStatus) {
this.announce($localize`:@@register.emailAreValid:Your emails match`)
this._registerObservability.reportRegisterEvent('emails_match')
} else if (this.emailsAreValidAlreadyChecked && !validStatus) {
this._registerObservability.reportRegisterEvent('emails_do_not_match')
this.announce(
$localize`:@@register.emailAreNotValid:Your emails do not match`
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { Component, DoCheck, forwardRef, OnInit } from '@angular/core'
import {
Component,
DoCheck,
forwardRef,
OnDestroy,
OnInit,
} from '@angular/core'
import {
NG_ASYNC_VALIDATORS,
NG_VALUE_ACCESSOR,
Expand All @@ -13,6 +19,8 @@ import { Register2Service } from 'src/app/core/register2/register2.service'
import { BaseForm } from '../BaseForm'
import { RegisterStateService } from '../../register-state.service'
import { RegisterObservabilityService } from '../../register-observability.service'
import { Subject } from 'rxjs'
import { takeUntil } from 'rxjs/operators'

@Component({
selector: 'app-form-visibility',
Expand All @@ -38,12 +46,13 @@ import { RegisterObservabilityService } from '../../register-observability.servi
})
export class FormVisibilityComponent
extends BaseForm
implements OnInit, DoCheck
implements OnInit, DoCheck, OnDestroy
{
ariaLabelMoreInformationOnVisibility = $localize`:@@register.ariaLabelMoreInformationOnVisibility:More information on visibility settings (Opens in new tab)`
visibilityOptions = VISIBILITY_OPTIONS
errorState = false
activitiesVisibilityDefault = new UntypedFormControl('', Validators.required)
destroy = new Subject()
constructor(
private _register: Register2Service,
private _errorStateMatcher: ErrorStateMatcher,
Expand All @@ -52,10 +61,16 @@ export class FormVisibilityComponent
) {
super()
}
ngOnDestroy(): void {
this.destroy.next()
}
ngOnInit() {
this._registerStateService.getNextButtonClickFor('c').subscribe(() => {
this._registerObservability.stepCNextButtonClicked(this.form)
})
this._registerStateService
.getNextButtonClickFor('c')
.pipe(takeUntil(this.destroy))
.subscribe(() => {
this._registerObservability.stepCNextButtonClicked(this.form)
})
this.form = new UntypedFormGroup({
activitiesVisibilityDefault: this.activitiesVisibilityDefault,
})
Expand Down
1 change: 0 additions & 1 deletion src/app/register2/components/step-a/step-a.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export class StepAComponent
}

ngOnInit(): void {
this._registerObservabilityService.stepLoaded('a')
}
infoSiteBaseUrl = environment.INFO_SITE

Expand Down
1 change: 0 additions & 1 deletion src/app/register2/components/step-b/step-b.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export class StepBComponent extends BaseStepDirective implements OnInit {
super()
}
ngOnInit(): void {
this._registerObservabilityService.stepLoaded('b')
}

nextButtonWasClicked = false
Expand Down
1 change: 0 additions & 1 deletion src/app/register2/components/step-c/step-c.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export class StepCComponent extends BaseStepDirective implements OnInit {
super()
}
ngOnInit(): void {
this._registerObservabilityService.stepLoaded('c')
}

nextButton2() {
Expand Down
1 change: 0 additions & 1 deletion src/app/register2/components/step-c2/step-c2.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export class StepC2Component extends BaseStepDirective implements OnInit {
super()
}
ngOnInit(): void {
this._registerObservabilityService.stepLoaded('c2')
}

optionalNextStep() {
Expand Down
1 change: 0 additions & 1 deletion src/app/register2/components/step-d/step-d.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export class StepDComponent extends BaseStepDirective {
super()
}
ngOnInit(): void {
this._registerObservabilityService.stepLoaded('d')
}

nextButton2() {
Expand Down
Loading

0 comments on commit 9803bd9

Please sign in to comment.