Fix some typescript warnings

This commit is contained in:
Daniel Egger 2022-08-31 12:23:05 +02:00
parent 2316150375
commit 911b974360
8 changed files with 39 additions and 48 deletions

View File

@ -1,2 +1,2 @@
nodejs 16.10.0 nodejs 16.17.0
python 3.10.5 python 3.10.5

View File

@ -7,7 +7,7 @@
"build:tailwind": "tailwindcss -i tailwind.css -o ../server/vbv_lernwelt/static/css/tailwind.css --minify", "build:tailwind": "tailwindcss -i tailwind.css -o ../server/vbv_lernwelt/static/css/tailwind.css --minify",
"test": "vitest run", "test": "vitest run",
"coverage": "vitest run --coverage", "coverage": "vitest run --coverage",
"typecheck": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false", "typecheck": "vue-tsc --noEmit -p tsconfig.app.json --composite false",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore", "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
"tailwind": "tailwindcss -i tailwind.css -o ../server/vbv_lernwelt/static/css/tailwind.css --watch" "tailwind": "tailwindcss -i tailwind.css -o ../server/vbv_lernwelt/static/css/tailwind.css --watch"
}, },
@ -30,6 +30,7 @@
"@testing-library/vue": "^6.6.1", "@testing-library/vue": "^6.6.1",
"@types/d3": "^7.4.0", "@types/d3": "^7.4.0",
"@types/jsdom": "^20.0.0", "@types/jsdom": "^20.0.0",
"@types/lodash": "^4.14.184",
"@types/node": "^18.7.14", "@types/node": "^18.7.14",
"@vitejs/plugin-vue": "^3.0.3", "@vitejs/plugin-vue": "^3.0.3",
"@vue/eslint-config-prettier": "^7.0.0", "@vue/eslint-config-prettier": "^7.0.0",

View File

@ -1,27 +1,23 @@
<script setup lang="ts"> <script setup lang="ts">
import {Circle} from '@/services/circle'; import { Circle } from '@/services/circle'
import ItFullScreenModal from '@/components/ui/ItFullScreenModal.vue' import ItFullScreenModal from '@/components/ui/ItFullScreenModal.vue'
const props = defineProps<{ const props = defineProps<{
circle: Circle, circle: Circle
show: boolean show: boolean
}>() }>()
const emits = defineEmits(['closemodal']) // const emits = defineEmits(['closemodal'])
</script> </script>
<template> <template>
<ItFullScreenModal <ItFullScreenModal :show="show" @closemodal="$emit('closemodal')">
:show="show"
@closemodal="$emit('closemodal')"
>
<h1 class="">Überblick: Circle "{{ circle.title }}"</h1> <h1 class="">Überblick: Circle "{{ circle.title }}"</h1>
<p class="mt-8 text-xl">Hier zeigen wir dir, was du in diesem Circle lernen wirst.</p> <p class="mt-8 text-xl">Hier zeigen wir dir, was du in diesem Circle lernen wirst.</p>
<div class="mt-8 p-4 border border-gray-500"> <div class="mt-8 p-4 border border-gray-500">
<h3>Du wirst in der Lage sein, ... </h3> <h3>Du wirst in der Lage sein, ...</h3>
<ul class="mt-4"> <ul class="mt-4">
<li class="text-xl flex items-center" v-for="goal in circle.goals" :key="goal.id"> <li class="text-xl flex items-center" v-for="goal in circle.goals" :key="goal.id">
@ -31,9 +27,7 @@ const emits = defineEmits(['closemodal'])
</ul> </ul>
</div> </div>
<h3 class="mt-16"> <h3 class="mt-16">Du wirst dein neu erworbenes Wissen auf folgenden berufstypischen Situation anwenden können:</h3>
Du wirst dein neu erworbenes Wissen auf folgenden berufstypischen Situation anwenden können:
</h3>
<ul class="grid grid-cols-1 lg:grid-cols-3 auto-rows-fr gap-6 mt-8"> <ul class="grid grid-cols-1 lg:grid-cols-3 auto-rows-fr gap-6 mt-8">
<li <li
@ -41,11 +35,10 @@ const emits = defineEmits(['closemodal'])
:key="jobSituation.id" :key="jobSituation.id"
class="job-situation border border-gray-500 p-4 text-xl flex items-center" class="job-situation border border-gray-500 p-4 text-xl flex items-center"
> >
{{jobSituation.value}} {{ jobSituation.value }}
</li> </li>
</ul> </ul>
</ItFullScreenModal> </ItFullScreenModal>
</template> </template>
<style scoped> <style scoped></style>
</style>

View File

