Skip to content

Commit

Permalink
lint format
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiscauwel committed May 21, 2024
1 parent 27716b4 commit def8cac
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const props = defineProps<{
isSubjectMailError: boolean;
}>();
const { currentUserAsInstructor} = toRefs(props);
const { currentUserAsInstructor } = toRefs(props);
const checkbox = ref(currentUserAsInstructor.value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import ModifySubjectHeaderImage from "@/components/subject/modify/header/ModifyS
defineProps<{
title: string;
imagePath: string;
subjectName: string,
academicYear: number,
subjectMail: string,
subjectName: string;
academicYear: number;
subjectMail: string;
currentUserAsInstructor: boolean;
isSubjectNameError: boolean;
isSubjectMailError: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@
</v-card-text>
</v-col>
<v-col v-if="isAdmin || (isInstructor && isTeacher)" cols="1">
<router-link :to="{ name: 'edit-subject', params: { subjectId: subjectId } }" class="link">
<router-link
:to="{ name: 'edit-subject', params: { subjectId: subjectId } }"
class="link"
>
<v-icon size="large">mdi-square-edit-outline</v-icon>
</router-link>
</v-col>
Expand All @@ -50,7 +53,7 @@ import useIsAdmin from "@/composables/useIsAdmin";
import useIsTeacher from "@/composables/useIsTeacher";
defineProps<{
subjectId: number
subjectId: number;
title: string;
academicYear: number;
instructors: User[];
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const router = createRouter({
component: () => import("../views/subject/modify/CreateSubjectView.vue"),
},
{
path: "/subjects/:subjectId(\\d+)/edit",
path: "/subjects/:subjectId(\\d+)/edit",
name: "edit-subject",
component: () => import("../views/subject/modify/PatchSubjectView.vue"),
props: (route) => ({ subjectId: Number(route.params.subjectId) }),
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/services/subject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,3 @@ export async function deleteSubjectInstructor(subjectId: number, uid: string): P
method: "DELETE",
});
}


82 changes: 46 additions & 36 deletions frontend/src/views/subject/modify/PatchSubjectView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@
<v-btn color="blue darken-1" @click="dialog = false">
{{ $t("default.no_capital") }}
</v-btn>
<v-btn color="blue darken-1" @click="router.push({ name: 'subject' , params: {subjectId: subjectId}})">
<v-btn
color="blue darken-1"
@click="
router.push({
name: 'subject',
params: { subjectId: subjectId },
})
"
>
{{ $t("default.yes_capital") }}
</v-btn>
</v-card-actions>
Expand Down Expand Up @@ -70,23 +78,20 @@
</template>

<script setup lang="ts">
import {computed, ref, toRefs} from "vue";
import {
useSubjectInstructorsQuery,
useSubjectQuery,
} from "@/queries/Subject";
import { computed, ref, toRefs } from "vue";
import { useSubjectInstructorsQuery, useSubjectQuery } from "@/queries/Subject";
import type SubjectForm from "@/models/Subject";
import type User from "@/models/User";
import {useCurrentUserQuery} from "@/queries/User";
import {useRouter} from "vue-router";
import { useCurrentUserQuery } from "@/queries/User";
import { useRouter } from "vue-router";
import ModifySubjectHeaderContainer from "@/components/subject/modify/header/ModifySubjectHeaderContainer.vue";
import ModifySubjectBody from "@/components/subject/modify/body/ModifySubjectBody.vue";
const props = defineProps<{
subjectId: number;
}>();
const {subjectId} = toRefs(props);
const { subjectId } = toRefs(props);
const snackbar = ref(false);
const dialog = ref(false);
Expand All @@ -104,12 +109,12 @@ const subjectMailChanged = ref(false);
const {
data: currentUser,
isLoading: isCurrentUserLoading,
isError: isCurrentUserError
isError: isCurrentUserError,
} = useCurrentUserQuery();
const {
data: subject,
isLoading: isSubjectLoading,
isError: isSubjectError
isError: isSubjectError,
} = useSubjectQuery(subjectId);
const {
data: instructors,
Expand All @@ -118,46 +123,51 @@ const {
} = useSubjectInstructorsQuery(subjectId);
const isLoading = computed(
() =>
isCurrentUserLoading.value ||
isSubjectLoading.value ||
isInstructorsLoading.value
() => isCurrentUserLoading.value || isSubjectLoading.value || isInstructorsLoading.value
);
const isError = computed(
() =>
isCurrentUserError.value ||
isSubjectError.value ||
isInstructorsError.value
() => isCurrentUserError.value || isSubjectError.value || isInstructorsError.value
);
const isInstructor = computed(() => {
return shownInstructors.value.some((instructor) => instructor?.uid === currentUser.value?.uid);
});
const isCurrentInstructor = (user: User) => {
return new Set([...(instructors.value || [])].map((instructor) => instructor.uid)).has(user.uid)
}
return new Set([...(instructors.value || [])].map((instructor) => instructor.uid)).has(
user.uid
);
};
const name = computed<string | null>(() => subjectNameChanged.value ? subjectName.value : subject.value?.name);
const academicYear = computed<number | null>(() => activeAcademicYear.value || subject.value?.academic_year);
const mail = computed<string | null>(() => subjectMailChanged.value ? subjectMail.value : subject.value?.email);
const name = computed<string | null>(() =>
subjectNameChanged.value ? subjectName.value : subject.value?.name
);
const academicYear = computed<number | null>(
() => activeAcademicYear.value || subject.value?.academic_year
);
const mail = computed<string | null>(() =>
subjectMailChanged.value ? subjectMail.value : subject.value?.email
);
const router = useRouter();
const shownInstructors = computed(() => {
return Array.from(new Set([...(instructors.value || []), ...addedInstructors.value].filter((instructor: User) => {
return !removedInstructorUIDs.value.has(instructor.uid);
}))).sort((a, b) => {
return Array.from(
new Set(
[...(instructors.value || []), ...addedInstructors.value].filter((instructor: User) => {
return !removedInstructorUIDs.value.has(instructor.uid);
})
)
).sort((a, b) => {
if (a?.is_teacher && !b?.is_teacher) {
return -1;
} else if (!a?.is_teacher && b?.is_teacher) {
return 1;
} else {
return a?.surname.localeCompare(b?.surname);
}
})
});
});
const addInstructor = (instructor: User) => {
Expand All @@ -166,7 +176,6 @@ const addInstructor = (instructor: User) => {
} else {
addedInstructors.value.add(instructor);
}
};
const removeInstructor = (instructor: User) => {
Expand Down Expand Up @@ -218,7 +227,6 @@ const validateInstructors = () => {
};
async function handleSubmit() {
if (!validateSubjectName()) {
isSubjectNameError.value = true;
return;
Expand All @@ -237,14 +245,16 @@ async function handleSubmit() {
const subjectData: SubjectForm = {
name: name.value.trim().charAt(0).toUpperCase() + name.value.trim().slice(1),
email: mail.value,
academic_year: academicYear.value
academic_year: academicYear.value,
};
const addedInstructorUIDs = Array.from(addedInstructors.value).map((instructor) => instructor.uid);
const addedInstructorUIDs = Array.from(addedInstructors.value).map(
(instructor) => instructor.uid
);
console.log(subjectData)
console.log(addedInstructorUIDs)
console.log(removedInstructorUIDs.value)
console.log(subjectData);
console.log(addedInstructorUIDs);
console.log(removedInstructorUIDs.value);
/*
try {
Expand Down

0 comments on commit def8cac

Please sign in to comment.