Skip to content

Commit

Permalink
Merge branch 'add-timestamps-to-dates' of https://github.com/ORCID/or…
Browse files Browse the repository at this point in the history
…cid-angular into add-timestamps-to-dates
  • Loading branch information
auumgn committed Jul 24, 2024
2 parents 4386a29 + dd300d7 commit f8b5310
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v2.102.9 - 2024-07-24

[Full Changelog](https://github.com/ORCID/orcid-angular/compare/v2.102.8...v2.102.9)

## v2.102.8 - 2024-07-24

[Full Changelog](https://github.com/ORCID/orcid-angular/compare/v2.102.7...v2.102.8)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,10 @@ <h2 class="orc-font-body-large" i18n="@@side-bar.emailAddressesUppercase">
<mat-select
outline="black"
[aria-label]="ariaLabelSelect"
[attr.disabled]="hasOneEmailAddress()"
[attr.disabled]="!hasVerifiedEmailAddress()"
(selectionChange)="makePrimary($event.value)"
[ngClass]="{
'disabled-select-notifications-email': hasOneEmailAddress()
'disabled-select-notifications-email': !hasVerifiedEmailAddress()
}"
placeholder=" {{ primaryEmail?.value }}"
[(value)]="primaryEmail"
Expand Down
14 changes: 9 additions & 5 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 @@ -247,12 +247,17 @@ export class ModalEmailComponent implements OnInit, OnDestroy {
}

setNextEmailAsPrimary() {
const verifiedEmails = this.emails.filter((email) => email.verified)
const currentIndex = verifiedEmails.findIndex(
let emails = this.emails.filter((email) => email.verified)
// If there are no verified emails left, set any next email as primary
// we're counting the one being deleted
if (emails.length <= 1) {
emails = this.emails
}
const currentIndex = emails.findIndex(
(value) => value.putCode === this.primaryEmail.putCode
)
const nextIndex = (currentIndex + 1) % verifiedEmails.length
const nextEmail = verifiedEmails[nextIndex]
const nextIndex = (currentIndex + 1) % emails.length
const nextEmail = emails[nextIndex]
this.makePrimary(nextEmail)
}

Expand Down Expand Up @@ -402,7 +407,6 @@ export class ModalEmailComponent implements OnInit, OnDestroy {
if (controlKey === this.primaryEmail?.putCode) {
this.setNextEmailAsPrimary()
}

const i = this.emails.findIndex((value) => value.putCode === controlKey)
this.emails.splice(i, 1)
this.emailsForm.removeControl(controlKey)
Expand Down

0 comments on commit f8b5310

Please sign in to comment.