@ -37,7 +37,7 @@ const block = computed(() => {
<span class="hidden lg:inline">zurück zum Circle</span> <span class="hidden lg:inline">zurück zum Circle</span>
</button> </button>
<h1 class="text-xl hidden lg:block">{{ learningContent.title }}</h1> <h1 class="text-xl hidden lg:block">{{ learningContent?.title }}</h1>
<button <button
type="button" type="button"

View File

@ -6,6 +6,7 @@ import type {
LearningContent, LearningContent,
LearningSequence, LearningSequence,
LearningUnit, LearningUnit,
LearningUnitQuestion,
LearningWagtailPage, LearningWagtailPage,
} from '@/types' } from '@/types'
import type { LearningPath } from '@/services/learningPath' import type { LearningPath } from '@/services/learningPath'
@ -146,8 +147,8 @@ export class Circle implements LearningWagtailPage {
) )
} }
public get flatChildren(): CircleChild[] { public get flatChildren(): (LearningContent | LearningUnitQuestion)[] {
const result: CircleChild[] = []; const result: (LearningContent | LearningUnitQuestion)[] = [];
this.learningSequences.forEach((learningSequence) => { this.learningSequences.forEach((learningSequence) => {
learningSequence.learningUnits.forEach((learningUnit) => { learningSequence.learningUnits.forEach((learningUnit) => {
learningUnit.children.forEach((learningUnitQuestion) => { learningUnit.children.forEach((learningUnitQuestion) => {

View File

@ -59,29 +59,33 @@ export class LearningPath implements LearningWagtailPage {
this.topics.push(topic) this.topics.push(topic)
} }
this.calcNextLearningContent(completionData); this.calcNextLearningContent(completionData)
} }
public calcNextLearningContent(completionData: CircleCompletion[]): void { public calcNextLearningContent(completionData: CircleCompletion[]): void {
this.nextLearningContent = undefined; this.nextLearningContent = undefined
const lastCompletedLearningContent = getLastCompleted(this.translation_key, completionData); const lastCompletedLearningContent = getLastCompleted(this.translation_key, completionData)
if (lastCompletedLearningContent) { if (lastCompletedLearningContent) {
const lastCircle = this.circles.find(circle => circle.translation_key === lastCompletedLearningContent.circle_key); const lastCircle = this.circles.find(
(circle) => circle.translation_key === lastCompletedLearningContent.circle_key
)
if (lastCircle) { if (lastCircle) {
const lastLearningContent = lastCircle.flatLearningContents.find(learningContent => learningContent.translation_key === lastCompletedLearningContent.page_key); const lastLearningContent = lastCircle.flatLearningContents.find(
(learningContent) => learningContent.translation_key === lastCompletedLearningContent.page_key
)
if (lastLearningContent && lastLearningContent.nextLearningContent) { if (lastLearningContent && lastLearningContent.nextLearningContent) {
this.nextLearningContent = lastLearningContent.nextLearningContent; this.nextLearningContent = lastLearningContent.nextLearningContent
} else { } else {
if (lastCircle.nextCircle) { if (lastCircle.nextCircle) {
this.nextLearningContent = lastCircle.nextCircle.flatLearningContents[0]; this.nextLearningContent = lastCircle.nextCircle.flatLearningContents[0]
} }
} }
} }
} else { } else {
if (this.circles[0]) { if (this.circles[0]) {
this.nextLearningContent = this.circles[0].flatLearningContents[0]; this.nextLearningContent = this.circles[0].flatLearningContents[0]
} }
} }
} }

View File

@ -1,30 +1,27 @@
<script setup lang="ts"> <script setup lang="ts">
import * as log from 'loglevel'; import * as log from 'loglevel'
import {reactive} from 'vue'; import { reactive } from 'vue'
import {useUserStore} from '@/stores/user'; import { useUserStore } from '@/stores/user'
import {useRoute} from 'vue-router'; import { useRoute } from 'vue-router'
const route = useRoute() const route = useRoute()
log.debug('LoginView.vue created'); log.debug('LoginView.vue created')
log.debug(route.query); log.debug(route.query)
const state = reactive({ const state = reactive({
username: '', username: '',
password: '', password: '',
}); })
const userStore = useUserStore();
const userStore = useUserStore()
</script> </script>
<template> <template>
<main class="px-8 py-8"> <main class="px-8 py-8">
<h1>Login</h1> <h1>Login</h1>
<form <form @submit.prevent="userStore.handleLogin(state.username, state.password, route.query.next)">
@submit.prevent="userStore.handleLogin(state.username, state.password, route.query.next)"
>
<div class="mt-8 mb-4"> <div class="mt-8 mb-4">
<label class="block mb-1" for="email">Username</label> <label class="block mb-1" for="email">Username</label>
<input <input
@ -47,17 +44,11 @@ const userStore = useUserStore();
</div> </div>
<div> <div>
<input <input data-cy="login-button" type="submit" value="Login" class="btn-primary" />
data-cy="login-button"
type="submit"
value="Login"
class="btn-primary"
/>
</div> </div>
</form> </form>
<p class="pt-8"><a href="/sso/login/">Login mit SSO</a></p> <p class="pt-8"><a href="/sso/login/">Login mit SSO</a></p>
</main> </main>
</template> </template>
<style scoped> <style scoped></style>
</style>

View File

@ -5,6 +5,7 @@
"compilerOptions": { "compilerOptions": {
"composite": true, "composite": true,
"strict": true, "strict": true,
"allowJs": true,
"baseUrl": ".", "baseUrl": ".",
"paths": { "paths": {
"@/*": ["./src/*"] "@/*": ["./src/*"]