Skip to content

Commit

Permalink
Merge pull request #2069 from ORCID/feature/8869-qa-hide-source-sorti…
Browse files Browse the repository at this point in the history
…ng-behind-a-togglz

feature: Add `SOURCE_SORTING` togglz
  • Loading branch information
leomendoza123 authored Oct 4, 2023
2 parents 899b7d3 + f1c9108 commit 33d0d83
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -54,6 +54,7 @@ export class AffiliationStacksGroupsComponent implements OnInit {
@Output()
expandedContentChange: EventEmitter<MainPanelsState> = new EventEmitter()
professionalActivitiesTogglz = false
sortTypes: SortOrderType[] = ['title', 'start', 'end']

constructor(
private _record: RecordService,
Expand All @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
>
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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',
Expand All @@ -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()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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'
Expand All @@ -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',
Expand Down Expand Up @@ -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<WorkStackComponent>
Expand All @@ -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 })
Expand Down

0 comments on commit 33d0d83

Please sign in to comment.