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

General: Make sure the filter button renders when reloading the course statistics page #10231

Merged
merged 6 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions src/main/webapp/app/overview/course-overview.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,12 +623,12 @@ export class CourseOverviewComponent implements OnInit, OnDestroy, AfterViewInit
if (componentRef.controlConfiguration) {
const provider = componentRef as BarControlConfigurationProvider;
this.controlConfiguration = provider.controlConfiguration as BarControlConfiguration;

// Listen for changes to the control configuration; works for initial config as well
this.controlsSubscription =
this.controlConfiguration.subject?.subscribe((controls: TemplateRef<any>) => {
this.controlConfiguration.subject?.subscribe(async (controls: TemplateRef<any>) => {
this.controls = controls;
this.tryRenderControls();
await firstValueFrom(provider.controlsRendered);
this.tryRenderControls();
}) || undefined;
}
if (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AfterViewInit, Component, OnDestroy, OnInit, TemplateRef, ViewChild, inject } from '@angular/core';
import { AfterViewInit, Component, EventEmitter, OnDestroy, OnInit, TemplateRef, ViewChild, inject } from '@angular/core';
import { ActivatedRoute, RouterLink } from '@angular/router';
import { faClipboard, faFilter, faQuestionCircle } from '@fortawesome/free-solid-svg-icons';
import { TranslateService } from '@ngx-translate/core';
Expand Down Expand Up @@ -116,6 +116,7 @@ enum ChartBarTitle {
],
})
export class CourseStatisticsComponent implements OnInit, OnDestroy, AfterViewInit, BarControlConfigurationProvider {
controlsRendered = new EventEmitter<void>();
private courseStorageService = inject(CourseStorageService);
private scoresStorageService = inject(ScoresStorageService);
private translateService = inject(TranslateService);
Expand Down Expand Up @@ -281,6 +282,7 @@ export class CourseStatisticsComponent implements OnInit, OnDestroy, AfterViewIn
// Send our controls template to parent so it will be rendered in the top bar
if (this.controls) {
this.controlConfiguration.subject!.next(this.controls);
this.controlsRendered.emit();
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/webapp/app/shared/tab-bar/tab-bar.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { Subject } from 'rxjs';
import { TemplateRef } from '@angular/core';
import { EventEmitter } from '@angular/core';

export interface BarControlConfiguration {
subject?: Subject<TemplateRef<any>>;
}

export interface BarControlConfigurationProvider {
controlConfiguration: BarControlConfiguration;
controlsRendered: EventEmitter<void>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe';
import { SortDirective } from 'app/shared/sort/sort.directive';
import { SortByDirective } from 'app/shared/sort/sort-by.directive';
import { AlertService } from 'app/core/util/alert.service';
import { AfterViewInit, ChangeDetectorRef, Component, TemplateRef, ViewChild } from '@angular/core';
import { AfterViewInit, ChangeDetectorRef, Component, EventEmitter, TemplateRef, ViewChild } from '@angular/core';
import { By } from '@angular/platform-browser';
import { TeamAssignmentPayload } from 'app/entities/team.model';
import { Exam } from 'app/entities/exam/exam.model';
Expand Down Expand Up @@ -117,6 +117,8 @@ const courses: Course[] = [course2];
template: '<ng-template #controls><button id="test-button">TestButton</button></ng-template>',
})
class ControlsTestingComponent implements BarControlConfigurationProvider, AfterViewInit {
controlsRendered = new EventEmitter<void>();

@ViewChild('controls', { static: false }) private controls: TemplateRef<any>;
public readonly controlConfiguration: BarControlConfiguration = {
subject: new Subject<TemplateRef<any>>(),
Expand Down
Loading