Skip to content

Commit

Permalink
fix: Add source sorting togglz inside togglz subscribe
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielPalafox committed Oct 4, 2023
1 parent b3160d4 commit f1c9108
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export class AffiliationStacksGroupsComponent implements OnInit {
@Output()
expandedContentChange: EventEmitter<MainPanelsState> = new EventEmitter()
professionalActivitiesTogglz = false
sourceSorting = false
sortTypes: SortOrderType[] = ['title', 'start', 'end']

constructor(
Expand All @@ -71,7 +70,11 @@ export class AffiliationStacksGroupsComponent implements OnInit {
this._togglz
.getStateOf('SOURCE_SORTING')
.pipe(take(1))
.subscribe((value) => (this.sourceSorting = value))
.subscribe((sourceSortingTogglz: boolean) => {
if (sourceSortingTogglz) {
this.sortTypes.push('source')
}
})
this.$loading = this._recordAffiliationService.$loading
this._record
.getRecord({
Expand Down Expand Up @@ -112,9 +115,6 @@ 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 @@ -41,7 +41,6 @@ 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(
Expand All @@ -54,13 +53,14 @@ export class FundingStacksGroupsComponent implements OnInit {

ngOnInit(): void {
this._togglz
.getStateOf('SOURCE_SORTING')
.pipe(take(1))
.subscribe((value) => (this.sourceSorting = value))
.getStateOf('SOURCE_SORTING')
.pipe(take(1))
.subscribe((sourceSortingTogglz: boolean) => {
if (sourceSortingTogglz) {
this.sortTypes.push('source')
}
})
this.getRecord()
if (this.sourceSorting) {
this.sortTypes.push('source')
}
}

private getRecord() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ export class WorkStackGroupComponent implements OnInit {
platform: PlatformInfo
selectedWorks: string[] = []
selectAll: false
sourceSorting = false
sortTypes: SortOrderType[] = ['title', 'start', 'end']

@ViewChildren('selectAllCheckbox') selectAllCheckbox: MatCheckbox
Expand All @@ -147,9 +146,13 @@ export class WorkStackGroupComponent implements OnInit {

ngOnInit(): void {
this._togglz
.getStateOf('SOURCE_SORTING')
.pipe(take(1))
.subscribe((value) => (this.sourceSorting = value))
.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 All @@ -171,9 +174,6 @@ export class WorkStackGroupComponent implements OnInit {
this._platform.get().subscribe((platform) => {
this.platform = platform
})
if (this.sourceSorting) {
this.sortTypes.push('source')
}
}

private getGroupingSuggestions() {
Expand Down

0 comments on commit f1c9108

Please sign in to comment.