Skip to content

Commit

Permalink
Merge branch 'main' into fix-invalid-date-label
Browse files Browse the repository at this point in the history
  • Loading branch information
auumgn authored Mar 19, 2024
2 parents 5b91f45 + a0d5f62 commit c1505d6
Show file tree
Hide file tree
Showing 18 changed files with 3,863 additions and 692 deletions.
347 changes: 235 additions & 112 deletions ui/src/app/affiliation/affiliation-detail.component.html

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion ui/src/app/affiliation/affiliation-detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ORCID_BASE_URL } from '../app.constants'
import { ActivatedRoute } from '@angular/router'
import { UserService } from '../user/service/user.service'
import { faPencilAlt, faArrowLeft } from '@fortawesome/free-solid-svg-icons'
import { DateUtilService } from '../shared/service/date-util.service'

@Component({
selector: 'app-affiliation-detail',
Expand All @@ -15,15 +16,28 @@ export class AffiliationDetailComponent implements OnInit {
ownerId: string | undefined
faPencilAlt = faPencilAlt
faArrowLeft = faArrowLeft
startDate: string | undefined
endDate: string | undefined

constructor(
protected activatedRoute: ActivatedRoute,
protected userService: UserService
protected userService: UserService,
protected dateUtilService: DateUtilService
) {}

ngOnInit() {
this.activatedRoute.data.subscribe(({ affiliation }) => {
this.affiliation = affiliation
this.startDate = this.dateUtilService.formatDate({
year: affiliation.startYear,
month: affiliation.startMonth,
day: affiliation.startDay,
})
this.endDate = this.dateUtilService.formatDate({
year: affiliation.endYear,
month: affiliation.endMonth,
day: affiliation.endDay,
})
this.userService.find(this.affiliation!.ownerId!).subscribe((user) => {
this.ownerId = user.email
})
Expand Down
100 changes: 46 additions & 54 deletions ui/src/app/affiliation/affiliation-update.component.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions ui/src/app/affiliation/affiliation-update.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ export class AffiliationUpdateComponent implements OnInit {
roleTitle: assertion.roleTitle,
url: assertion.url,
startYear: assertion.startYear,
startMonth: parseInt(assertion.startMonth || '0'),
startMonth: parseInt(assertion.startMonth || '') || null,
startDay: assertion.startDay,
endYear: assertion.endYear,
endMonth: parseInt(assertion.endMonth || '0'),
endMonth: parseInt(assertion.endMonth || '') || null,
endDay: assertion.endDay,
orgName: assertion.orgName,
orgCountry: assertion.orgCountry,
Expand Down
18 changes: 9 additions & 9 deletions ui/src/app/affiliation/affiliations.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -174,23 +174,23 @@ <h1 id="page-heading" class="mt-3" i18n="@@gatewayApp.assertionServiceAssertion.
><br />
<span *ngIf="affiliation.departmentName">{{ affiliation.departmentName }}</span
><span *ngIf="affiliation.roleTitle"> ({{ affiliation.roleTitle }})</span><br />
<span *ngIf="affiliation.startYear">{{ affiliation.startYear }}</span
><span *ngIf="affiliation.startMonth">-{{ affiliation.startMonth }}</span
><span *ngIf="affiliation.startDay">-{{ affiliation.startDay }}</span>
<span *ngIf="affiliation.startYear"
>{{ formatDate(affiliation.startYear, affiliation.startMonth, affiliation.startDay) }}
</span>
<span
*ngIf="affiliation.startYear && affiliation.endYear"
i18n="@@gatewayApp.assertionServiceaffiliation.dateRange.string"
i18n="@@gatewayApp.assertionServiceAssertion.dateRange.string"
>to</span
>
<span *ngIf="affiliation.endYear">{{ affiliation.endYear }}</span
><span *ngIf="affiliation.endMonth">-{{ affiliation.endMonth }}</span
><span *ngIf="affiliation.endDay">-{{ affiliation.endDay }} </span> <br /><a
<span *ngIf="affiliation.endYear">
{{ formatDate(affiliation.endYear, affiliation.endMonth, affiliation.endDay) }}</span
><br /><a
i18n="@@gatewayApp.assertionServiceAssertion.details.string"
[routerLink]="['/affiliations', affiliation.id, 'view']"
>View details</a
>
</td>
<td>{{ affiliation.created?.toString() | date: 'medium' }}</td>
<td>{{ affiliation.created?.toDate() | date: 'medium' : 'en-US' }}</td>
<td class="assertion-status" *ngIf="affiliation.prettyStatus">
<span>{{ affiliation.prettyStatus | localize }}</span>
<div
Expand Down Expand Up @@ -252,4 +252,4 @@ <h1 id="page-heading" class="mt-3" i18n="@@gatewayApp.assertionServiceAssertion.
</div>
</div>
</div>
<router-outlet name="popup"></router-outlet>
<router-outlet name="popup"></router-outlet>
14 changes: 13 additions & 1 deletion ui/src/app/affiliation/affiliations.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { AccountService } from '../account'
import { AlertService } from '../shared/service/alert.service'
import { ActivatedRoute, Router } from '@angular/router'
import { EventService } from '../shared/service/event.service'
import { DateUtilService } from '../shared/service/date-util.service'

@Component({
selector: 'app-affiliations',
Expand All @@ -47,6 +48,8 @@ export class AffiliationsComponent implements OnInit, OnDestroy {
ascending: any
orcidBaseUrl: string | undefined = ORCID_BASE_URL
itemCount: string | undefined
startDate: string | undefined
endDate: string | undefined
faChartBar = faChartBar
faFileDownload = faFileDownload
faFileImport = faFileImport
Expand All @@ -71,7 +74,8 @@ export class AffiliationsComponent implements OnInit, OnDestroy {
protected activatedRoute: ActivatedRoute,
protected router: Router,
protected eventService: EventService,
protected translate: LanguageService
protected translate: LanguageService,
protected dateUtilService: DateUtilService
) {
this.itemsPerPage = ITEMS_PER_PAGE
}
Expand Down Expand Up @@ -137,6 +141,14 @@ export class AffiliationsComponent implements OnInit, OnDestroy {
this.loadAll()
}

formatDate(year?: string, month?: string, day?: string) {
return this.dateUtilService.formatDate({
year,
month,
day,
})
}

clear() {
this.page = 0
this.router.navigate([
Expand Down
16 changes: 16 additions & 0 deletions ui/src/app/shared/service/date-util.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,20 @@ export class DateUtilService {
}
return days
}

formatDate({ year, month, day }: { year?: string; month?: string; day?: string }): string {
let date = ''
if (year) {
date = year

if (month && parseInt(month) > 0) {
date += `-${month.padStart(2, '0')}`

if (day && parseInt(day) > 0) {
date += `-${day.padStart(2, '0')}`
}
}
}
return date
}
}
Loading

0 comments on commit c1505d6

Please sign in to comment.