Increment application version to 0.8.164 and update changelog for new features in ExercisePickerModal
Deploy Development / deploy (push) Successful in 45s
Test Suite / pytest-backend (push) Successful in 40s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m15s
Deploy Development / deploy (push) Successful in 45s
Test Suite / pytest-backend (push) Successful in 40s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m15s
- Updated APP_VERSION to 0.8.164 and added changelog entry for the new version. - Enhanced ExercisePickerModal to support quick exercise creation using AI, including fields for sketch and focus area. - Implemented error handling for AI suggestions and improved user prompts for input validation. - Updated UI elements to reflect changes in exercise creation workflow.
This commit is contained in:
1 parent
9f4678f418
commit
4725eaa90b
3 files changed
+194
-38
No files matched your search
@@ -0,0 +1,100 @@
|
||||
/**
|
||||
* KI-gestützte Schnellanlage einer Übung (Planung / ExercisePickerModal).
|
||||
*/
|
||||
import { stripHtmlToText } from './htmlUtils'
|
||||
import { normalizeSkillLevelSlug } from '../constants/skillLevels'
|
||||
import {
|
||||
EXERCISE_SKILL_INTENSITY_DEFAULT,
|
||||
normalizeExerciseSkillIntensity,
|
||||
} from '../constants/exerciseSkillIntensity'
|
||||
|
||||
function escapeHtmlText(s) {
|
||||
return String(s)
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
}
|
||||
|
||||
/** Plaintext → Absätze für RichTextEditor / API. */
|
||||
export function aiPlainTextToMinimalHtml(text) {
|
||||
const raw = String(text || '').trim()
|
||||
if (!raw) return ''
|
||||
const parts = raw.split(/\n+/).map((p) => p.trim()).filter(Boolean)
|
||||
const paras = parts.length ? parts : [raw]
|
||||
return paras.map((p) => `<p>${escapeHtmlText(p)}</p>`).join('')
|
||||
}
|
||||
|
||||
export function normalizeAiSkillRowFromApi(sug) {
|
||||
const sid = Number(sug?.skill_id)
|
||||
if (!Number.isFinite(sid) || sid < 1) return null
|
||||
return {
|
||||
skill_id: sid,
|
||||
intensity: normalizeExerciseSkillIntensity(sug.intensity) || EXERCISE_SKILL_INTENSITY_DEFAULT,
|
||||
required_level: normalizeSkillLevelSlug(sug.required_level) || 'grundlagen',
|
||||
target_level:
|
||||
normalizeSkillLevelSlug(sug.target_level) ||
|
||||
normalizeSkillLevelSlug(sug.required_level) ||
|
||||
'grundlagen',
|
||||
is_primary: !!sug.is_primary,
|
||||
ai_suggested: true,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Baut createExercise-Payload aus suggestExerciseAi-Antwort.
|
||||
* @throws {Error} wenn Ziel/Durchführung nach KI leer wären
|
||||
*/
|
||||
export function buildQuickCreateExercisePayload({ title, focusAreaId, sketchPlain, apiRes }) {
|
||||
const sketchHtml = aiPlainTextToMinimalHtml(sketchPlain)
|
||||
const fields = apiRes?.instructions?.fields || {}
|
||||
|
||||
let goal = (fields.goal || '').trim() || sketchHtml
|
||||
let execution = (fields.execution || '').trim()
|
||||
const prep = (fields.preparation || '').trim() || null
|
||||
const trainerNotes = (fields.trainer_notes || '').trim() || null
|
||||
|
||||
if (!stripHtmlToText(goal).trim() && !stripHtmlToText(execution).trim()) {
|
||||
throw new Error('KI lieferte keine verwertbare Anleitung (Ziel/Durchführung leer).')
|
||||
}
|
||||
if (!stripHtmlToText(goal).trim()) goal = execution
|
||||
if (!stripHtmlToText(execution).trim()) execution = goal
|
||||
|
||||
let summary = null
|
||||
if (apiRes?.summary?.text) {
|
||||
const sumHtml = aiPlainTextToMinimalHtml(apiRes.summary.text)
|
||||
if (sumHtml) summary = sumHtml
|
||||
}
|
||||
|
||||
const skills = []
|
||||
if (Array.isArray(apiRes?.skills)) {
|
||||
for (const sug of apiRes.skills) {
|
||||
const row = normalizeAiSkillRowFromApi(sug)
|
||||
if (row) skills.push(row)
|
||||
}
|
||||
}
|
||||
|
||||
const fid = Number(focusAreaId)
|
||||
if (!Number.isFinite(fid) || fid < 1) {
|
||||
throw new Error('Fokusbereich ist erforderlich.')
|
||||
}
|
||||
|
||||
return {
|
||||
title: (title || '').trim(),
|
||||
summary,
|
||||
goal,
|
||||
execution,
|
||||
preparation: prep,
|
||||
trainer_notes: trainerNotes,
|
||||
visibility: 'private',
|
||||
status: 'draft',
|
||||
equipment: [],
|
||||
focus_areas_multi: [{ focus_area_id: fid, is_primary: true }],
|
||||
training_styles_multi: [],
|
||||
training_types_multi: [],
|
||||
target_groups_multi: [],
|
||||
age_groups: [],
|
||||
skills,
|
||||
club_id: null,
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user