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

Add confirm dialog when moving course with packages

parent 792aa3de
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,9 @@ import * as utils from '@app/degree-planner/shared/utils'; ...@@ -24,6 +24,9 @@ import * as utils from '@app/degree-planner/shared/utils';
import { findSafariExecutable } from 'selenium-webdriver/safari'; import { findSafariExecutable } from 'selenium-webdriver/safari';
import { TermCode } from '@app/core/models/termcode'; 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 => { const isntUndefined = <T>(thing: T | undefined): thing is T => {
return thing !== undefined; return thing !== undefined;
}; };
...@@ -147,11 +150,33 @@ export class TermContainerComponent implements OnInit, OnDestroy { ...@@ -147,11 +150,33 @@ export class TermContainerComponent implements OnInit, OnDestroy {
const to = event.container.data; const to = event.container.data;
const { id } = event.item.data; const { id } = event.item.data;
const newIndex = event.currentIndex; const newIndex = event.currentIndex;
const { classNumber } = event.item.data as Course;
// Dispatch a new change request console.log('classNumber', classNumber);
this.store.dispatch(
new actions.MoveCourseBetweenTerms({ to, from, id, newIndex }), 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') { } else if (previousContainer === 'saved-courses') {
// If moving from saved courses to term // If moving from saved courses to term
......
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