-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
caeff88
commit b73f0b6
Showing
21 changed files
with
617 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "chrome", | ||
"request": "launch", | ||
"name": "Launch Chrome ORCID Angular", | ||
"url": "http://localhost:4200", | ||
"webRoot": "${workspaceFolder}" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
src/app/record/components/record-header/record-header.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<mat-progress-bar *ngIf="loadingUserRecord" mode="indeterminate" color="accent"></mat-progress-bar> | ||
<div class="row record-header" [ngClass]="{ 'mobile': !platform.columns12 }"> | ||
<section [id]="'names'" role="region" [attr.aria-label]="regionNames"> | ||
<div class="names-wrapper" *ngIf="userRecord?.names || userRecord?.otherNames"> | ||
<div class="row names"> | ||
<h1 [ngClass]="{ | ||
'orc-font-heading-small': !platform.columns12, | ||
'orc-font-heading': platform.columns12 | ||
}"> | ||
<ng-container *ngIf="creditName">{{ creditName }}</ng-container> | ||
<ng-container *ngIf="!!!creditName && (givenNames || familyName)"> | ||
<ng-container *ngIf="givenNames">{{ givenNames + ' ' }}</ng-container> | ||
{{ familyName }} | ||
</ng-container> | ||
</h1> | ||
</div> | ||
<div class="row other-names" [ngClass]="{ 'mobile': !platform.columns12 }"> | ||
<p class="orc-font-body" *ngIf="otherNames">{{ otherNames }}</p> | ||
</div> | ||
</div> | ||
<div class="issue" *ngIf="userInfo?.RECORD_WITH_ISSUES"> | ||
<h1 [ngClass]="{ | ||
'orc-font-heading-small': !platform.columns12, | ||
'orc-font-heading': platform.columns12 | ||
}"> | ||
<ng-container *ngIf="userInfo.IS_DEACTIVATED === 'true' && !userInfo.PRIMARY_RECORD" | ||
i18n="@@summary.recordIsDeactivated">This record has been deactivated | ||
</ng-container> | ||
<ng-container | ||
*ngIf="userInfo.IS_LOCKED === 'true' && !(userInfo.IS_DEACTIVATED === 'true' && !userInfo.PRIMARY_RECORD)" | ||
i18n="@@summary.recordIsLocked">This record is locked | ||
</ng-container> | ||
<ng-container *ngIf="userInfo.PRIMARY_RECORD" i18n="@@summary.recordIsDeprecated">This record has been | ||
deprecated</ng-container> | ||
</h1> | ||
</div> | ||
<div class="no-public-information" | ||
*ngIf="!recordWithIssues && affiliations === 0 && !(!!!creditName && (givenNames || familyName))"> | ||
<h1 [ngClass]="{ | ||
'orc-font-heading-small': !platform.columns12, | ||
'orc-font-heading': platform.columns12 | ||
}"> | ||
<ng-container i18n="@@record.noPublicInfo">No public information available. | ||
</ng-container> | ||
</h1> | ||
</div> | ||
</section> | ||
<mat-divider class="divider"></mat-divider> | ||
<section [id]="'orcid-id'" role="region" [attr.aria-label]="regionOrcidId"> | ||
<div class="row id-wrapper"> | ||
<div class="col" [ngClass]="{ | ||
'orc-font-body-small': !platform.columns12, | ||
'orc-font-body': platform.columns12 | ||
}" dir="ltr"> | ||
<div> | ||
<img class="orcid-logo" [ngClass]="{ mobile: !platform.columns12 }" src="assets/vectors/orcid.logo.icon.svg" | ||
alt="orcid logo" /> | ||
</div> | ||
<h2 [ngClass]="{ | ||
'orc-font-body': !platform.columns12, | ||
'orc-font-body-large': platform.columns12 | ||
}">{{ orcidId }}</h2> | ||
<div class="buttons-wrapper" [ngClass]="{ | ||
row: !platform.columns12, | ||
mobile: !platform.columns12 | ||
}"> | ||
<button mat-icon-button class="orc-font-small-print" [matTooltip]="tooltipCopy" | ||
[attr.aria-label]="ariaLabelCopyOrcidId" (click)="clipboard()"> | ||
<mat-icon class="material-icons" class="icon">content_copy</mat-icon> | ||
</button> | ||
<button mat-icon-button class="orc-font-small-print" [matTooltip]="tooltipPrintableVersion" | ||
[attr.aria-label]="ariaLabelViewPrintable" (click)="printRecord()"> | ||
<mat-icon class="material-icons" class="icon">print</mat-icon> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
</div> |
75 changes: 75 additions & 0 deletions
75
src/app/record/components/record-header/record-header.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
.record-header { | ||
display: flex; | ||
box-sizing: border-box; | ||
width: 100%; | ||
padding: 32px; | ||
margin-bottom: 32px; | ||
align-items: flex-start; | ||
gap: 16px; | ||
word-break: break-all; | ||
|
||
h1,p { | ||
margin: 0; | ||
} | ||
|
||
h2 { | ||
margin: auto; | ||
font-weight: normal; | ||
} | ||
|
||
.divider { | ||
width: 100%; | ||
height: 2px; | ||
} | ||
|
||
.names-wrapper { | ||
.names { | ||
line-height: 40px; | ||
} | ||
|
||
.other-names { | ||
line-height: 24px; | ||
} | ||
|
||
.other-names.mobile { | ||
justify-content: center; | ||
} | ||
} | ||
|
||
.issue { | ||
h1 { | ||
font-weight: normal; | ||
} | ||
} | ||
|
||
.id-wrapper { | ||
align-items: center; | ||
|
||
.col { | ||
padding: 0 !important | ||
} | ||
|
||
.orcid-logo { | ||
width: 40px; | ||
margin-right: 8px; | ||
} | ||
|
||
.orcid-logo.mobile { | ||
width: 32px; | ||
} | ||
|
||
.buttons-wrapper { | ||
margin-left: 16px; | ||
} | ||
|
||
.buttons-wrapper.mobile { | ||
justify-content: center; | ||
margin-left: 0; | ||
} | ||
} | ||
} | ||
|
||
.record-header.mobile { | ||
justify-content: center; | ||
padding: 18px; | ||
} |
25 changes: 25 additions & 0 deletions
25
src/app/record/components/record-header/record-header.component.scss-theme.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
@use '@angular/material' as mat; | ||
@import 'src/assets/scss/material.orcid-theme.scss'; | ||
|
||
@mixin top-bar-public-names-theme($theme) { | ||
$primary: map-get($theme, primary); | ||
$accent: map-get($theme, accent); | ||
$warn: map-get($theme, accent); | ||
$foreground: map-get($theme, foreground); | ||
$background: map-get($theme, background); | ||
$config: mat.define-legacy-typography-config(); | ||
|
||
.record-header { | ||
color: $orcid-light-primary-text; | ||
background: mat.get-color-from-palette($primary, 900); | ||
} | ||
|
||
.divider { | ||
background: mat.get-color-from-palette($primary, 700); | ||
} | ||
|
||
.other-names { | ||
color: mat.get-color-from-palette($primary, 50); | ||
} | ||
} | ||
@include top-bar-public-names-theme($orcid-app-theme); |
21 changes: 21 additions & 0 deletions
21
src/app/record/components/record-header/record-header.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { RecordHeaderComponent } from './record-header.component'; | ||
|
||
describe('TopBarPublicNamesComponent', () => { | ||
let component: RecordHeaderComponent; | ||
let fixture: ComponentFixture<RecordHeaderComponent>; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [RecordHeaderComponent] | ||
}); | ||
fixture = TestBed.createComponent(RecordHeaderComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
106 changes: 106 additions & 0 deletions
106
src/app/record/components/record-header/record-header.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import { Component, Inject, Input, OnInit } from '@angular/core'; | ||
import { isEmpty } from 'lodash'; | ||
import { Subject } from 'rxjs'; | ||
import { takeUntil } from 'rxjs/operators'; | ||
import { PlatformInfo, PlatformInfoService } from 'src/app/cdk/platform-info'; | ||
import { WINDOW } from 'src/app/cdk/window'; | ||
import { UserService } from 'src/app/core'; | ||
import { RecordService } from 'src/app/core/record/record.service'; | ||
import { NamesUtil } from 'src/app/shared/utils/names.util'; | ||
import { Assertion, UserInfo } from 'src/app/types'; | ||
import { UserRecord } from 'src/app/types/record.local'; | ||
import { environment } from 'src/environments/environment'; | ||
|
||
@Component({ | ||
selector: 'app-record-header', | ||
templateUrl: './record-header.component.html', | ||
styleUrls: [ | ||
'./record-header.component.scss', | ||
'./record-header.component.scss-theme.scss' | ||
] | ||
}) | ||
export class RecordHeaderComponent implements OnInit { | ||
$destroy: Subject<boolean> = new Subject<boolean>() | ||
@Input() loadingUserRecord = true | ||
@Input() isPublicRecord: string | ||
@Input() affiliations: number | ||
|
||
platform: PlatformInfo | ||
recordWithIssues: boolean | ||
userRecord: UserRecord | ||
userInfo: UserInfo | ||
environment = environment | ||
givenNames = '' | ||
familyName = '' | ||
creditName = '' | ||
otherNames = '' | ||
ariaLabelName = '' | ||
orcidId = '' | ||
|
||
regionNames = $localize`:@@topBar.names:Names` | ||
regionOrcidId = 'Orcid iD' | ||
tooltipPrintableVersion = $localize`:@@topBar.printableRecord:Printable record` | ||
tooltipCopy = $localize`:@@topBar.copyId:Copy iD` | ||
privateName = $localize`:@@account.nameIsPri:Name is private` | ||
|
||
ariaLabelCopyOrcidId = $localize`:@@topBar.ariaLabelCopyOrcidId:Copy your ORCID iD to the clipboard` | ||
ariaLabelViewPrintable = $localize`:@@topBar.ariaLabelViewPrintable:View a printable version of your ORCID record (Opens in new tab)` | ||
|
||
constructor( | ||
@Inject(WINDOW) private window: Window, | ||
private _platform: PlatformInfoService, | ||
private _user: UserService, | ||
private _record: RecordService, | ||
) { } | ||
|
||
ngOnInit(): void { | ||
this.orcidId = 'https:' + environment.BASE_URL + this.isPublicRecord | ||
|
||
this._platform | ||
.get() | ||
.pipe(takeUntil(this.$destroy)) | ||
.subscribe((data) => { | ||
this.platform = data | ||
}) | ||
|
||
this._record | ||
.getRecord({ | ||
publicRecordId: this.isPublicRecord || undefined, | ||
}) | ||
.pipe(takeUntil(this.$destroy)) | ||
.subscribe((userRecord) => { | ||
this.recordWithIssues = userRecord?.userInfo?.RECORD_WITH_ISSUES | ||
this.userRecord = userRecord | ||
this.userInfo = userRecord?.userInfo | ||
|
||
if (!isEmpty(this.userRecord?.names)) { | ||
this.givenNames = NamesUtil.getGivenNames(this.userRecord) | ||
this.familyName = NamesUtil.getFamilyName(this.userRecord) | ||
this.creditName = NamesUtil.getCreditName(this.userRecord) | ||
this.ariaLabelName = NamesUtil.getAriaLabelName(this.userRecord, this.ariaLabelName) | ||
} else { | ||
if (this.affiliations > 0) { | ||
this.creditName = this.privateName | ||
} | ||
} | ||
|
||
if (!isEmpty(this.userRecord.otherNames?.otherNames)) { | ||
this.otherNames = NamesUtil.getOtherNamesUnique(userRecord.otherNames?.otherNames) | ||
} | ||
}) | ||
} | ||
|
||
clipboard() { | ||
this.window.navigator.clipboard.writeText( | ||
this.orcidId | ||
) | ||
} | ||
|
||
printRecord() { | ||
this.window.open( | ||
environment.BASE_URL + | ||
this.userRecord?.userInfo?.EFFECTIVE_USER_ORCID + | ||
'/print' | ||
) | ||
} | ||
} |
Oops, something went wrong.