diff --git a/src/app/record/components/affiliation-stacks-groups/affiliation-stacks-groups.component.html b/src/app/record/components/affiliation-stacks-groups/affiliation-stacks-groups.component.html index 167ff9144d..4b8b51ebda 100644 --- a/src/app/record/components/affiliation-stacks-groups/affiliation-stacks-groups.component.html +++ b/src/app/record/components/affiliation-stacks-groups/affiliation-stacks-groups.component.html @@ -21,7 +21,7 @@ [(expandedContent)]="expandedContent['EMPLOYMENT']" (expandedContentChange)="expandedContentChange.emit(expandedContent)" [isPublicRecord]="isPublicRecord" - [sortTypes]="['title', 'start', 'end', 'source']" + [sortTypes]="sortTypes" [sortType]="'end'" (sort)="sortEvent($event, 'EMPLOYMENT')" id="cy-affiliation-employment" diff --git a/src/app/record/components/affiliation-stacks-groups/affiliation-stacks-groups.component.ts b/src/app/record/components/affiliation-stacks-groups/affiliation-stacks-groups.component.ts index 98969f2c02..8dc07c6674 100644 --- a/src/app/record/components/affiliation-stacks-groups/affiliation-stacks-groups.component.ts +++ b/src/app/record/components/affiliation-stacks-groups/affiliation-stacks-groups.component.ts @@ -15,7 +15,7 @@ import { UserRecord, UserRecordOptions, } from 'src/app/types/record.local' -import { SortData } from 'src/app/types/sort' +import { SortData, SortOrderType } from 'src/app/types/sort' import { UserInfo } from '../../../types' import { TogglzService } from '../../../core/togglz/togglz.service' @@ -54,6 +54,7 @@ export class AffiliationStacksGroupsComponent implements OnInit { @Output() expandedContentChange: EventEmitter = new EventEmitter() professionalActivitiesTogglz = false + sortTypes: SortOrderType[] = ['title', 'start', 'end'] constructor( private _record: RecordService, @@ -66,6 +67,14 @@ export class AffiliationStacksGroupsComponent implements OnInit { .getStateOf('PROFESSIONAL_ACTIVITIES') .pipe(take(1)) .subscribe((value) => (this.professionalActivitiesTogglz = value)) + this._togglz + .getStateOf('SOURCE_SORTING') + .pipe(take(1)) + .subscribe((sourceSortingTogglz: boolean) => { + if (sourceSortingTogglz) { + this.sortTypes.push('source') + } + }) this.$loading = this._recordAffiliationService.$loading this._record .getRecord({ diff --git a/src/app/record/components/funding-stacks-groups/funding-stacks-groups.component.html b/src/app/record/components/funding-stacks-groups/funding-stacks-groups.component.html index bccb353be2..b496ed01ae 100644 --- a/src/app/record/components/funding-stacks-groups/funding-stacks-groups.component.html +++ b/src/app/record/components/funding-stacks-groups/funding-stacks-groups.component.html @@ -15,7 +15,7 @@ [isPublicRecord]="isPublicRecord" [(expandedContent)]="expandedContent['FUNDING']" (expandedContentChange)="expandedContentChange.emit(expandedContent)" - [sortTypes]="['date', 'title', 'type', 'source']" + [sortTypes]="sortTypes" [sortType]="'date'" (sort)="sortEvent($event)" > diff --git a/src/app/record/components/funding-stacks-groups/funding-stacks-groups.component.ts b/src/app/record/components/funding-stacks-groups/funding-stacks-groups.component.ts index 0ed5bc56e5..216a300742 100644 --- a/src/app/record/components/funding-stacks-groups/funding-stacks-groups.component.ts +++ b/src/app/record/components/funding-stacks-groups/funding-stacks-groups.component.ts @@ -1,6 +1,6 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' import { Observable, Subject } from 'rxjs' -import { first, takeUntil } from 'rxjs/operators' +import { first, take, takeUntil } from 'rxjs/operators' import { UserService } from 'src/app/core' import { RecordCountriesService } from 'src/app/core/record-countries/record-countries.service' import { RecordService } from 'src/app/core/record/record.service' @@ -11,10 +11,11 @@ import { UserRecordOptions, } from 'src/app/types/record.local' import { UserSession } from 'src/app/types/session.local' -import { SortData } from 'src/app/types/sort' +import { SortData, SortOrderType } from 'src/app/types/sort' import { RecordFundingsService } from '../../../core/record-fundings/record-fundings.service' import { UserInfo } from '../../../types' +import { TogglzService } from '../../../core/togglz/togglz.service' @Component({ selector: 'app-fundings', @@ -40,15 +41,25 @@ export class FundingStacksGroupsComponent implements OnInit { ngOrcidFunding = $localize`:@@shared.funding:Funding` countryCodes: { key: string; value: string }[] loading = true + sortTypes: SortOrderType[] = ['title', 'start', 'end'] constructor( private _userSession: UserService, private _record: RecordService, private _recordFundingsService: RecordFundingsService, - private _recordCountryService: RecordCountriesService + private _recordCountryService: RecordCountriesService, + private _togglz: TogglzService ) {} ngOnInit(): void { + this._togglz + .getStateOf('SOURCE_SORTING') + .pipe(take(1)) + .subscribe((sourceSortingTogglz: boolean) => { + if (sourceSortingTogglz) { + this.sortTypes.push('source') + } + }) this.getRecord() } diff --git a/src/app/record/components/work-stack-group/work-stack-group.component.html b/src/app/record/components/work-stack-group/work-stack-group.component.html index a729b151c7..7f4647d858 100644 --- a/src/app/record/components/work-stack-group/work-stack-group.component.html +++ b/src/app/record/components/work-stack-group/work-stack-group.component.html @@ -15,7 +15,7 @@ [isPublicRecord]="isPublicRecord" [(expandedContent)]="expandedContent['WORK']" (expandedContentChange)="expandedContentChange.emit(expandedContent)" - [sortTypes]="['date', 'title', 'type', 'source']" + [sortTypes]="sortTypes" [sortType]="'date'" [addMenuOptions]="addMenuOptions" (sort)="sortEvent($event)" diff --git a/src/app/record/components/work-stack-group/work-stack-group.component.ts b/src/app/record/components/work-stack-group/work-stack-group.component.ts index eacfafe2ec..d6aaf6377f 100644 --- a/src/app/record/components/work-stack-group/work-stack-group.component.ts +++ b/src/app/record/components/work-stack-group/work-stack-group.component.ts @@ -15,7 +15,7 @@ import { MatDialog } from '@angular/material/dialog' import { MatPaginatorIntl, PageEvent } from '@angular/material/paginator' import { isEmpty } from 'lodash' import { Observable, Subject } from 'rxjs' -import { first } from 'rxjs/operators' +import { first, take } from 'rxjs/operators' import { PlatformInfo, PlatformInfoService } from 'src/app/cdk/platform-info' import { ADD_EVENT_ACTION, @@ -34,7 +34,7 @@ import { UserRecord, UserRecordOptions, } from 'src/app/types/record.local' -import { SortData } from 'src/app/types/sort' +import { SortData, SortOrderType } from 'src/app/types/sort' import { UserInfo } from '../../../types' import { ModalDeleteItemsComponent } from '../modals/modal-delete-item/modal-delete-items.component' @@ -49,6 +49,7 @@ import { WorkBibtexModalComponent } from './modals/work-bibtex-modal/work-bibtex import { ModalCombineWorksWithSelectorComponent } from '../work/modals/modal-combine-works-with-selector/modal-combine-works-with-selector.component' import { GroupingSuggestions } from 'src/app/types/works.endpoint' import { AnnouncerService } from 'src/app/core/announcer/announcer.service' +import { TogglzService } from '../../../core/togglz/togglz.service' @Component({ selector: 'app-work-stack-group', @@ -127,6 +128,7 @@ export class WorkStackGroupComponent implements OnInit { platform: PlatformInfo selectedWorks: string[] = [] selectAll: false + sortTypes: SortOrderType[] = ['title', 'start', 'end'] @ViewChildren('selectAllCheckbox') selectAllCheckbox: MatCheckbox @ViewChildren('appWorkStacks') appWorkStacks: QueryList @@ -138,10 +140,19 @@ export class WorkStackGroupComponent implements OnInit { private _record: RecordService, private _works: RecordWorksService, private _matPaginatorIntl: MatPaginatorIntl, - private _announce: AnnouncerService + private _announce: AnnouncerService, + private _togglz: TogglzService ) {} ngOnInit(): void { + this._togglz + .getStateOf('SOURCE_SORTING') + .pipe(take(1)) + .subscribe((sourceSortingTogglz: boolean) => { + if (sourceSortingTogglz) { + this.sortTypes.push('source') + } + }) this.$loading = this._works.$loading this._record .getRecord({ publicRecordId: this.isPublicRecord })