Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

saved courses into main #954

Merged
merged 29 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ea5a1af
[Saved Courses] add save modal (#912)
plumshum Sep 17, 2024
c475ccb
added collections in store. add backend methods and gtags
plumshum Oct 2, 2024
3108134
added basic functionality for save course
plumshum Oct 5, 2024
32add4c
fixed functionality for save courses to mutliple collections
plumshum Oct 5, 2024
36f9925
finished backend and fixed frontend
plumshum Oct 17, 2024
5d4df16
created editabilify for collection names
plumshum Oct 18, 2024
726dbe3
fixed backend error and logic
plumshum Oct 28, 2024
428790d
[Saved Courses] Add Icon to Sidebar (#882)
andxu282 Oct 28, 2024
f376e2c
Merge branch 'saved-courses' into hannah--merge-collection
plumshum Oct 28, 2024
f304e70
merged sidebar with backend
plumshum Oct 28, 2024
5c2bc27
fixed migration script and bottom course bar
plumshum Oct 28, 2024
24537e2
feat: draggable saved courses
Destaq Oct 29, 2024
0c737aa
chore: prettify things
Destaq Oct 29, 2024
3e5cc0a
Merge pull request #952 from cornell-dti/simon-draggable-saved-courses
Destaq Oct 29, 2024
4080113
ran prettier and type check
plumshum Oct 29, 2024
a1a461b
Merge branch 'hannah--merge-collection' of github.com:cornell-dti/cou…
plumshum Oct 29, 2024
aa42b8c
fixed cu review api
plumshum Oct 29, 2024
2d1970e
Merge pull request #951 from cornell-dti/hannah--merge-collection
plumshum Oct 29, 2024
e81d8b0
Merge branch 'main' into saved-courses
plumshum Oct 29, 2024
a858f5f
fixed div
plumshum Oct 29, 2024
dc9d6e3
remove feature flag
plumshum Oct 29, 2024
b9216fc
frontend and type check fixes
plumshum Oct 30, 2024
224c8c1
resolved front-end issue with plans
plumshum Oct 30, 2024
843a9aa
fixed more front-end and confirmation modal
plumshum Oct 30, 2024
b4b20e6
fixed frontend
plumshum Oct 30, 2024
f8a2f42
ran prettier
plumshum Oct 30, 2024
2b2e264
Merge branch 'main' into saved-courses
plumshum Oct 30, 2024
6313eb4
last fix
plumshum Oct 30, 2024
8b9bbb2
Merge branch 'saved-courses' of github.com:cornell-dti/course-plan in…
plumshum Oct 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions scripts/migration/savedCourses-migration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* eslint-disable no-console */

import { usernameCollection, semestersCollection } from '../firebase-config';

/**
* Perform migration of a default The 'All' Collection for All Courses saved
*/
async function runOnUser(userEmail: string) {
const courses = [] as object;
await semestersCollection.doc(userEmail).update({
savedCourses: [{ name: 'All', courses }],
});
}

async function main() {
const userEmail = process.argv[2];
if (userEmail != null) {
await runOnUser(userEmail);
return;
}
const collection = await usernameCollection.get();
for (const { id } of collection.docs) {
console.group(`Running on ${id}...`);
// Intentionally await in a loop to have no interleaved console logs.
// eslint-disable-next-line no-await-in-loop
await runOnUser(id);
console.groupEnd();
}
}

main();
3 changes: 3 additions & 0 deletions src/assets/images/dropdown.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/images/navbar/savedCoursesIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/images/navbar/savedCoursesIconBlue.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/images/plus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/images/saveIconBig.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/images/saveIconSmall.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/assets/images/trash-gray.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ $offWhite: #f8f8f8;
$searchBoxWhite: #f1f1f1;
$veryLightGray: #e5e5e5;
$lightGray: #acacac;
$lightestGray: #e0e0e0;
$viewLabelGray: #7e7e7e80;
$medGray: #737373;
$darkGray: #3c3c3c;
Expand Down
88 changes: 82 additions & 6 deletions src/components/Course/Course.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
}"
class="course"
>
<save-course-modal
:courseCode="courseCode"
@close-save-course-modal="closeSaveCourseModal"
@save-course="saveCourse"
@add-collection="addCollection"
v-if="isSaveCourseOpen"
/>
<edit-color
:editedColor="editedColor"
@color-course="colorCourse"
Expand Down Expand Up @@ -42,9 +49,22 @@
:isCompactView="true"
/>
</div>
<button v-if="!isReqCourse" class="course-dotRow" @click="openMenu">
<button
v-if="!isReqCourse && isSemesterCourseCard"
class="course-dotRow"
@click="openMenu"
>
<img src="@/assets/images/dots/threeDots.svg" alt="open menu for course card" />
</button>
<button
v-else-if="!isReqCourse && !isSemesterCourseCard"
class="course-trash"
@click.stop="deleteCourseFromCollection"
@mouseover="hoverTrashIcon"
@mouseleave="unhoverTrashIcon"
>
<img :src="trashIcon" alt="delete course from collection" />
</button>
</div>
<div v-if="!compact" class="course-name">{{ courseObj.name }}</div>
<div v-if="!compact" class="course-info">
Expand All @@ -60,12 +80,15 @@
</div>
<course-menu
v-if="menuOpen"
:courseObj="courseObj"
:semesterIndex="semesterIndex"
:isCompact="compact"
:courseColor="courseObj.color"
:courseCode="courseObj.code"
@open-edit-color-modal="openEditColorModal"
@delete-course="deleteCourse"
@edit-course-credit="editCourseCredit"
@open-save-course-modal="openSaveCourseModal"
:getCreditRange="getCreditRange || []"
v-click-outside="closeMenuIfOpen"
/>
Expand All @@ -76,17 +99,20 @@
import { CSSProperties, PropType, defineComponent } from 'vue';
import CourseMenu from '@/components/Modals/CourseMenu.vue';
import CourseCaution from '@/components/Course/CourseCaution.vue';
import SaveCourseModal from '@/components/Modals/SaveCourseModal.vue';
import {
addCourseToBottomBar,
reportCourseColorChange,
reportSubjectColorChange,
} from '@/components/BottomBar/BottomBarState';
import { isCourseConflict } from '@/store';
import { clickOutside } from '@/utilities';
import EditColor from '../Modals/EditColor.vue';
import { isCourseConflict } from '@/store';
import trashGrayIcon from '@/assets/images/trash-gray.svg';
import trashRedIcon from '@/assets/images/trash.svg';

export default defineComponent({
components: { CourseCaution, CourseMenu, EditColor },
components: { CourseCaution, CourseMenu, EditColor, SaveCourseModal },
props: {
courseObj: { type: Object as PropType<FirestoreSemesterCourse>, required: true },
compact: { type: Boolean, required: true },
Expand All @@ -95,6 +121,7 @@ export default defineComponent({
semesterIndex: { type: Number, required: false, default: 0 },
season: { type: String, required: false, default: '' },
year: { type: Number, required: false, default: 0 },
isSemesterCourseCard: { type: Boolean, required: true },
isSchedGenCourse: { type: Boolean, required: false, default: false },
},
emits: {
Expand All @@ -107,14 +134,28 @@ export default defineComponent({
'course-on-click': (course: FirestoreSemesterCourse) => typeof course === 'object',
'edit-course-credit': (credit: number, uniqueID: number) =>
typeof credit === 'number' && typeof uniqueID === 'number',
'save-course': (
course: FirestoreSemesterCourse,
addedToCollections: string[],
deletedFromCollection: string[]
) =>
typeof course === 'object' &&
typeof addedToCollections === 'object' &&
typeof deletedFromCollection === 'object',
'add-collection': (name: string) => typeof name === 'string',
'delete-course-from-collection': (courseCode: string) => typeof courseCode === 'string',
},
data() {
return {
menuOpen: false,
stopCloseFlag: false,
getCreditRange: this.courseObj.creditRange,
isEditColorOpen: false,
isSaveCourseOpen: false,
editedColor: '',
deletingCourse: false,
trashIcon: trashGrayIcon, // Default icon
courseCode: '',
};
},
computed: {
Expand Down Expand Up @@ -155,17 +196,35 @@ export default defineComponent({
this.menuOpen = false;
}
},
openSaveCourseModal(courseCode: string) {
this.courseCode = courseCode;
this.isSaveCourseOpen = true;
this.closeMenuIfOpen();
},
closeSaveCourseModal() {
this.isSaveCourseOpen = false;
},
deleteCourse() {
this.$emit('delete-course', this.courseObj.code, this.courseObj.uniqueID);
this.closeMenuIfOpen();
},
deleteCourseFromCollection() {
this.$emit('delete-course-from-collection', this.courseObj.code);
},
openEditColorModal(color: string) {
this.editedColor = color;
this.isEditColorOpen = true;
},
closeEditColorModal() {
this.isEditColorOpen = false;
},
addCollection(name: string) {
this.$emit('add-collection', name);
},
saveCourse(addedToCollections: string[], deletedFromCollections: string[]) {
const course = { ...this.courseObj };
this.$emit('save-course', course, addedToCollections, deletedFromCollections);
},
colorCourse(color: string) {
this.$emit('color-course', color, this.courseObj.uniqueID, this.courseObj.code);
reportCourseColorChange(this.courseObj.uniqueID, color);
Expand All @@ -177,7 +236,7 @@ export default defineComponent({
this.closeMenuIfOpen();
},
courseOnClick() {
if (!this.menuOpen) {
if (!this.menuOpen && !this.deletingCourse) {
this.$emit('course-on-click', this.courseObj);
addCourseToBottomBar(this.courseObj, this.season, this.year);
}
Expand All @@ -187,6 +246,12 @@ export default defineComponent({
this.closeMenuIfOpen();
},
isCourseConflict,
hoverTrashIcon() {
this.trashIcon = trashRedIcon;
},
unhoverTrashIcon() {
this.trashIcon = trashGrayIcon;
},
},
directives: {
'click-outside': clickOutside,
Expand Down Expand Up @@ -251,6 +316,18 @@ export default defineComponent({
}
}

&-trash {
padding: 8px 0;
display: flex;
position: relative;

&:hover,
&:active,
&:focus {
cursor: pointer;
}
}

&-content {
width: calc(100% - #{$colored-grabber-width});
padding: 0 1rem;
Expand Down Expand Up @@ -297,8 +374,7 @@ export default defineComponent({
display: flex;
align-items: center;
}

&-credits {
port &-credits {
white-space: nowrap;
}

Expand Down
1 change: 1 addition & 0 deletions src/components/DropDownArrow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default defineComponent({
</script>

<style scoped lang="scss">
@import '@/assets/scss/_variables.scss';
.arrow {
height: 14px;
width: 14px;
Expand Down
Loading
Loading