Skip to content

Commit

Permalink
Merge pull request #2124 from ORCID/fix/8909-prod-link-to-remove-dupl…
Browse files Browse the repository at this point in the history
…icate-record-section-not-working

Fix/8909 prod link to remove duplicate record section not working
  • Loading branch information
leomendoza123 authored Dec 15, 2023
2 parents 1d105c2 + 172e938 commit b0a196d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
<a
i18n="@@account.accountSettings"
[routerLink]="removeDuplicateUrl"
[queryParams]="{ section: 'remove-duplicate' }"
fragment="remove-duplicate"
class="underline"
id="cy-remove-duplicated-record"
>Account settings > Remove duplicate record
</a>
</p>
</p>
<p>
<a
href="https://support.orcid.org/hc/en-us/articles/360006896634"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
OnInit,
Output,
} from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router'
import { Subject } from 'rxjs'
import { takeUntil } from 'rxjs/operators'
import { PlatformInfoService } from 'src/app/cdk/platform-info'
Expand All @@ -30,7 +31,8 @@ export class SettingsActionsDeactivateComponent implements OnInit, OnDestroy {
constructor(
private _platform: PlatformInfoService,
private _deactivate: AccountActionsDeactivateService,
private _togglz: TogglzService
private _togglz: TogglzService,
private activeRoute: ActivatedRoute,
) {}

ngOnInit(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'

import { SettingsActionsComponent } from './settings-actions.component'
import { WINDOW_PROVIDERS } from 'src/app/cdk/window/window.service'
import { ActivatedRoute } from '@angular/router'
import { of } from 'rxjs'

describe('SettingsActionsComponent', () => {
let component: SettingsActionsComponent
Expand All @@ -10,7 +12,7 @@ describe('SettingsActionsComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [SettingsActionsComponent],
providers: [WINDOW_PROVIDERS],
providers: [WINDOW_PROVIDERS, { provide: ActivatedRoute, useValue: {fragment: of({})} }],
}).compileComponents()
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Component, Inject, OnInit } from '@angular/core'
import { ActivatedRoute } from '@angular/router'
import { set } from 'lodash'
import { WINDOW } from 'src/app/cdk/window'

@Component({
Expand All @@ -18,10 +20,28 @@ export class SettingsActionsComponent implements OnInit {
settingDownloadLoading = false
settingDuplicatedRecordLoading = false
settingDeactivateLoading = false
constructor(@Inject(WINDOW) private _window: Window) {}
constructor(
@Inject(WINDOW) private _window: Window,
private activeRoute: ActivatedRoute
) {}

ngOnInit(): void {
const hash = this._window.location.hash.substr(1)
this.displayPanelByHashName(hash)
this.activeRoute.fragment.subscribe((fragment) => {
if (fragment === 'remove-duplicate') {
const element = this._window.document.querySelector('#cy-remove-duplicate-panel')
this.displayPanelByHashName(fragment)
setTimeout(() => {
if (element) {
element.scrollIntoView()
}
})
}
})
}

private displayPanelByHashName(hash: string) {
switch (hash) {
case 'download-data':
this.settingDownload = true
Expand Down

0 comments on commit b0a196d

Please sign in to comment.