Skip to content
Snippets Groups Projects
Commit 4b5bded5 authored by pnogal's avatar pnogal Committed by Paulina Nogal
Browse files

Include active term in user messages

parent f22389af
No related branches found
No related tags found
No related merge requests found
...@@ -4,8 +4,8 @@ import { ...@@ -4,8 +4,8 @@ import {
withLatestFrom, withLatestFrom,
distinctUntilChanged, distinctUntilChanged,
} from 'rxjs/operators'; } from 'rxjs/operators';
import { OnInit } from '@angular/core'; import { OnInit, OnDestroy } from '@angular/core';
import { Observable, of } from 'rxjs'; import { Observable, of, Subscription } from 'rxjs';
import { select } from '@ngrx/store'; import { select } from '@ngrx/store';
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { MatSelectChange } from '@angular/material'; import { MatSelectChange } from '@angular/material';
...@@ -34,16 +34,18 @@ import { ...@@ -34,16 +34,18 @@ import {
CloseCourseSearch, CloseCourseSearch,
} from './store/actions/ui.actions'; } from './store/actions/ui.actions';
// Pipes
import { GetTermDescriptionPipe } from '@app/shared/pipes/get-term-description.pipe';
@Component({ @Component({
selector: 'cse-degree-planner', selector: 'cse-degree-planner',
templateUrl: './degree-planner.component.html', templateUrl: './degree-planner.component.html',
styleUrls: ['./degree-planner.component.scss'], styleUrls: ['./degree-planner.component.scss'],
}) })
export class DegreePlannerComponent implements OnInit { export class DegreePlannerComponent implements OnInit, OnDestroy {
public termsByAcademicYear: Object; public termsByAcademicYear: Object;
public mobileView: MediaQueryList; public mobileView: MediaQueryList;
public coursesData$: any; public coursesData$: any;
public degreePlan$: Observable<DegreePlan | undefined>; public degreePlan$: Observable<DegreePlan | undefined>;
public allDegreePlans$: Observable<DegreePlan[]>; public allDegreePlans$: Observable<DegreePlan[]>;
public firstActiveTermCode$: Observable<string | undefined>; public firstActiveTermCode$: Observable<string | undefined>;
...@@ -51,6 +53,8 @@ export class DegreePlannerComponent implements OnInit { ...@@ -51,6 +53,8 @@ export class DegreePlannerComponent implements OnInit {
public yearCodes$: Observable<string[]>; public yearCodes$: Observable<string[]>;
public isCourseSearchOpen$: Observable<boolean>; public isCourseSearchOpen$: Observable<boolean>;
public isLoadingPlan$: Observable<boolean>; public isLoadingPlan$: Observable<boolean>;
public activeTermSubscription: Subscription;
public firstActiveTerm: string;
constructor( constructor(
private store: Store<GlobalState>, private store: Store<GlobalState>,
...@@ -85,6 +89,11 @@ export class DegreePlannerComponent implements OnInit { ...@@ -85,6 +89,11 @@ export class DegreePlannerComponent implements OnInit {
); );
} }
// Unsubscribe from subs to prevent memeory leaks
public ngOnDestroy() {
this.activeTermSubscription.unsubscribe();
}
public handleAcademicYearToggle(year: Year): void { public handleAcademicYearToggle(year: Year): void {
// this.store.dispatch( // this.store.dispatch(
// new ToggleAcademicYear({ year: year.twoDigitYearCode.toString() }), // new ToggleAcademicYear({ year: year.twoDigitYearCode.toString() }),
...@@ -139,13 +148,22 @@ export class DegreePlannerComponent implements OnInit { ...@@ -139,13 +148,22 @@ export class DegreePlannerComponent implements OnInit {
} }
public onMakePrimayClick(currentPlan: DegreePlan) { public onMakePrimayClick(currentPlan: DegreePlan) {
this.activeTermSubscription = this.store
.pipe(select(selectors.getActiveTerms))
.subscribe(terms => {
this.firstActiveTerm = terms[0];
});
const currentTerm: any = new GetTermDescriptionPipe().transform(
this.firstActiveTerm,
);
this.dialog this.dialog
.open(ConfirmDialogComponent, { .open(ConfirmDialogComponent, {
data: { data: {
title: 'Are you sure?', title: 'Are you sure?',
confirmText: 'Change plan', confirmText: 'Change plan',
text: text: `This will change your primary plan and replace the current courses in your cart with the courses in this plan's ${currentTerm} term`,
"This will change your primary plan and replace the current courses in your cart with the courses in this plan's active term",
}, },
}) })
.afterClosed() .afterClosed()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment