Skip to content

Commit

Permalink
Merge pull request #232 from SELab-2/project_creation
Browse files Browse the repository at this point in the history
Project creation
  • Loading branch information
EwoutV authored Apr 4, 2024
2 parents 99a8858 + 243b030 commit 62a6a08
Show file tree
Hide file tree
Showing 14 changed files with 622 additions and 83 deletions.
98 changes: 97 additions & 1 deletion frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"lint-fix": "eslint src --ext .ts,.vue --fix"
},
"dependencies": {
"@vuelidate/core": "^2.0.3",
"@vuelidate/validators": "^2.0.4",
"@vueuse/core": "^10.9.0",
"axios": "^1.6.8",
"js-cookie": "^3.0.5",
Expand All @@ -26,7 +28,8 @@
"primevue": "^3.50.0",
"vue": "^3.4.18",
"vue-i18n": "^9.10.2",
"vue-router": "^4.3.0"
"vue-router": "^4.3.0",
"vuelidate": "^0.7.7"
},
"devDependencies": {
"@types/js-cookie": "^3.0.6",
Expand Down
21 changes: 17 additions & 4 deletions frontend/src/assets/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"courses": "My courses",
"projects": "Current projects",
"no_projects": "No projects available for this academic year.",
"no_courses": "No courses available for this academic year."
"no_courses": "No courses available for this academic year.",
"select_course": "Select the course for which you want to create a project:"
},
"login": {
"title": "Login",
Expand All @@ -38,9 +39,17 @@
"title": "Calendar"
},
"projects": {
"deadline": "Deadline",
"submissionStatus": "Indienstatus",
"groupMembers": "Group members"
"deadline": "Deadline",
"submissionStatus": "Indienstatus",
"groupMembers": "Group members",
"create": "Create new project",
"name": "Project name",
"description": "Description",
"start_date": "Start project",
"group_size": "Number of students in a group (1 for an individual project)",
"max_score": "Maximum score that can be achieved",
"visibility": "Make project visible to students",
"score_visibility": "Make score, when uploaded, automatically visible to students"
},
"courses": {
"create": "Create course",
Expand Down Expand Up @@ -85,6 +94,10 @@
"unknown": "An unknown error has occurred."
}
},
"validations": {
"required": "This field is required",
"deadline": "The deadline must be after the start date"
},
"primevue": {
"startsWith": "Starts with",
"contains": "Contains",
Expand Down
17 changes: 15 additions & 2 deletions frontend/src/assets/lang/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"courses": "Mijn vakken",
"projects": "Lopende projecten",
"no_projects": "Geen projecten gevonden.",
"no_courses": "Geen vakken gevonden."
"no_courses": "Geen vakken gevonden.",
"select_course": "Selecteer het vak waarvoor je een project wil maken:"
},
"login": {
"title": "Inloggen",
Expand All @@ -40,7 +41,15 @@
"projects": {
"deadline": "Deadline",
"submissionStatus": "Indienstatus",
"groupMembers": "Groepsleden"
"groupMembers": "Groepsleden",
"create": "Creëer nieuw project",
"name": "Projectnaam",
"description": "Beschrijving",
"start_date": "Start project",
"group_size": "Aantal studenten per groep (1 voor individueel project)",
"max_score": "Maximale te behalen score",
"visibility": "Project zichtbaar maken voor studenten",
"score_visibility": "Maak score, wanneer ingevuld, automatisch zichtbaar voor studenten"
},
"courses": {
"create": "Creëer vak",
Expand Down Expand Up @@ -110,6 +119,10 @@
}
}
},
"validations": {
"required": "Dit veld is verplicht",
"deadline": "De deadline moet na de startdatum liggen"
},
"primevue": {
"accept": "Ja",
"addRule": "Voeg regel toe",
Expand Down
14 changes: 14 additions & 0 deletions frontend/src/components/forms/ErrorMessage.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script setup lang="ts">
/* Props */
const props = defineProps<{ field: any }>();
</script>

<template>
<span v-if="props.field.$error" class="p-error">{{ props.field.$errors[0].$message }}</span>
</template>

<style scoped lang="scss">
.p-error {
display: block;
}
</style>
72 changes: 72 additions & 0 deletions frontend/src/components/projects/ProjectCreateButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import { type Course } from '@/types/Course.ts';
import { PrimeIcons } from 'primevue/api';
import Dialog from 'primevue/dialog';
import Button from 'primevue/button';
import { useRouter } from 'vue-router';
import { ref } from 'vue';
/* Composable injections */
const { t } = useI18n();
const { push } = useRouter();
/* Props */
const props = defineProps<{ courses: Course[] }>();
/* Dialog state to select the course you want to create a project for */
const displayCourseSelection = ref(false);
/* Method to route to the project creation view */
const createProjectForCourse = (courseId: string): void => {
push({ name: 'project-create', params: { courseId } });
displayCourseSelection.value = false;
};
</script>

<template>
<!-- Button to create a new project -->
<Button
v-if="props.courses && props.courses.length > 0"
:icon="PrimeIcons.PLUS"
icon-pos="right"
class="custom-button"
@click="displayCourseSelection = true"
/>
<!-- Dialog to select the course you want to create a project for -->
<Dialog
v-model:visible="displayCourseSelection"
modal
:draggable="false"
:contentStyle="{ width: '50vw' }"
:header="t('views.dashboard.select_course')"
>
<!-- List of courses to select from-->
<div v-if="props.courses && props.courses.length > 0">
<div
v-for="course in props.courses"
:key="course.id"
class="course-item"
@click="createProjectForCourse(course.id)"
>
<span class="course-name">{{ course.name }}</span>
</div>
</div>
</Dialog>
</template>

<style scoped lang="scss">
.course-item {
cursor: pointer;
padding: 8px;
border-radius: 4px;
margin-bottom: 8px;
transition: background-color 0.3s;
}
.course-item:hover {
background-color: #f0f0f0;
}
.course-name {
font-weight: bold;
}
</style>
2 changes: 1 addition & 1 deletion frontend/src/composables/services/project.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function useProject(): ProjectState {
visible: projectData.visible,
archived: projectData.archived,
locked_groups: projectData.locked_groups,
start_data: projectData.start_date,
start_date: projectData.start_date,
deadline: projectData.deadline,
max_score: projectData.max_score,
score_visible: projectData.score_visible,
Expand Down
45 changes: 8 additions & 37 deletions frontend/src/router/router.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// import { useUserStore } from '@/stores/userStore';
// TODO: after pinia setup is done

import DashboardView from '@/views/dashboard/DashboardView.vue';
import CourseView from '@/views/courses/CourseView.vue';
import CreateCourseView from '@/views/courses/CreateCourseView.vue';
import CreateProjectView from '@/views/projects/CreateProjectView.vue';
import Dummy from '@/components/Dummy.vue';
import LoginView from '@/views/authentication/LoginView.vue';
import CalendarView from '@/views/calendar/CalendarView.vue';
Expand Down Expand Up @@ -36,11 +34,7 @@ const routes: RouteRecordRaw[] = [
path: '/courses',
children: [
{ path: '', component: SearchCourseView, name: 'courses' },
{
path: 'create',
component: CreateCourseView,
name: 'course-create',
},
{ path: 'create', component: CreateCourseView, name: 'course-create' },
// Single course
{
path: ':courseId',
Expand All @@ -52,35 +46,15 @@ const routes: RouteRecordRaw[] = [
path: 'projects',
children: [
{ path: '', component: Dummy, name: 'projects' },
{
path: 'create',
component: Dummy,
name: 'project-create',
},
{ path: 'create', component: CreateProjectView, name: 'project-create' },
// Single project
{
path: ':projectId',
children: [
{
path: '',
component: ProjectView,
name: 'project',
},
{
path: 'edit',
component: Dummy,
name: 'project-edit',
},
{
path: 'groups',
component: Dummy,
name: 'project-groups',
},
{
path: 'submit',
component: Dummy,
name: 'project-submit',
},
{ path: '', component: ProjectView, name: 'project' },
{ path: 'edit', component: Dummy, name: 'project-edit' },
{ path: 'groups', component: Dummy, name: 'project-groups' },
{ path: 'submit', component: Dummy, name: 'project-submit' },
],
},
],
Expand Down Expand Up @@ -138,10 +112,7 @@ const routes: RouteRecordRaw[] = [
{ path: '/notifications/:id', component: Dummy, name: 'notification' },

// Authentication
{
path: '/auth/',
children: [{ path: 'login', component: LoginView, name: 'login' }],
},
{ path: '/auth/', children: [{ path: 'login', component: LoginView, name: 'login' }] },

// Page not found: redirect to dashboard
{ path: '/:pathMatch(.*)*', redirect: { name: 'dashboard' } },
Expand Down
Loading

0 comments on commit 62a6a08

Please sign in to comment.