Skip to content

Commit b3d5331

Browse files
committed
ENGAGE-243
1 parent 76348b3 commit b3d5331

6 files changed

Lines changed: 99 additions & 62 deletions

File tree

src/app/core/record-works/record-works.service.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -556,9 +556,19 @@ export class RecordWorksService {
556556
}
557557

558558
loadWorkImportWizardList(): Observable<RecordImportWizard[]> {
559-
return this._http.get<RecordImportWizard[]>(
560-
runtimeEnvironment.API_WEB + 'workspace/retrieve-work-import-wizards.json'
561-
)
559+
return this._togglz
560+
.getStateOf(TogglzFlag.SEARCH_AND_LINK_WIZARD_WITH_CERTIFIED_AND_FEATURED_LINKS)
561+
.pipe(
562+
take(1),
563+
switchMap((useNewEndpoint) =>
564+
this._http.get<RecordImportWizard[]>(
565+
runtimeEnvironment.API_WEB +
566+
(useNewEndpoint
567+
? 'workspace/retrieve-search-and-link-wizard.json'
568+
: 'workspace/retrieve-work-import-wizards.json')
569+
)
570+
)
571+
)
562572
}
563573

564574
loadExternalId(

src/app/record/components/search-link-wizard/search-link-wizard.component.html

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,18 @@ <h2 class="orc-font-body-small">
77
>
88
{{ recordImportWizard.name }}
99
</a>
10+
<span
11+
*ngIf="recordImportWizard.isConnected"
12+
class="orc-font-body-small wizard-connected"
13+
i18n="@@works.connected"
14+
>
15+
Connected
16+
</span>
1017
</h2>
1118
<p class="orc-font-body-small">
12-
<ng-container *ngIf="recordImportWizard.description.length > 125">
19+
<ng-container *ngIf="(recordImportWizard.description || recordImportWizard.redirectUriMetadata?.defaultDescription || '').length > 125">
1320
<ng-container *ngIf="!recordImportWizard.show">
14-
{{ recordImportWizard.description.substring(0, 125) + '...' }}
21+
{{ (recordImportWizard.description || recordImportWizard.redirectUriMetadata?.defaultDescription || '').substring(0, 125) + '...' }}
1522
<a
1623
class="underline"
1724
i18n="@@shared.showMore"
@@ -21,7 +28,7 @@ <h2 class="orc-font-body-small">
2128
</a>
2229
</ng-container>
2330
<ng-container *ngIf="recordImportWizard.show">
24-
{{ recordImportWizard.description }}
31+
{{ recordImportWizard.description || recordImportWizard.redirectUriMetadata?.defaultDescription || '' }}
2532
<br />
2633
<a
2734
class="underline"
@@ -32,8 +39,8 @@ <h2 class="orc-font-body-small">
3239
</a>
3340
</ng-container>
3441
</ng-container>
35-
<ng-container *ngIf="recordImportWizard.description.length < 125">
36-
{{ recordImportWizard.description }}
42+
<ng-container *ngIf="(recordImportWizard.description || recordImportWizard.redirectUriMetadata?.defaultDescription || '').length <= 125">
43+
{{ recordImportWizard.description || recordImportWizard.redirectUriMetadata?.defaultDescription || '' }}
3744
</ng-container>
3845
</p>
3946
</div>

src/app/record/components/search-link-wizard/search-link-wizard.component.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,19 @@ export class SearchLinkWizardComponent implements OnInit {
1515
ngOnInit(): void {}
1616

1717
openImportWizardUrlFilter(client: RecordImportWizard): string {
18-
if (client.status === 'RETIRED') {
19-
return client.clientWebsite
20-
} else {
21-
return (
22-
runtimeEnvironment.BASE_URL +
23-
'oauth/authorize' +
24-
'?client_id=' +
25-
client.id +
26-
'&response_type=code&scope=' +
27-
client.scopes +
28-
'&redirect_uri=' +
29-
client.redirectUri
30-
)
18+
if (client.isConnected || client.status === 'RETIRED') {
19+
return client.clientWebsite || '#'
3120
}
21+
return (
22+
runtimeEnvironment.BASE_URL +
23+
'oauth/authorize' +
24+
'?client_id=' +
25+
client.id +
26+
'&response_type=code&scope=' +
27+
encodeURIComponent(client.scopes) +
28+
'&redirect_uri=' +
29+
encodeURIComponent(client.redirectUri)
30+
)
3231
}
3332

3433
toggle(recordImportWizard: RecordImportWizard) {

src/app/record/components/work-stack-group/modals/work-search-link-modal/modal-works-search-link.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ <h3>
3232
</h3>
3333
<hr />
3434
</div>
35-
<div class="row search-link-options">
35+
<div class="row search-link-options" *ngIf="!useNewSearchLinkUi">
3636
<div class="select">
3737
<div class="title">
3838
<label class="mat-caption">

src/app/record/components/work-stack-group/modals/work-search-link-modal/modal-works-search-link.component.ts

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { Component, OnDestroy, OnInit } from '@angular/core'
22
import { Subject } from 'rxjs'
33
import { MatDialogRef } from '@angular/material/dialog'
4-
import { takeUntil } from 'rxjs/operators'
4+
import { take, takeUntil } from 'rxjs/operators'
55
import { RecordImportWizard } from '../../../../../types/record-peer-review-import.endpoint'
66
import { ModalComponent } from '../../../../../cdk/modal/modal/modal.component'
77
import { RecordWorksService } from '../../../../../core/record-works/record-works.service'
8+
import { TogglzService } from '../../../../../core/togglz/togglz.service'
9+
import { TogglzFlag } from '../../../../../types/config.endpoint'
810
import { sortBy } from 'lodash'
911

1012
@Component({
@@ -19,72 +21,80 @@ export class ModalWorksSearchLinkComponent implements OnInit, OnDestroy {
1921
loadingWorks = true
2022
recordImportWizardsOriginal: RecordImportWizard[]
2123
recordImportWizards: RecordImportWizard[]
22-
workTypes = []
23-
geographicalAreas = []
24+
workTypes: string[] = []
25+
geographicalAreas: string[] = []
2426
workTypeSelected = 'All'
2527
geographicalAreaSelected = 'All'
2628
total = 0
29+
/** When true, use new search-and-link endpoint and UI (no work type/geo filters, show isConnected). */
30+
useNewSearchLinkUi = false
2731

2832
constructor(
2933
public dialogRef: MatDialogRef<ModalComponent>,
30-
private _recordWorksService: RecordWorksService
34+
private _recordWorksService: RecordWorksService,
35+
private _togglz: TogglzService
3136
) {}
3237

3338
ngOnInit(): void {
34-
this.loadWorkImportWizardList()
39+
this._togglz
40+
.getStateOf(TogglzFlag.SEARCH_AND_LINK_WIZARD_WITH_CERTIFIED_AND_FEATURED_LINKS)
41+
.pipe(take(1), takeUntil(this.$destroy))
42+
.subscribe((enabled) => {
43+
this.useNewSearchLinkUi = enabled
44+
this.loadWorkImportWizardList()
45+
})
3546
}
3647

3748
loadWorkImportWizardList(): void {
3849
this._recordWorksService
3950
.loadWorkImportWizardList()
4051
.pipe(takeUntil(this.$destroy))
4152
.subscribe((recordImportWizards) => {
53+
recordImportWizards.forEach((w) => (w.show = w.show ?? false))
4254
this.recordImportWizardsOriginal = sortBy(recordImportWizards, 'name')
43-
this.recordImportWizards = this.recordImportWizardsOriginal
55+
this.recordImportWizards = [...this.recordImportWizardsOriginal]
4456
recordImportWizards.forEach((recordImportWizard) => {
45-
recordImportWizard.actTypes.forEach((actType) => {
57+
recordImportWizard.actTypes?.forEach((actType) => {
4658
if (!this.workTypes.includes(actType)) {
4759
this.workTypes.push(actType)
4860
}
4961
})
50-
51-
recordImportWizard.geoAreas.forEach((geoArea) => {
62+
recordImportWizard.geoAreas?.forEach((geoArea) => {
5263
if (!this.geographicalAreas.includes(geoArea)) {
5364
this.geographicalAreas.push(geoArea)
5465
}
5566
})
5667
})
5768
this.loadingWorks = false
58-
5969
this.total = this.recordImportWizardsOriginal.length
6070
})
6171
}
6272

6373
searchAndLink() {
64-
this.recordImportWizards = []
65-
this.recordImportWizardsOriginal.forEach((recordImportWizard) => {
66-
if (
67-
this.workTypeSelected === 'All' &&
68-
this.geographicalAreaSelected === 'All'
69-
) {
70-
this.recordImportWizards = this.recordImportWizardsOriginal
71-
} else if (
72-
this.workTypeSelected === 'All' &&
73-
recordImportWizard.geoAreas.includes(this.geographicalAreaSelected)
74-
) {
75-
this.recordImportWizards.push(recordImportWizard)
76-
} else if (
77-
this.geographicalAreaSelected === 'All' &&
78-
recordImportWizard.actTypes.includes(this.workTypeSelected)
79-
) {
80-
this.recordImportWizards.push(recordImportWizard)
81-
} else if (
82-
recordImportWizard.actTypes.includes(this.workTypeSelected) &&
83-
recordImportWizard.geoAreas.includes(this.geographicalAreaSelected)
84-
) {
85-
this.recordImportWizards.push(recordImportWizard)
86-
}
87-
})
74+
if (
75+
this.workTypeSelected === 'All' &&
76+
this.geographicalAreaSelected === 'All'
77+
) {
78+
this.recordImportWizards = [...this.recordImportWizardsOriginal]
79+
} else {
80+
this.recordImportWizards = this.recordImportWizardsOriginal.filter(
81+
(recordImportWizard) => {
82+
const matchWorkType =
83+
this.workTypeSelected === 'All' ||
84+
(recordImportWizard.actTypes?.length
85+
? recordImportWizard.actTypes.includes(this.workTypeSelected)
86+
: true)
87+
const matchGeo =
88+
this.geographicalAreaSelected === 'All' ||
89+
(recordImportWizard.geoAreas?.length
90+
? recordImportWizard.geoAreas.includes(
91+
this.geographicalAreaSelected
92+
)
93+
: true)
94+
return matchWorkType && matchGeo
95+
}
96+
)
97+
}
8898
this.total = this.recordImportWizards.length
8999
}
90100

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
1+
export type RecordImportWizardMetadataType = 'Featured' | 'Default' | 'Certified'
2+
3+
export interface RecordImportWizardMetadata {
4+
type?: RecordImportWizardMetadataType
5+
index?: number
6+
defaultDescription?: string
7+
logoUrl?: string
8+
}
9+
110
export interface RecordImportWizard {
2-
actTypes: string[]
3-
clientWebsite: string
4-
description: string
5-
geoAreas: string[]
11+
actTypes?: string[]
12+
clientWebsite?: string
13+
description?: string
14+
geoAreas?: string[]
615
id: string
16+
isConnected?: boolean
717
name: string
818
redirectUri: string
19+
redirectUriMetadata?: RecordImportWizardMetadata
920
scopes: string
10-
status: string
11-
show: boolean
21+
status?: string
22+
show?: boolean
1223
}

0 commit comments

Comments
 (0)