Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Add SOURCE_SORTING togglz #2069

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,8 @@ export class AffiliationStacksGroupsComponent implements OnInit {
@Output()
expandedContentChange: EventEmitter<MainPanelsState> = new EventEmitter()
professionalActivitiesTogglz = false
sourceSorting = false
sortTypes: SortOrderType[] = ['title', 'start', 'end']

constructor(
private _record: RecordService,
Expand All @@ -66,6 +68,10 @@ 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((value) => (this.sourceSorting = value))
this.$loading = this._recordAffiliationService.$loading
this._record
.getRecord({
Expand Down Expand Up @@ -106,6 +112,9 @@ export class AffiliationStacksGroupsComponent implements OnInit {
}
}
})
if (this.sourceSorting) {
this.sortTypes.push('source')
}
}

trackByProfileAffiliationUiGroups(index, item: AffiliationUIGroup) {
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,16 +41,26 @@ export class FundingStacksGroupsComponent implements OnInit {
ngOrcidFunding = $localize`:@@shared.funding:Funding`
countryCodes: { key: string; value: string }[]
loading = true
sourceSorting = false
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((value) => (this.sourceSorting = value))
this.getRecord()
if (this.sourceSorting) {
DanielPalafox marked this conversation as resolved.
Show resolved Hide resolved
this.sortTypes.push('source')
}
}

private 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,8 @@ export class WorkStackGroupComponent implements OnInit {
platform: PlatformInfo
selectedWorks: string[] = []
selectAll: false
sourceSorting = false
sortTypes: SortOrderType[] = ['title', 'start', 'end']

@ViewChildren('selectAllCheckbox') selectAllCheckbox: MatCheckbox
@ViewChildren('appWorkStacks') appWorkStacks: QueryList<WorkStackComponent>
Expand All @@ -138,10 +141,15 @@ 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((value) => (this.sourceSorting = value))
this.$loading = this._works.$loading
this._record
.getRecord({ publicRecordId: this.isPublicRecord })
Expand All @@ -163,6 +171,9 @@ export class WorkStackGroupComponent implements OnInit {
this._platform.get().subscribe((platform) => {
this.platform = platform
})
if (this.sourceSorting) {
DanielPalafox marked this conversation as resolved.
Show resolved Hide resolved
this.sortTypes.push('source')
}
}

private getGroupingSuggestions() {
Expand Down