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