update
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<script setup>
|
||||
import { ref, computed, watch, onMounted, onUnmounted, nextTick } from 'vue'
|
||||
import { fetchGuides, fetchTopics, createTopic as apiCreateTopic, deleteTopic as apiDeleteTopic, createGuide as apiCreate, deleteGuide, cancelGuide as apiCancel, fetchBausteineStatus, fetchActiveBausteine, createBausteine as apiCreateBausteine, cancelBausteine as apiCancelBausteine, deleteBausteine as apiDeleteBausteine, fetchProjects, deleteProject as apiDeleteProject, fetchProviders, fetchStats } from './api.js'
|
||||
import { fetchGuides, fetchTopics, createTopic as apiCreateTopic, deleteTopic as apiDeleteTopic, createGuide as apiCreate, deleteGuide, cancelGuide as apiCancel, fetchBausteineStatus, fetchActiveBausteine, createBausteine as apiCreateBausteine, cancelBausteine as apiCancelBausteine, deleteBausteine as apiDeleteBausteine, fetchProjects, deleteProject as apiDeleteProject, fetchProviders, fetchStats, fetchTopicFortschritt } from './api.js'
|
||||
import TopicSidebar from './components/TopicSidebar.vue'
|
||||
import TopicDetail from './components/TopicDetail.vue'
|
||||
|
||||
@@ -22,6 +22,7 @@ const activeBausteine = ref([])
|
||||
const provider = ref(localStorage.getItem('provider') || 'claude')
|
||||
const providers = ref([])
|
||||
const stats = ref(null)
|
||||
const fortschritt = ref({})
|
||||
|
||||
async function loadStats() {
|
||||
try {
|
||||
@@ -145,8 +146,10 @@ async function loadBausteine() {
|
||||
activeBausteine.value = await fetchActiveBausteine()
|
||||
if (selectedTopic.value) {
|
||||
bausteine.value = await fetchBausteineStatus(selectedTopic.value)
|
||||
fortschritt.value = await fetchTopicFortschritt(selectedTopic.value)
|
||||
} else {
|
||||
bausteine.value = { ...EMPTY_BAUSTEINE }
|
||||
fortschritt.value = {}
|
||||
}
|
||||
if (activeBausteine.value.length && !pollTimer) startPolling()
|
||||
} catch (e) {
|
||||
@@ -325,6 +328,7 @@ onUnmounted(() => {
|
||||
:projects="projectNames"
|
||||
:selectedTopic="selectedTopic"
|
||||
:stats="stats"
|
||||
:fortschritt="fortschritt"
|
||||
:doneByFormat="doneByFormat"
|
||||
:latestByFormat="latestByFormat"
|
||||
:allGuides="guides"
|
||||
@@ -357,7 +361,7 @@ onUnmounted(() => {
|
||||
:previewGuide="previewGuide"
|
||||
:dark="darkMode"
|
||||
:provider="provider"
|
||||
@progressChanged="loadStats"
|
||||
@progressChanged="loadStats(); loadBausteine()"
|
||||
/>
|
||||
<div v-else class="empty-main">
|
||||
<p>Thema in der Sidebar anlegen oder auswählen.</p>
|
||||
|
||||
@@ -41,6 +41,11 @@ export async function deleteBausteine(topic) {
|
||||
await fetch(`${BASE}/bausteine?topic=${encodeURIComponent(topic)}`, { method: 'DELETE' })
|
||||
}
|
||||
|
||||
export async function fetchTopicFortschritt(topic) {
|
||||
const res = await fetch(`${BASE}/topics/fortschritt?topic=${encodeURIComponent(topic)}`)
|
||||
return res.json()
|
||||
}
|
||||
|
||||
export async function fetchStats() {
|
||||
const res = await fetch(`${BASE}/stats`)
|
||||
return res.json()
|
||||
|
||||
@@ -6,6 +6,7 @@ const props = defineProps({
|
||||
projects: { type: Array, default: () => [] },
|
||||
selectedTopic: { type: String, default: null },
|
||||
stats: { type: Object, default: null },
|
||||
fortschritt: { type: Object, default: () => ({}) },
|
||||
doneByFormat: { type: Object, default: () => ({}) },
|
||||
latestByFormat: { type: Object, default: () => ({}) },
|
||||
allGuides: { type: Array, default: () => [] },
|
||||
@@ -146,8 +147,10 @@ function handleFormatClick(format) {
|
||||
}
|
||||
}
|
||||
|
||||
// Lernschulden-Regel: JE Format max. 5 erstellte, aber nicht absolvierte Guides —
|
||||
// darüber sind nur Neu-Generierungen bereits erstellter Guides erlaubt.
|
||||
// Lernschulden-Regeln (nur Neu-Erstellungen; Resume + Neu-Generieren bestehender erlaubt):
|
||||
// Progression pro Thema (MiniGuide → Guide → FullGuide) + max. 3 offene je Format.
|
||||
const VORSTUFE = { Guide: 'MiniGuide', FullGuide: 'Guide' }
|
||||
|
||||
function offeneGuides(format) {
|
||||
const f = props.stats?.formate?.[format]
|
||||
return (f?.erstellt ?? 0) - (f?.absolviert ?? 0)
|
||||
@@ -156,9 +159,14 @@ function offeneGuides(format) {
|
||||
function playLock(format) {
|
||||
if (format === 'OnePager') return null
|
||||
if (!props.bausteine.ready) return 'Erst Bausteine erstellen'
|
||||
if (props.doneByFormat[format] || abgebrochen(format)) return null
|
||||
const vorstufe = VORSTUFE[format]
|
||||
if (vorstufe && !props.fortschritt?.[vorstufe]) {
|
||||
return `Erst den ${vorstufe} dieses Themas absolvieren`
|
||||
}
|
||||
const offen = offeneGuides(format)
|
||||
if (offen >= 5 && !props.doneByFormat[format]) {
|
||||
return `Erst ${format}s absolvieren — ${offen} offen (max. 5)`
|
||||
if (offen >= 3) {
|
||||
return `Erst ${format}s absolvieren — ${offen} offen (max. 3)`
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user