Skip to content

Commit 401928e

Browse files
Merge pull request #2144 from ORCID/fix/batch-of-fixes-2-feb
Fix/batch of fixes 2 feb
2 parents b7dd89c + a4435bc commit 401928e

32 files changed

+202
-47
lines changed

src/app/core/register2/register2.form-adapter.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ export function Register2FormAdapterMixin<T extends Constructor<any>>(base: T) {
127127
} else {
128128
return {
129129
affiliationName: { value: value.value },
130+
disambiguatedAffiliationSourceId: {
131+
value: value.disambiguatedAffiliationIdentifier,
132+
},
130133
orgDisambiguatedId: {
131134
value: value.disambiguatedAffiliationIdentifier,
132135
},
@@ -137,6 +140,10 @@ export function Register2FormAdapterMixin<T extends Constructor<any>>(base: T) {
137140
month: startDateGroup.startDateMonth,
138141
year: startDateGroup.startDateYear,
139142
},
143+
sourceId: { value: value.sourceId },
144+
city: { value: value.city },
145+
region: { value: value.region },
146+
country: { value: value.country },
140147
}
141148
}
142149
}

src/app/register2/components/form-current-employment/form-current-employment.component.html

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,42 @@ <h3 i18n="@@register.currentEmployment" class="orc-font-body margin-top-12">
33
Current employment
44
</h3>
55

6-
<!-- <div class="announce" *ngIf="affiliationFound">
6+
<div class="announce" *ngIf="rorIdHasBeenMatched">
77
<div>
8-
<img src="/assets/vectors/personal-email-icon.svg" aria-hidden="true" />
8+
<img
9+
src="/assets/vectors/registration-affiliation-icon.svg"
10+
aria-hidden="true"
11+
/>
912
</div>
1013
<div class="content">
1114
<div>
12-
<h3 class="orc-font-body" i18n="@@register.thisLooksLikeAPersonalEmail">
15+
<h3 class="orc-font-body" i18n="@@register.affiliationFoud">
1316
Affiliation found
1417
</h3>
1518
</div>
1619
<div>
17-
<ng-container>
18-
Based on your emails we think you are currently affiliated with
19-
</ng-container>
20-
<strong>The University of Bath.</strong>
21-
<ng-container
22-
>We’ve pre-selected this organization for you in the form
23-
below.</ng-container
24-
>
20+
<p class="main-paragraph">
21+
<ng-container i18n="@@register.basedOnYourEmailWeThink">
22+
Based on your emails we think you are currently affiliated with
23+
</ng-container>
24+
<strong>TEST.</strong>
2525

26-
<div>
26+
<ng-container
27+
i18n="
28+
@@register.webePreselectedThisOrganizationForYouInTheFormBelow"
29+
>
30+
We’ve pre-selected this organization for you in the form
31+
below.</ng-container
32+
>
33+
</p>
34+
35+
<div i18n="@@register.whenYouCompleteRegistrationAnEmployment">
2736
When you complete registration an employment affiliation will be
2837
automatically added to your new ORCID record.
2938
</div>
3039
</div>
3140
</div>
32-
</div> -->
41+
</div>
3342

3443
<section id="{{ type }}-organization">
3544
<div
@@ -110,11 +119,14 @@ <h3 class="orc-font-body" i18n="@@register.thisLooksLikeAPersonalEmail">
110119
class="selected-org orc-font-small-print"
111120
*ngIf="selectedOrganizationFromDatabase && displayOrganizationHint"
112121
>
113-
{{ selectedOrganizationFromDatabase.value }},
114122
{{ selectedOrganizationFromDatabase.city
115123
}}<ng-container *ngIf="selectedOrganizationFromDatabase.city"
116124
>,</ng-container
117125
>
126+
{{ selectedOrganizationFromDatabase.region
127+
}}<ng-container *ngIf="selectedOrganizationFromDatabase.region"
128+
>,</ng-container
129+
>
118130
{{ selectedOrganizationFromDatabase.country }}
119131
</div>
120132
<div

