Skip to content

Commit b3160d4

Browse files
committed
feature: Add SOURCE_SORTING togglz
1 parent 899b7d3 commit b3160d4

6 files changed

+41
-10
lines changed

src/app/record/components/affiliation-stacks-groups/affiliation-stacks-groups.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
[(expandedContent)]="expandedContent['EMPLOYMENT']"
2222
(expandedContentChange)="expandedContentChange.emit(expandedContent)"
2323
[isPublicRecord]="isPublicRecord"
24-
[sortTypes]="['title', 'start', 'end', 'source']"
24+
[sortTypes]="sortTypes"
2525
[sortType]="'end'"
2626
(sort)="sortEvent($event, 'EMPLOYMENT')"
2727
id="cy-affiliation-employment"

src/app/record/components/affiliation-stacks-groups/affiliation-stacks-groups.component.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
UserRecord,
1616
UserRecordOptions,
1717
} from 'src/app/types/record.local'
18-
import { SortData } from 'src/app/types/sort'
18+
import { SortData, SortOrderType } from 'src/app/types/sort'
1919

2020
import { UserInfo } from '../../../types'
2121
import { TogglzService } from '../../../core/togglz/togglz.service'
@@ -54,6 +54,8 @@ export class AffiliationStacksGroupsComponent implements OnInit {
5454
@Output()
5555
expandedContentChange: EventEmitter<MainPanelsState> = new EventEmitter()
5656
professionalActivitiesTogglz = false
57+
sourceSorting = false
58+
sortTypes: SortOrderType[] = ['title', 'start', 'end']
5759

5860
constructor(
5961
private _record: RecordService,
@@ -66,6 +68,10 @@ export class AffiliationStacksGroupsComponent implements OnInit {
6668
.getStateOf('PROFESSIONAL_ACTIVITIES')
6769
.pipe(take(1))
6870
.subscribe((value) => (this.professionalActivitiesTogglz = value))
71+
this._togglz
72+
.getStateOf('SOURCE_SORTING')
73+
.pipe(take(1))
74+
.subscribe((value) => (this.sourceSorting = value))
6975
this.$loading = this._recordAffiliationService.$loading
7076
this._record
7177
.getRecord({
@@ -106,6 +112,9 @@ export class AffiliationStacksGroupsComponent implements OnInit {
106112
}
107113
}
108114
})
115+
if (this.sourceSorting) {
116+
this.sortTypes.push('source')
117+
}
109118
}
110119

111120
trackByProfileAffiliationUiGroups(index, item: AffiliationUIGroup) {

src/app/record/components/funding-stacks-groups/funding-stacks-groups.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
[isPublicRecord]="isPublicRecord"
1616
[(expandedContent)]="expandedContent['FUNDING']"
1717
(expandedContentChange)="expandedContentChange.emit(expandedContent)"
18-
[sortTypes]="['date', 'title', 'type', 'source']"
18+
[sortTypes]="sortTypes"
1919
[sortType]="'date'"
2020
(sort)="sortEvent($event)"
2121
>

src/app/record/components/funding-stacks-groups/funding-stacks-groups.component.ts

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
22
import { Observable, Subject } from 'rxjs'
3-
import { first, takeUntil } from 'rxjs/operators'
3+
import { first, take, takeUntil } from 'rxjs/operators'
44
import { UserService } from 'src/app/core'
55
import { RecordCountriesService } from 'src/app/core/record-countries/record-countries.service'
66
import { RecordService } from 'src/app/core/record/record.service'
@@ -11,10 +11,11 @@ import {
1111
UserRecordOptions,
1212
} from 'src/app/types/record.local'
1313
import { UserSession } from 'src/app/types/session.local'
14-
import { SortData } from 'src/app/types/sort'
14+
import { SortData, SortOrderType } from 'src/app/types/sort'
1515

1616
import { RecordFundingsService } from '../../../core/record-fundings/record-fundings.service'
1717
import { UserInfo } from '../../../types'
18+
import { TogglzService } from '../../../core/togglz/togglz.service'
1819

1920
@Component({
2021
selector: 'app-fundings',
@@ -40,16 +41,26 @@ export class FundingStacksGroupsComponent implements OnInit {
4041
ngOrcidFunding = $localize`:@@shared.funding:Funding`
4142
countryCodes: { key: string; value: string }[]
4243
loading = true
44+
sourceSorting = false
45+
sortTypes: SortOrderType[] = ['title', 'start', 'end']
4346

4447
constructor(
4548
private _userSession: UserService,
4649
private _record: RecordService,
4750
private _recordFundingsService: RecordFundingsService,
48-
private _recordCountryService: RecordCountriesService
51+
private _recordCountryService: RecordCountriesService,
52+
private _togglz: TogglzService
4953
) {}
5054

5155
ngOnInit(): void {
56+
this._togglz
57+
.getStateOf('SOURCE_SORTING')
58+
.pipe(take(1))
59+
.subscribe((value) => (this.sourceSorting = value))
5260
this.getRecord()
61+
if (this.sourceSorting) {
62+
this.sortTypes.push('source')
63+
}
5364
}
5465

5566
private getRecord() {

src/app/record/components/work-stack-group/work-stack-group.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
[isPublicRecord]="isPublicRecord"
1616
[(expandedContent)]="expandedContent['WORK']"
1717
(expandedContentChange)="expandedContentChange.emit(expandedContent)"
18-
[sortTypes]="['date', 'title', 'type', 'source']"
18+
[sortTypes]="sortTypes"
1919
[sortType]="'date'"
2020
[addMenuOptions]="addMenuOptions"
2121
(sort)="sortEvent($event)"

src/app/record/components/work-stack-group/work-stack-group.component.ts

+14-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { MatDialog } from '@angular/material/dialog'
1515
import { MatPaginatorIntl, PageEvent } from '@angular/material/paginator'
1616
import { isEmpty } from 'lodash'
1717
import { Observable, Subject } from 'rxjs'
18-
import { first } from 'rxjs/operators'
18+
import { first, take } from 'rxjs/operators'
1919
import { PlatformInfo, PlatformInfoService } from 'src/app/cdk/platform-info'
2020
import {
2121
ADD_EVENT_ACTION,
@@ -34,7 +34,7 @@ import {
3434
UserRecord,
3535
UserRecordOptions,
3636
} from 'src/app/types/record.local'
37-
import { SortData } from 'src/app/types/sort'
37+
import { SortData, SortOrderType } from 'src/app/types/sort'
3838

3939
import { UserInfo } from '../../../types'
4040
import { ModalDeleteItemsComponent } from '../modals/modal-delete-item/modal-delete-items.component'
@@ -49,6 +49,7 @@ import { WorkBibtexModalComponent } from './modals/work-bibtex-modal/work-bibtex
4949
import { ModalCombineWorksWithSelectorComponent } from '../work/modals/modal-combine-works-with-selector/modal-combine-works-with-selector.component'
5050
import { GroupingSuggestions } from 'src/app/types/works.endpoint'
5151
import { AnnouncerService } from 'src/app/core/announcer/announcer.service'
52+
import { TogglzService } from '../../../core/togglz/togglz.service'
5253

5354
@Component({
5455
selector: 'app-work-stack-group',
@@ -127,6 +128,8 @@ export class WorkStackGroupComponent implements OnInit {
127128
platform: PlatformInfo
128129
selectedWorks: string[] = []
129130
selectAll: false
131+
sourceSorting = false
132+
sortTypes: SortOrderType[] = ['title', 'start', 'end']
130133

131134
@ViewChildren('selectAllCheckbox') selectAllCheckbox: MatCheckbox
132135
@ViewChildren('appWorkStacks') appWorkStacks: QueryList<WorkStackComponent>
@@ -138,10 +141,15 @@ export class WorkStackGroupComponent implements OnInit {
138141
private _record: RecordService,
139142
private _works: RecordWorksService,
140143
private _matPaginatorIntl: MatPaginatorIntl,
141-
private _announce: AnnouncerService
144+
private _announce: AnnouncerService,
145+
private _togglz: TogglzService
142146
) {}
143147

144148
ngOnInit(): void {
149+
this._togglz
150+
.getStateOf('SOURCE_SORTING')
151+
.pipe(take(1))
152+
.subscribe((value) => (this.sourceSorting = value))
145153
this.$loading = this._works.$loading
146154
this._record
147155
.getRecord({ publicRecordId: this.isPublicRecord })
@@ -163,6 +171,9 @@ export class WorkStackGroupComponent implements OnInit {
163171
this._platform.get().subscribe((platform) => {
164172
this.platform = platform
165173
})
174+
if (this.sourceSorting) {
175+
this.sortTypes.push('source')
176+
}
166177
}
167178

168179
private getGroupingSuggestions() {

0 commit comments

Comments
 (0)