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 {
withLatestFrom,
distinctUntilChanged,
} from 'rxjs/operators';
import { OnInit } from '@angular/core';
import { Observable, of } from 'rxjs';
import { OnInit, OnDestroy } from '@angular/core';
import { Observable, of, Subscription } from 'rxjs';
import { select } from '@ngrx/store';
import { Component } from '@angular/core';
import { MatSelectChange } from '@angular/material';
......@@ -34,16 +34,18 @@ import {
CloseCourseSearch,
} from './store/actions/ui.actions';
// Pipes
import { GetTermDescriptionPipe } from '@app/shared/pipes/get-term-description.pipe';
@Component({
selector: 'cse-degree-planner',
templateUrl: './degree-planner.component.html',
styleUrls: ['./degree-planner.component.scss'],
})
export class DegreePlannerComponent implements OnInit {
export class DegreePlannerComponent implements OnInit, OnDestroy {
public termsByAcademicYear: Object;
public mobileView: MediaQueryList;
public coursesData$: any;
public degreePlan$: Observable<DegreePlan | undefined>;
public allDegreePlans$: Observable<DegreePlan[]>;
public firstActiveTermCode$: Observable<string | undefined>;
......@@ -51,6 +53,8 @@ export class DegreePlannerComponent implements OnInit {
public yearCodes$: Observable<string[]>;
public isCourseSearchOpen$: Observable<boolean>;
public isLoadingPlan$: Observable<boolean>;
public activeTermSubscription: Subscription;
public firstActiveTerm: string;
constructor(
private store: Store<GlobalState>,
......@@ -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 {
// this.store.dispatch(
// new ToggleAcademicYear({ year: year.twoDigitYearCode.toString() }),
......@@ -139,13 +148,22 @@ export class DegreePlannerComponent implements OnInit {
}
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
.open(ConfirmDialogComponent, {
data: {
title: 'Are you sure?',
confirmText: 'Change plan',
text:
"This will change your primary plan and replace the current courses in your cart with the courses in this plan's active term",
text: `This will change your primary plan and replace the current courses in your cart with the courses in this plan's ${currentTerm} term`,
},
})
.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