From f1c91080c9c30a7f339f7fc853160f7d0f981aff Mon Sep 17 00:00:00 2001 From: Daniel Palafox Date: Wed, 4 Oct 2023 15:51:36 -0500 Subject: [PATCH] fix: Add source sorting togglz inside togglz subscribe --- .../affiliation-stacks-groups.component.ts | 10 +++++----- .../funding-stacks-groups.component.ts | 14 +++++++------- .../work-stack-group/work-stack-group.component.ts | 14 +++++++------- 3 files changed, 19 insertions(+), 19 deletions(-) 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 1e4c6e13c5..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 @@ -54,7 +54,6 @@ export class AffiliationStacksGroupsComponent implements OnInit { @Output() expandedContentChange: EventEmitter = new EventEmitter() professionalActivitiesTogglz = false - sourceSorting = false sortTypes: SortOrderType[] = ['title', 'start', 'end'] constructor( @@ -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({ @@ -112,9 +115,6 @@ export class AffiliationStacksGroupsComponent implements OnInit { } } }) - if (this.sourceSorting) { - this.sortTypes.push('source') - } } trackByProfileAffiliationUiGroups(index, item: AffiliationUIGroup) { 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 0de17ff27a..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 @@ -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( @@ -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() { 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 1bc48f040d..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 @@ -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 @@ -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 }) @@ -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() {