Skip to content

Commit

Permalink
display name or orcid id when source id is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
auumgn committed Oct 30, 2024
1 parent e057f29 commit b46dc97
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ <h2 class="orc-font-body-large" i18n="@@side-bar.emailAddressesUppercase">
[name]="
email.professionalEmail
? orcidEmailValidation
: email.sourceName || email.source
: displayName ||
userInfo.EFFECTIVE_USER_ORCID ||
userInfo.REAL_USER_ORCID
"
[isEmailOrDomain]="true"
[date]="
Expand Down
11 changes: 11 additions & 0 deletions src/app/cdk/side-bar/modals/modal-email/modal-email.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ import { ModalComponent } from 'src/app/cdk/modal/modal/modal.component'
import { PlatformInfoService } from 'src/app/cdk/platform-info'
import { SnackbarService } from 'src/app/cdk/snackbar/snackbar.service'
import { RecordEmailsService } from 'src/app/core/record-emails/record-emails.service'
import { RecordNamesService } from 'src/app/core/record-names/record-names.service'
import { TogglzService } from 'src/app/core/togglz/togglz.service'
import { UserInfoService } from 'src/app/core/user-info/user-info.service'
import { RecordUtil } from 'src/app/shared/utils/record.util'
import {
AssertionVisibilityString,
EmailsEndpoint,
Expand Down Expand Up @@ -91,13 +93,15 @@ export class ModalEmailComponent implements OnInit, OnDestroy {
loadingTogglz = false
emailDomainsTogglz = false
disableVisibilities: { [domainPutcode: string]: VisibilityStrings[] } = {}
displayName: string

isMobile: boolean
userInfo: UserInfo

constructor(
public dialogRef: MatDialogRef<ModalComponent>,
public _recordEmails: RecordEmailsService,
private _names: RecordNamesService,
private _changeDetectorRef: ChangeDetectorRef,
private _platform: PlatformInfoService,
private _snackBar: SnackbarService,
Expand All @@ -117,6 +121,13 @@ export class ModalEmailComponent implements OnInit, OnDestroy {
(platform) => (this.isMobile = platform.columns4 || platform.columns8)
)

this._names
.getNames()
.pipe(takeUntil(this.$destroy))
.subscribe((names) => {
this.displayName = RecordUtil.getDisplayName(names)
})

this._recordEmails
.getEmails()
.pipe(
Expand Down
4 changes: 3 additions & 1 deletion src/app/cdk/side-bar/side-bar/side-bar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ <h4 header i18n="@@side-bar.verifiedEmailAddresses">
[name]="
email.professionalEmail
? orcidEmailValidation
: email.sourceName || email.source
: displayName ||
userInfo.EFFECTIVE_USER_ORCID ||
userInfo.REAL_USER_ORCID
"
[isEmailOrDomain]="true"
[date]="
Expand Down
5 changes: 2 additions & 3 deletions src/app/cdk/side-bar/side-bar/side-bar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { RecordService } from 'src/app/core/record/record.service'
import {
Address,
Assertion,
AssertionVisibilityString,
NameForm,
RequestInfoForm,
UserInfo,
Expand Down Expand Up @@ -75,6 +74,7 @@ export class SideBarComponent implements OnInit, OnDestroy {
userInfo: UserInfo
userRecord: UserRecord
platform: PlatformInfo
displayName: string

websiteOpenState = false
keywordOpenState = false
Expand Down Expand Up @@ -138,9 +138,8 @@ export class SideBarComponent implements OnInit, OnDestroy {
this.orcidId = true
}
this.userRecord = userRecord

this.userInfo = userRecord?.userInfo

this.displayName = RecordUtil.getDisplayName(userRecord?.names)
this.onSideBarElementsDisplay(userRecord)
})
}
Expand Down
17 changes: 17 additions & 0 deletions src/app/shared/utils/record.util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { E } from '@angular/cdk/keycodes'
import { Assertion } from 'src/app/types'
import { NamesEndPoint } from 'src/app/types/record-name.endpoint'
import { UserRecord } from 'src/app/types/record.local'

export class RecordUtil {
Expand All @@ -21,6 +22,22 @@ export class RecordUtil {
: ''
}

static getDisplayName(names: NamesEndPoint): string {
if (
names?.creditName &&
names?.creditName.value &&
names?.creditName.value.length
) {
return names.creditName.value
} else {
return (
((names?.givenNames && names?.givenNames.value) || ' ') +
' ' +
((names?.familyName && names?.familyName.value) || ' ')
)
}
}

static isNamePublicAndAffiliations(
userRecord: UserRecord,
affiliations: number
Expand Down

0 comments on commit b46dc97

Please sign in to comment.