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

[Schedule Generator] Add Requirements #905

Merged
merged 9 commits into from
Apr 16, 2024
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
fixed dropdowns
  • Loading branch information
andxu282 committed Mar 28, 2024
commit 93180044169479e956b0e93503a72a42a83b102c
25 changes: 24 additions & 1 deletion src/components/ScheduleGenerate/ScheduleGenerateSideBar.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<div class="sidebar">
<confirmation :text="confirmationText" v-if="isConfirmationOpen" />
<div class="sidebar-header">
<h1 class="top header-title">Semester Schedule Builder</h1>
<div class="semester">
Expand Down Expand Up @@ -71,12 +72,15 @@
<script lang="ts">
import { defineComponent } from 'vue';
import RequirementCourses from '@/components/ScheduleGenerate/RequirementCourses.vue';
import Confirmation from '@/components/Modals/Confirmation.vue';

export default defineComponent({
data(): {
requirements: string[];
availableRequirements: Record<string, string>;
numberOfRequirements: number;
isConfirmationOpen: boolean;
confirmationText: string;
} {
return {
requirements: [],
Expand All @@ -86,10 +90,13 @@ export default defineComponent({
'Liberal Studies': 'Liberal Studies',
},
numberOfRequirements: 3,
isConfirmationOpen: false,
confirmationText: '',
};
},
components: {
RequirementCourses,
Confirmation,
},
props: {
// current semester being generated for
Expand All @@ -99,6 +106,18 @@ export default defineComponent({
},
emits: ['openScheduleGenerateModal'],
methods: {
openConfirmationModal(msg: string) {
// Set text and display confirmation modal, then have it disappear after 3 seconds
this.confirmationText = msg;
this.isConfirmationOpen = true;

setTimeout(() => {
this.closeConfirmationModal();
}, 2000);
},
closeConfirmationModal() {
this.isConfirmationOpen = false;
},
addRequirement() {
this.requirements = [...this.requirements, ''];
},
Expand All @@ -112,11 +131,15 @@ export default defineComponent({
if (requirement !== '') this.availableRequirements[requirement] = requirement;
},
deleteRequirement(index: number) {
const requirement = this.requirements[index];
// add back to the availableRequirements record
this.addAvailableRequirement(this.requirements[index]);
this.addAvailableRequirement(requirement);

// delete this requirement from list
this.requirements.splice(index, 1);
this.openConfirmationModal(
`Removed ${requirement === '' ? 'requirement' : requirement} from schedule builder`
);
},
openScheduleGenerateModal() {
this.$emit('openScheduleGenerateModal');
Expand Down