src/app/register2/components/form-current-employment/form-current-employment.component.ts

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import {
3030
import { EMPTY, Observable, of } from 'rxjs'
3131
import { RecordAffiliationService } from 'src/app/core/record-affiliations/record-affiliations.service'
3232
import { dateMonthYearValidator } from 'src/app/shared/validators/date/date.validator'
33+
import { RegisterStateService } from '../../register-state.service'
34+
import { OrgDisambiguated } from 'src/app/types'
3335
export class MyErrorStateMatcher implements ErrorStateMatcher {
3436
isErrorState(
3537
control: FormControl | null,
@@ -74,6 +76,7 @@ export class FormCurrentEmploymentComponent extends BaseForm implements OnInit {
7476
requireOrganizationDisambiguatedDataOnRefresh = false
7577
private _type: AffiliationType
7678
affiliationFound = false
79+
rorIdHasBeenMatched: boolean
7780

7881
@Input()
7982
public get type(): AffiliationType {
@@ -104,15 +107,17 @@ export class FormCurrentEmploymentComponent extends BaseForm implements OnInit {
104107
.fill(0)
105108
.map((i, idx) => idx + 1)
106109

107-
organization: string | Organization = ''
110+
organization: string | Organization | OrgDisambiguated = ''
108111
platform: PlatformInfo
109112
isMobile: boolean
113+
rorId: string = 'https://ror.org/036mest28'
110114
constructor(
111115
private _register: Register2Service,
112116
private _platform: PlatformInfoService,
113117
private _liveAnnouncer: LiveAnnouncer,
114118
private _recordAffiliationService: RecordAffiliationService,
115-
private _formBuilder: FormBuilder
119+
private _formBuilder: FormBuilder,
120+
private registerStateService: RegisterStateService
116121
) {
117122
super()
118123
this._platform.get().subscribe((platform) => {
@@ -122,6 +127,19 @@ export class FormCurrentEmploymentComponent extends BaseForm implements OnInit {
122127
}
123128

124129
ngOnInit() {
130+
this.registerStateService.matchOrganization$.subscribe((organization) => {
131+
this.organization = organization
132+
this.form.patchValue({
133+
organization: organization,
134+
})
135+
this.rorIdHasBeenMatched = !!organization
136+
137+
if (this.rorIdHasBeenMatched) {
138+
this.form.controls.organization.markAsTouched()
139+
} else {
140+
this.form.controls.organization.markAsUntouched()
141+
}
142+
})
125143
this.form = new UntypedFormGroup({
126144
organization: new UntypedFormControl(this.organization, {
127145
validators: [
@@ -212,8 +230,12 @@ export class FormCurrentEmploymentComponent extends BaseForm implements OnInit {
212230
)
213231
}
214232

215-
autoCompleteDisplayOrganization(organization: Organization) {
216-
return organization.value
233+
autoCompleteDisplayOrganization(
234+
organization: Organization | string | OrgDisambiguated
235+
) {
236+
if (typeof organization === 'object') {
237+
return organization.value
238+
}
217239
}
218240

219241
private _filter(value: string): Observable<Organization[]> {

src/app/register2/components/form-personal/form-personal.component.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ <h3 i18n="@@register.yourNames" class="orc-font-body margin-top-12">
6767
[placeholder]="labelFamilyNamePlaceholder"
6868
/>
6969
</mat-form-field>
70+
<mat-error
71+
*ngIf="form.hasError('maxlength', 'familyNames')"
72+
i18n="@@topBar.keywordMaxLength"
73+
>
74+
Must be less than 100 characters
75+
</mat-error>
7076
<mat-error
7177
*ngIf="
7278
familyNamesFormTouched && form.hasError('illegalName', 'familyNames')

src/app/register2/components/form-personal/form-personal.component.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import { SnackbarService } from 'src/app/cdk/snackbar/snackbar.service'
4646
import { SignInService } from 'src/app/core/sign-in/sign-in.service'
4747
import { ErrorHandlerService } from 'src/app/core/error-handler/error-handler.service'
4848
import { ERROR_REPORT } from 'src/app/errors'
49+
import { RegisterStateService } from '../../register-state.service'
4950
export class MyErrorStateMatcher implements ErrorStateMatcher {
5051
isErrorState(
5152
control: FormControl | null,
@@ -111,6 +112,7 @@ export class FormPersonalComponent extends BaseForm implements OnInit {
111112
private _snackbar: SnackbarService,
112113
private _signIn: SignInService,
113114
private _errorHandler: ErrorHandlerService,
115+
private _registerStateService: RegisterStateService,
114116
@Inject(WINDOW) private window: Window
115117
) {
116118
super()
@@ -146,6 +148,19 @@ export class FormPersonalComponent extends BaseForm implements OnInit {
146148
}
147149
)
148150

151+
this.additionalEmails.controls[0].valueChanges
152+
.pipe(
153+
debounceTime(1000),
154+
filter(() => !this.additionalEmails.controls[0].errors),
155+
switchMap((value) => {
156+
const emailDomain = value.split('@')[1]
157+
return this._register.getEmailCategory(emailDomain)
158+
})
159+
)
160+
.subscribe((value) => {
161+
this._registerStateService.setRorAffiliationFound(value.rorId, true)
162+
})
163+
149164
this.emails.controls['email'].valueChanges
150165
.pipe(
151166
debounceTime(1000),
@@ -159,6 +174,7 @@ export class FormPersonalComponent extends BaseForm implements OnInit {
159174
this.professionalEmail = value.category === 'PROFESSIONAL'
160175
this.personalEmail = value.category === 'PERSONAL'
161176
this.undefinedEmail = value.category === 'UNDEFINED'
177+
this._registerStateService.setRorAffiliationFound(value.rorId)
162178
})
163179

164180
if (!this.reactivation?.isReactivation) {
@@ -180,7 +196,10 @@ export class FormPersonalComponent extends BaseForm implements OnInit {
180196
asyncValidators: this._register.backendValueValidate('givenNames'),
181197
}),
182198
familyNames: new UntypedFormControl('', {
183-
validators: [OrcidValidators.illegalName],
199+
validators: [
200+
OrcidValidators.illegalName,
201+
Validators.maxLength(this.maxNameLenght),
202+
],
184203
}),
185204
emails: this.emails,
186205
})

src/app/register2/components/form-terms/form-terms.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ <h3 class="orc-font-body" i18n="@@register.termsOfUse">Terms of Use</h3>
55
(form.hasError('required', 'termsOfUse') ||
66
form.hasError('required', 'dataProcessed'))
77
"
8-
i18n="@@register.youMustAccept"
9-
>You must accept the terms we use and consent to your data being processed in
8+
i18n="@@register.youMustAccept2"
9+
>You must accept the terms of use and consent to your data being processed in
1010
the United States</mat-error
1111
>
1212

src/app/register2/components/register2.style.scss

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,18 @@ mat-label.orc-font-small-print {
6161
.step-actions {
6262
border-top: 1px solid;
6363
padding-top: 32px;
64-
a {
65-
font-style: italic;
64+
65+
button {
66+
height: 40px;
67+
font-size: 16px;
68+
a {
69+
font-style: italic;
70+
font-size: 14px;
71+
}
72+
a.skip-step {
73+
font-style: normal;
74+
font-size: 14px;
75+
}
6676
}
6777
}
6878
.columns-12 {
@@ -150,6 +160,9 @@ mat-label.orc-font-small-print {
150160

151161
.info,
152162
.announce {
163+
.main-paragraph {
164+
margin-bottom: 16px;
165+
}
153166
.content div:not(:last-child) {
154167
margin-bottom: 16px;
155168
}
@@ -222,7 +235,7 @@ mat-label.orc-font-small-print {
222235
justify-content: space-between;
223236
width: 100%;
224237
margin-top: 29px;
225-
gap: 12px;
238+
gap: 16px;
226239
}
227240
}
228241
}

src/app/register2/components/step-c2/step-c2.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ <h2 class="orc-font-body-small" i18n="@@register.step3.3">
7272
id="step-c-back-button"
7373
(click)="optionalNextStep()"
7474
>
75-
<a i18n="@@shared.skipThisStepWithoutAddingAnAffiliation">
75+
<a i18n="@@shared.skipThisStepWithoutAddingAnAffiliation" class="skip-step">
7676
Skip this step without adding an affiliation</a
7777
>
7878
</button>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { TestBed } from '@angular/core/testing';
2+
3+
import { RegisterStateService } from './register-state.service';
4+
5+
describe('RegisterStateService', () => {
6+
let service: RegisterStateService;
7+
8+
beforeEach(() => {
9+
TestBed.configureTestingModule({
10+
providers: [{
11+
provide: RegisterStateService,
12+
useValue: {}
13+
}]
14+
});
15+
service = TestBed.inject(RegisterStateService);
16+
});
17+
18+
it('should be created', () => {
19+
expect(service).toBeTruthy();
20+
});
21+
});
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import { Injectable } from '@angular/core'
2+
import { OrganizationsService } from '../core'
3+
import { Organization } from 'src/app/types/record-affiliation.endpoint'
4+
import { Subject } from 'rxjs'
5+
import { OrgDisambiguated } from '../types'
6+
@Injectable({
7+
providedIn: 'root',
8+
})
9+
export class RegisterStateService {
10+
rorIdHasBeenMatched: boolean = false
11+
matchOrganization$ = new Subject<string | Organization>()
12+
primaryEmailMatched: Organization
13+
secondaryEmail: Organization
14+
constructor(private _organizationsService: OrganizationsService) {}
15+
16+
setRorAffiliationFound(affiliationFound: string, additionalEmail = false) {
17+
if (!!affiliationFound) {
18+
this._organizationsService
19+
.getOrgDisambiguated('ROR', affiliationFound)
20+
.subscribe((affiliation) => {
21+
this.rorIdHasBeenMatched = true
22+
if (!additionalEmail) {
23+
this.primaryEmailMatched =
24+
this.affiliationToOrganization(affiliation)
25+
} else {
26+
this.secondaryEmail = this.affiliationToOrganization(affiliation)
27+
}
28+
29+
this.updateTheAffiliationMatch()
30+
})
31+
} else {
32+
if (!additionalEmail) {
33+
this.primaryEmailMatched = null
34+
} else {
35+
this.secondaryEmail = null
36+
}
37+
this.updateTheAffiliationMatch()
38+
}
39+
}
40+
41+
private affiliationToOrganization(
42+
affiliation: OrgDisambiguated
43+
): Organization {
44+
return {
45+
value: affiliation.value,
46+
city: affiliation.city,
47+
region: affiliation.region,
48+
country: affiliation.country,
49+
disambiguatedAffiliationIdentifier:
50+
affiliation.disambiguatedAffiliationIdentifier,
51+
sourceId: affiliation.sourceId,
52+
} as Organization
53+
}
54+
55+
private updateTheAffiliationMatch() {
56+
if (this.primaryEmailMatched) {
57+
this.rorIdHasBeenMatched = true
58+
this.matchOrganization$.next(this.primaryEmailMatched)
59+
} else if (this.secondaryEmail) {
60+
this.rorIdHasBeenMatched = true
61+
this.matchOrganization$.next(this.secondaryEmail)
62+
} else {
63+
this.rorIdHasBeenMatched = false
64+
this.matchOrganization$.next('')
65+
}
66+
}
67+
}

src/app/types/register.email-category.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ export type EmailCategory = 'PROFESSIONAL' | 'PERSONAL' | 'UNDEFINED'
22

33
export interface EmailCategoryEndpoint {
44
category: EmailCategory
5+
rorId: string
56
}
Lines changed: 4 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)