From a7bda9b6f40c21ee968a7004f5948c66a4187502 Mon Sep 17 00:00:00 2001
From: pnogal <paulina.nogal@wisc.edu>
Date: Fri, 16 Nov 2018 13:41:25 -0600
Subject: [PATCH] Add condition when running removeFavoriteCourse() in
 term-container

---
 .../term-container/term-container.component.ts       | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 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 9e007ca..a0c14ca 100644
--- a/src/app/degree-planner/term-container/term-container.component.ts
+++ b/src/app/degree-planner/term-container/term-container.component.ts
@@ -15,6 +15,7 @@ export class TermContainerComponent {
 	@Input() term: Term;
 	@Input() courses: Course[];
 	@Input() termCodes: String[];
+
 	terms: any[];
 	favoriteCourse: FavoriteCourse;
 
@@ -32,6 +33,7 @@ export class TermContainerComponent {
 	}
 
 	drop(event: CdkDragDrop<string[]>) {
+
 		if (event.previousContainer.id !== event.container.id) {
 			// moveItemInArray(event.container.data, event.previousIndex, event.currentIndex);
 			transferArrayItem(event.previousContainer.data,
@@ -40,9 +42,11 @@ export class TermContainerComponent {
 				event.currentIndex);
 		}
 
-		this.dataService.removeFavoriteCourse(event.item.data.subjectCode, event.item.data.courseId)
-		.subscribe(favoriteCourse => {
-			this.favoriteCourse = favoriteCourse;
-		});
+		if (event.previousContainer.id === 'favoriteCourse-dropZone') {
+			this.dataService.removeFavoriteCourse(event.item.data.subjectCode, event.item.data.courseId)
+			.subscribe(favoriteCourse => {
+				this.favoriteCourse = favoriteCourse;
+			});
+		}
 	}
 }
-- 
GitLab