refactor(frontend): Linting errors wegwerken
This commit is contained in:
parent
e2ec28bbfb
commit
a5e095b852
10 changed files with 72 additions and 69 deletions
|
@ -71,7 +71,7 @@ export default [
|
|||
'init-declarations': 'off',
|
||||
'@typescript-eslint/init-declarations': 'off',
|
||||
'max-params': 'off',
|
||||
'@typescript-eslint/max-params': ['error', { max: 6 }],
|
||||
'@typescript-eslint/max-params': 'off',
|
||||
'@typescript-eslint/member-ordering': 'error',
|
||||
'@typescript-eslint/method-signature-style': 'off', // Don't care about TypeScript strict mode.
|
||||
'@typescript-eslint/naming-convention': [
|
||||
|
@ -87,6 +87,7 @@ export default [
|
|||
modifiers: ['const'],
|
||||
format: ['camelCase', 'UPPER_CASE'],
|
||||
trailingUnderscore: 'allow',
|
||||
leadingUnderscore: 'allow',
|
||||
},
|
||||
{
|
||||
// Enforce that private members are prefixed with an underscore
|
||||
|
|
|
@ -1,20 +1,22 @@
|
|||
import { SubmissionController, type SubmissionResponse } from "@/controllers/submissions";
|
||||
import type { SubmissionDTO } from "@dwengo-1/common/interfaces/submission";
|
||||
import { SubmissionController, type SubmissionResponse } from '@/controllers/submissions';
|
||||
import type { SubmissionDTO } from '@dwengo-1/common/interfaces/submission';
|
||||
import {
|
||||
QueryClient,
|
||||
useMutation,
|
||||
type UseMutationReturnType,
|
||||
useQuery,
|
||||
useQueryClient,
|
||||
type UseMutationReturnType,
|
||||
type UseQueryReturnType,
|
||||
} from "@tanstack/vue-query";
|
||||
import { computed, toValue, type MaybeRefOrGetter } from "vue";
|
||||
import { LEARNING_PATH_KEY } from "@/queries/learning-paths.ts";
|
||||
import { LEARNING_OBJECT_KEY } from "@/queries/learning-objects.ts";
|
||||
import type { Language } from "@dwengo-1/common/util/language";
|
||||
} from '@tanstack/vue-query';
|
||||
import { computed, type MaybeRefOrGetter, toValue } from 'vue';
|
||||
import { LEARNING_PATH_KEY } from '@/queries/learning-paths.ts';
|
||||
import { LEARNING_OBJECT_KEY } from '@/queries/learning-objects.ts';
|
||||
import { Language } from '@dwengo-1/common/util/language';
|
||||
|
||||
export const SUBMISSION_KEY = "submissions";
|
||||
|
||||
type SubmissionQueryKey = ["submission", string, Language | undefined, number, string, number, number, number];
|
||||
|
||||
function submissionQueryKey(
|
||||
hruid: string,
|
||||
language: Language,
|
||||
|
@ -23,7 +25,7 @@ function submissionQueryKey(
|
|||
assignmentNumber: number,
|
||||
groupNumber: number,
|
||||
submissionNumber: number,
|
||||
) {
|
||||
): SubmissionQueryKey {
|
||||
return ["submission", hruid, language, version, classid, assignmentNumber, groupNumber, submissionNumber];
|
||||
}
|
||||
|
||||
|
@ -39,19 +41,21 @@ export async function invalidateAllSubmissionKeys(
|
|||
): Promise<void> {
|
||||
const keys = ["submission"];
|
||||
|
||||
for (const key of keys) {
|
||||
const queryKey = [
|
||||
key,
|
||||
hruid,
|
||||
language,
|
||||
version,
|
||||
classid,
|
||||
assignmentNumber,
|
||||
groupNumber,
|
||||
submissionNumber,
|
||||
].filter((arg) => arg !== undefined);
|
||||
await queryClient.invalidateQueries({ queryKey: queryKey });
|
||||
}
|
||||
await Promise.all(
|
||||
keys.map(async (key) => {
|
||||
const queryKey = [
|
||||
key,
|
||||
hruid,
|
||||
language,
|
||||
version,
|
||||
classid,
|
||||
assignmentNumber,
|
||||
groupNumber,
|
||||
submissionNumber,
|
||||
].filter((arg) => arg !== undefined);
|
||||
return queryClient.invalidateQueries({ queryKey: queryKey });
|
||||
})
|
||||
)
|
||||
|
||||
await queryClient.invalidateQueries({
|
||||
queryKey: ["submissions", hruid, language, version, classid, assignmentNumber, groupNumber].filter(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export function copyArrayWith<T>(index: number, newValue: T, array: T[]) {
|
||||
export function copyArrayWith<T>(index: number, newValue: T, array: T[]): T[] {
|
||||
const copy = [...array];
|
||||
copy[index] = newValue;
|
||||
return copy;
|
||||
|
|
|
@ -3,7 +3,7 @@ export function deepEquals<T>(a: T, b: T): boolean {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (typeof a !== "object" || typeof b !== "object" || a == null || b == null) {
|
||||
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
<script setup lang="ts">
|
||||
import { Language } from "@/data-objects/language.ts";
|
||||
import type { LearningPath } from "@/data-objects/learning-paths/learning-path.ts";
|
||||
import { computed, type ComputedRef, ref } from "vue";
|
||||
import type { LearningObject } from "@/data-objects/learning-objects/learning-object.ts";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import LearningObjectView from "@/views/learning-paths/learning-object/LearningObjectView.vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import LearningPathSearchField from "@/components/LearningPathSearchField.vue";
|
||||
import { useGetLearningPathQuery } from "@/queries/learning-paths.ts";
|
||||
import { useLearningObjectListForPathQuery } from "@/queries/learning-objects.ts";
|
||||
import UsingQueryResult from "@/components/UsingQueryResult.vue";
|
||||
import authService from "@/services/auth/auth-service.ts";
|
||||
import { LearningPathNode } from "@/data-objects/learning-paths/learning-path-node.ts";
|
||||
import LearningPathGroupSelector from "@/views/learning-paths/LearningPathGroupSelector.vue";
|
||||
import { Language } from '@/data-objects/language.ts';
|
||||
import type { LearningPath } from '@/data-objects/learning-paths/learning-path.ts';
|
||||
import { computed, type ComputedRef, ref } from 'vue';
|
||||
import type { LearningObject } from '@/data-objects/learning-objects/learning-object.ts';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import LearningObjectView from '@/views/learning-paths/learning-object/LearningObjectView.vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import LearningPathSearchField from '@/components/LearningPathSearchField.vue';
|
||||
import { useGetLearningPathQuery } from '@/queries/learning-paths.ts';
|
||||
import { useLearningObjectListForPathQuery } from '@/queries/learning-objects.ts';
|
||||
import UsingQueryResult from '@/components/UsingQueryResult.vue';
|
||||
import authService from '@/services/auth/auth-service.ts';
|
||||
import { LearningPathNode } from '@/data-objects/learning-paths/learning-path-node.ts';
|
||||
import LearningPathGroupSelector from '@/views/learning-paths/LearningPathGroupSelector.vue';
|
||||
|
||||
const router = useRouter();
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
|
||||
|
@ -40,6 +40,7 @@
|
|||
classId: query.value.classId,
|
||||
};
|
||||
}
|
||||
return undefined
|
||||
});
|
||||
|
||||
const learningPathQueryResult = useGetLearningPathQuery(props.hruid, props.language, forGroup);
|
||||
|
@ -108,15 +109,15 @@
|
|||
|
||||
const forGroupQueryParam = computed<number | undefined>({
|
||||
get: () => route.query.forGroup,
|
||||
set: (value: number | undefined) => {
|
||||
let query = structuredClone(route.query);
|
||||
set: async (value: number | undefined) => {
|
||||
const query = structuredClone(route.query);
|
||||
query.forGroup = value;
|
||||
router.push({ query });
|
||||
await router.push({ query });
|
||||
},
|
||||
});
|
||||
|
||||
function assign() {
|
||||
router.push({
|
||||
async function assign(): Promise<void> {
|
||||
await router.push({
|
||||
path: "/assignment/create",
|
||||
query: {
|
||||
hruid: props.hruid,
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import LearningObjectContentView from "@/views/learning-paths/learning-object/content/LearningObjectContentView.vue";
|
||||
import LearningObjectSubmissionsView from "@/views/learning-paths/learning-object/submissions/LearningObjectSubmissionsView.vue";
|
||||
|
||||
const isStudent = computed(() => authService.authState.activeRole === "student");
|
||||
const _isStudent = computed(() => authService.authState.activeRole === "student");
|
||||
|
||||
const props = defineProps<{
|
||||
hruid: string;
|
||||
|
|
|
@ -9,18 +9,19 @@
|
|||
submissionData?: SubmissionData;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: "update:submissionData", value: SubmissionData): void;
|
||||
}>();
|
||||
const emit = defineEmits<(e: "update:submissionData", value: SubmissionData) => void>();
|
||||
|
||||
const submissionData = computed<SubmissionData | undefined>({
|
||||
get: () => props.submissionData,
|
||||
set: (v?: SubmissionData) => (v ? emit("update:submissionData", v) : undefined),
|
||||
set: (v?: SubmissionData): void => {
|
||||
if (v)
|
||||
emit("update:submissionData", v)
|
||||
},
|
||||
});
|
||||
|
||||
function forEachQuestion(
|
||||
doAction: (questionIndex: number, questionName: string, questionType: string, questionElement: Element) => void,
|
||||
) {
|
||||
): void {
|
||||
const questions = document.querySelectorAll(".gift-question");
|
||||
questions.forEach((question) => {
|
||||
const name = question.id.match(/gift-q(\d+)/)?.[1];
|
||||
|
@ -45,8 +46,8 @@
|
|||
});
|
||||
}
|
||||
|
||||
function setAnswers(answers: SubmissionData) {
|
||||
forEachQuestion((index, name, type, element) => {
|
||||
function setAnswers(answers: SubmissionData): void {
|
||||
forEachQuestion((index, _name, type, element) => {
|
||||
const answer = answers[index];
|
||||
if (answer !== null && answer !== undefined) {
|
||||
getGiftAdapterForType(type)?.setAnswer(element, answer);
|
||||
|
@ -57,7 +58,7 @@
|
|||
submissionData.value = answers;
|
||||
}
|
||||
|
||||
onMounted(() =>
|
||||
onMounted(async () =>
|
||||
nextTick(() => {
|
||||
attachQuestionListeners();
|
||||
setAnswers(props.submissionData ?? []);
|
||||
|
|
|
@ -8,9 +8,7 @@
|
|||
const props = defineProps<{
|
||||
allSubmissions: SubmissionDTO[];
|
||||
}>();
|
||||
const emit = defineEmits<{
|
||||
(e: "submission-selected", submission: SubmissionDTO): void;
|
||||
}>();
|
||||
const emit = defineEmits<(e: "submission-selected", submission: SubmissionDTO) => void>();
|
||||
|
||||
const headers = computed(() => [
|
||||
{ title: "#", value: "submissionNo", width: "50px" },
|
||||
|
@ -30,7 +28,7 @@
|
|||
})),
|
||||
);
|
||||
|
||||
function selectSubmission(submission: SubmissionDTO) {
|
||||
function selectSubmission(submission: SubmissionDTO): void {
|
||||
emit("submission-selected", submission);
|
||||
}
|
||||
</script>
|
||||
|
@ -46,7 +44,7 @@
|
|||
hide-default-footer
|
||||
:no-data-text="t('noSubmissionsYet')"
|
||||
>
|
||||
<template v-slot:item.action="{ item }">
|
||||
<template v-slot:[`item.action`]="{ item }">
|
||||
<v-btn
|
||||
density="compact"
|
||||
variant="plain"
|
||||
|
|
|
@ -18,9 +18,7 @@
|
|||
version: number;
|
||||
group: { forGroup: number; assignmentNo: number; classId: string };
|
||||
}>();
|
||||
const emit = defineEmits<{
|
||||
(e: "update:submissionData", value: SubmissionData): void;
|
||||
}>();
|
||||
const emit = defineEmits<(e: "update:submissionData", value: SubmissionData) => void>();
|
||||
|
||||
const submissionQuery = useSubmissionsQuery(
|
||||
() => props.hruid,
|
||||
|
@ -32,11 +30,11 @@
|
|||
() => true,
|
||||
);
|
||||
|
||||
function emitSubmissionData(submissionData: SubmissionData) {
|
||||
function emitSubmissionData(submissionData: SubmissionData): void {
|
||||
emit("update:submissionData", submissionData);
|
||||
}
|
||||
|
||||
function emitSubmission(submission: SubmissionDTO) {
|
||||
function emitSubmission(submission: SubmissionDTO): void {
|
||||
emitSubmissionData(JSON.parse(submission.content));
|
||||
}
|
||||
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
|
||||
const {
|
||||
isPending: submissionIsPending,
|
||||
isError: submissionFailed,
|
||||
error: submissionError,
|
||||
isSuccess: submissionSuccess,
|
||||
// - isError: submissionFailed,
|
||||
// - error: submissionError,
|
||||
// - isSuccess: submissionSuccess,
|
||||
mutate: submitSolution,
|
||||
} = useCreateSubmissionMutation();
|
||||
|
||||
|
@ -47,11 +47,11 @@
|
|||
});
|
||||
|
||||
function submitCurrentAnswer(): void {
|
||||
const { forGroup, assignmentNo, classId } = props.group!;
|
||||
const { forGroup, assignmentNo, classId } = props.group;
|
||||
const currentUser: UserProfile = authService.authState.user!.profile;
|
||||
const learningObjectIdentifier: LearningObjectIdentifierDTO = {
|
||||
hruid: props.hruid,
|
||||
language: props.language as Language,
|
||||
language: props.language,
|
||||
version: props.version,
|
||||
};
|
||||
const submitter: StudentDTO = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue