diff --git a/src/app/degree-planner/term-container/term-container.component.ts b/src/app/degree-planner/term-container/term-container.component.ts index 8700ccb7b76358a972f0110d5b64dd88430c447b..253d445276110657ee90a0c1d78fb5cb9ec3b2e4 100644 --- a/src/app/degree-planner/term-container/term-container.component.ts +++ b/src/app/degree-planner/term-container/term-container.component.ts @@ -24,6 +24,9 @@ import * as utils from '@app/degree-planner/shared/utils'; import { findSafariExecutable } from 'selenium-webdriver/safari'; import { TermCode } from '@app/core/models/termcode'; +// Dialogs +import { ConfirmDialogComponent } from '@app/shared/dialogs/confirm-dialog/confirm-dialog.component'; + const isntUndefined = <T>(thing: T | undefined): thing is T => { return thing !== undefined; }; @@ -147,11 +150,33 @@ export class TermContainerComponent implements OnInit, OnDestroy { const to = event.container.data; const { id } = event.item.data; const newIndex = event.currentIndex; - - // Dispatch a new change request - this.store.dispatch( - new actions.MoveCourseBetweenTerms({ to, from, id, newIndex }), - ); + const { classNumber } = event.item.data as Course; + console.log('classNumber', classNumber); + + if (classNumber !== null) { + // If moving course with packages to future term + this.dialog + .open(ConfirmDialogComponent, { + data: { + title: 'Are you sure?', + confirmText: 'Move course', + text: `Moving this course to a future term will remove your selected section`, + }, + }) + .afterClosed() + .subscribe((result: { confirmed: true } | undefined) => { + if (result !== undefined && result.confirmed === true) { + this.store.dispatch( + new actions.MoveCourseBetweenTerms({ to, from, id, newIndex }), + ); + } + }); + } else { + // Dispatch a new change request + this.store.dispatch( + new actions.MoveCourseBetweenTerms({ to, from, id, newIndex }), + ); + } } else if (previousContainer === 'saved-courses') { // If moving from saved courses to term