From fc70851bf5ad8e96ccdb56732b9115a20209c48e Mon Sep 17 00:00:00 2001 From: pnogal <paulina.nogal@wisc.edu> Date: Wed, 27 Feb 2019 15:13:30 -0600 Subject: [PATCH] Add confirm dialog when moving course with packages --- .../term-container.component.ts | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) 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 8700ccb..253d445 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 -- GitLab