Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const routes: Routes = [
path: ApplicationRoutes.register,
canActivateChild: [LanguageGuard, RegisterGuard],
loadChildren: () =>
import('./register2/register.module').then((m) => m.Register2Module),
import('./register/register.module').then((m) => m.RegisterModule),
},
{
path: ApplicationRoutes.search,
Expand Down Expand Up @@ -151,7 +151,7 @@ const routes: Routes = [
matcher: routerReactivation,
canActivateChild: [LanguageGuard, RegisterGuard],
loadChildren: () =>
import('./register2/register.module').then((m) => m.Register2Module),
import('./register/register.module').then((m) => m.RegisterModule),
},
{
path: ApplicationRoutes.selfService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'
import { OrganizationsService, UserService } from 'src/app/core'
import { RecordAffiliationService } from 'src/app/core/record-affiliations/record-affiliations.service'
import { RecordService } from 'src/app/core/record/record.service'
import { Register2Service } from 'src/app/core/register2/register2.service'
import { RegisterService } from 'src/app/core/register/register.service'
import { AffiliationsInterstitialComponent } from './affiliations-interstitial.component'
import { EMPTY } from 'rxjs'
import { PlatformInfoService } from 'src/app/cdk/platform-info'
Expand Down Expand Up @@ -38,7 +38,7 @@ describe('AffiliationsInterstitialComponent', () => {
},

{
provide: Register2Service,
provide: RegisterService,
useValue: {},
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
} from 'src/app/constants'
import { dateMonthYearValidator } from 'src/app/shared/validators/date/date.validator'
import { OrganizationsService, UserService } from 'src/app/core'
import { Register2Service } from 'src/app/core/register2/register2.service'
import { RegisterService } from 'src/app/core/register/register.service'
import { AssertionVisibilityString, RequestInfoForm } from 'src/app/types'
import {
Affiliation,
Expand Down Expand Up @@ -97,7 +97,7 @@ export class AffiliationsInterstitialComponent implements OnInit, OnDestroy {
private formBuilder: UntypedFormBuilder,
private recordService: RecordService,
private organizationService: OrganizationsService,
private register2Service: Register2Service,
private registerService: RegisterService,
private user: UserService
) {}

Expand All @@ -115,7 +115,7 @@ export class AffiliationsInterstitialComponent implements OnInit, OnDestroy {
switchMap((domain: AssertionVisibilityString) => {
if (domain) {
this.userDomainMatched = domain.value
return this.register2Service
return this.registerService
.getEmailCategory(domain.value)
.pipe(map((response) => response.rorId))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ import {
} from '@angular/material/legacy-dialog'
import { OrganizationsService, UserService } from 'src/app/core'
import { RecordService } from 'src/app/core/record/record.service'
import { RecordCountriesService } from 'src/app/core/record-countries/record-countries.service'
import { RecordAffiliationService } from 'src/app/core/record-affiliations/record-affiliations.service'
import { Register2Service } from 'src/app/core/register2/register2.service'
import { extend } from 'lodash'
import { RegisterService } from 'src/app/core/register/register.service'

import {
BaseInterstitialDialogInput,
BaseInterstitialDialogOutput,
Expand Down Expand Up @@ -66,7 +65,7 @@ export class AffiliationsInterstitialDialogComponent extends AffiliationsInterst
formBuilder: UntypedFormBuilder,
recordService: RecordService,
organizationService: OrganizationsService,
register2Service: Register2Service,
registerService: RegisterService,
private dialogRef: MatLegacyDialogRef<
AffiliationsInterstitialDialogComponent,
AffilationsComponentDialogOutput
Expand All @@ -80,7 +79,7 @@ export class AffiliationsInterstitialDialogComponent extends AffiliationsInterst
formBuilder,
recordService,
organizationService,
register2Service,
registerService,
user
)
}
Expand Down
26 changes: 17 additions & 9 deletions src/app/core/register/register.backend-validators.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { HttpClient } from '@angular/common/http'
import {
UntypedFormGroup,
AsyncValidatorFn,
AbstractControl,
AsyncValidatorFn,
UntypedFormGroup,
ValidationErrors,
} from '@angular/forms'
import { RegisterForm } from 'src/app/types/register.endpoint'
import { Constructor } from 'src/app/types'
import { Observable, of } from 'rxjs'

import { retry, catchError, map } from 'rxjs/operators'
import { HttpClient } from '@angular/common/http'
import { catchError, map, retry } from 'rxjs/operators'
import { Constructor } from 'src/app/types'
import { RegisterForm } from 'src/app/types/register.endpoint'
import { ErrorHandlerService } from '../error-handler/error-handler.service'

interface HasHttpClientAndErrorHandler {
Expand All @@ -23,7 +22,10 @@ interface HasFormAdapters {
formGroupToFullRegistrationForm(
StepA: UntypedFormGroup,
StepB: UntypedFormGroup,
StepC: UntypedFormGroup
StepC: UntypedFormGroup,
StepC2: UntypedFormGroup,
StepD: UntypedFormGroup,
isReactivation?: boolean
): RegisterForm
}

Expand Down Expand Up @@ -160,13 +162,19 @@ export function RegisterBackendValidatorMixin<
StepA: UntypedFormGroup,
StepB: UntypedFormGroup,
StepC: UntypedFormGroup,
StepC2: UntypedFormGroup,
StepD: UntypedFormGroup,
isReactivation?: boolean,
type?: 'shibboleth'
): Observable<RegisterForm> {
const registerForm = this.formGroupToFullRegistrationForm(
StepA,
StepB,
StepC
StepC,
StepC2,
StepD
)
registerForm.isReactivation = isReactivation
return this._http
.post<RegisterForm>(
`${runtimeEnvironment.API_WEB}register.json`,
Expand Down
57 changes: 50 additions & 7 deletions src/app/core/register/register.form-adapter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { UntypedFormGroup } from '@angular/forms'
import { RegisterForm } from 'src/app/types/register.endpoint'
import { Value, Visibility } from 'src/app/types/common.endpoint'
import { Constructor } from 'src/app/types'
import { Value, Visibility } from 'src/app/types/common.endpoint'
import { RegisterForm } from 'src/app/types/register.endpoint'

export function RegisterFormAdapterMixin<T extends Constructor<any>>(base: T) {
return class RegisterFormAdapter extends base {
Expand Down Expand Up @@ -116,18 +116,61 @@ export function RegisterFormAdapterMixin<T extends Constructor<any>>(base: T) {
return value
}

formGroupToAffiliationRegisterForm(formGroup: UntypedFormGroup) {
const value = formGroup.controls['organization'].value
const departmentName = formGroup.controls['departmentName'].value
const roleTitle = formGroup.controls['roleTitle'].value
const startDateGroup = formGroup.controls['startDateGroup'].value

if (typeof value === 'string') {
return { affiliationName: { value } }
} else {
return {
affiliationName: { value: value.value },
disambiguatedAffiliationSourceId: {
value: value.disambiguatedAffiliationIdentifier,
},
orgDisambiguatedId: {
value: value.disambiguatedAffiliationIdentifier,
},
departmentName: { value: departmentName },
roleTitle: { value: roleTitle },
affiliationType: { value: 'employment' },
startDate: {
month: startDateGroup.startDateMonth,
year: startDateGroup.startDateYear,
},
sourceId: { value: value.sourceId },
city: { value: value.city },
region: { value: value.region },
country: { value: value.country },
}
}
}

formGroupToFullRegistrationForm(
StepA: UntypedFormGroup,
StepB: UntypedFormGroup,
StepC: UntypedFormGroup
StepC: UntypedFormGroup,
StepC2: UntypedFormGroup,
StepD: UntypedFormGroup
): RegisterForm {
return {
const value = {
...StepA.value.personal,
...StepB.value.password,
...StepB.value.sendOrcidNews,
...StepC.value.activitiesVisibilityDefault,
...StepC.value.termsOfUse,
...StepC.value.captcha,
...StepD.value.sendOrcidNews,
...StepD.value.termsOfUse,
...StepD.value.captcha,
}

if (StepC2.valid) {
return {
...value,
...StepC2.value.affiliations,
}
} else {
return value
}
}
}
Expand Down
36 changes: 0 additions & 36 deletions src/app/core/register/register.service.spec.ts

This file was deleted.

23 changes: 17 additions & 6 deletions src/app/core/register/register.service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { HttpClient } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { UntypedFormGroup } from '@angular/forms'
import { Observable } from 'rxjs'
import { catchError, first, map, retry, switchMap } from 'rxjs/operators'
import { Observable, throwError } from 'rxjs'
import { catchError, first, map, retry, switchMap, tap } from 'rxjs/operators'
import { PlatformInfo, PlatformInfoService } from 'src/app/cdk/platform-info'
import { RequestInfoForm } from 'src/app/types'
import {
Expand All @@ -11,13 +11,14 @@ import {
RegisterForm,
} from 'src/app/types/register.endpoint'

import { ERROR_REPORT } from 'src/app/errors'
import { objectToUrlParameters } from '../../constants'
import { ReactivationLocal } from '../../types/reactivation.local'
import { ErrorHandlerService } from '../error-handler/error-handler.service'
import { UserService } from '../user/user.service'
import { RegisterBackendValidatorMixin } from './register.backend-validators'
import { RegisterFormAdapterMixin } from './register.form-adapter'
import { ERROR_REPORT } from 'src/app/errors'
import { objectToUrlParameters } from '../../constants'
import { ReactivationLocal } from '../../types/reactivation.local'
import { EmailCategoryEndpoint } from 'src/app/types/register.email-category'

// Mixing boiler plate

Expand Down Expand Up @@ -76,10 +77,18 @@ export class RegisterService extends _RegisterServiceMixingBase {
.pipe(map((form) => (this.backendRegistrationForm = form)))
}

getEmailCategory(email: string): Observable<EmailCategoryEndpoint> {
return this._http.get<any>(
`${runtimeEnvironment.API_WEB}email-domain/find-category?domain=${email}`
)
}

register(
StepA: UntypedFormGroup,
StepB: UntypedFormGroup,
StepC: UntypedFormGroup,
StepC2: UntypedFormGroup,
StepD: UntypedFormGroup,
reactivation: ReactivationLocal,
requestInfoForm?: RequestInfoForm,
updateUserService = true
Expand All @@ -89,7 +98,9 @@ export class RegisterService extends _RegisterServiceMixingBase {
const registerForm = this.formGroupToFullRegistrationForm(
StepA,
StepB,
StepC
StepC,
StepC2,
StepD
)
this.addOauthContext(registerForm, requestInfoForm)
return this._platform.get().pipe(
Expand Down
Loading