Increment application version to 0.8.166 and update changelog for new features in AI exercise creation
Deploy Development / deploy (push) Successful in 41s
Test Suite / pytest-backend (push) Successful in 43s
Test Suite / lint-backend (push) Successful in 0s
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 41s
Test Suite / pytest-backend (push) Successful in 43s
Test Suite / lint-backend (push) Successful in 0s
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.166 and modified BUILD_DATE to reflect recent changes. - Enhanced AI exercise creation process with a new quick create feature, allowing users to generate exercises based on search input. - Introduced a rich text editor for editing AI-generated drafts, improving user experience in exercise creation. - Updated ExercisePickerModal and related components to support the new quick create functionality, including error handling and input validation. - Added new utility functions for parsing search queries and building exercise payloads from drafts.
This commit is contained in:
1 parent
675cfa85f0
commit
294740b780
8 files changed
+592
-397
No files matched your search
@@ -24,6 +24,38 @@ function escapeHtmlText(s) {
|
||||
.replace(/"/g, '"')
|
||||
}
|
||||
|
||||
/** Suchstring → Titel + Skizze für Schnellanlage (erste Zeile / Satz als Titel). */
|
||||
export function parseSearchQueryForQuickCreate(searchText) {
|
||||
const raw = String(searchText || '').trim()
|
||||
if (!raw) return { title: '', sketch: '' }
|
||||
|
||||
const lines = raw.split(/\n/).map((l) => l.trim()).filter(Boolean)
|
||||
if (lines.length >= 2) {
|
||||
return {
|
||||
title: lines[0].slice(0, 300),
|
||||
sketch: lines.slice(1).join('\n'),
|
||||
}
|
||||
}
|
||||
|
||||
const single = lines[0] || raw
|
||||
if (single.length <= 80) {
|
||||
return { title: single.slice(0, 300), sketch: single }
|
||||
}
|
||||
|
||||
const sentenceMatch = single.match(/^(.{10,120}?[.!?;:])\s+(.+)$/s)
|
||||
if (sentenceMatch) {
|
||||
return {
|
||||
title: sentenceMatch[1].trim().slice(0, 300),
|
||||
sketch: single,
|
||||
}
|
||||
}
|
||||
|
||||
const words = single.split(/\s+/).filter(Boolean)
|
||||
const titleWordCount = Math.min(8, Math.max(3, Math.ceil(words.length / 3)))
|
||||
const title = words.slice(0, titleWordCount).join(' ').slice(0, 120)
|
||||
return { title, sketch: single }
|
||||
}
|
||||
|
||||
/** Plaintext → Absätze für RichTextEditor / API. */
|
||||
export function aiPlainTextToMinimalHtml(text) {
|
||||
const raw = String(text || '').trim()
|
||||
@@ -133,8 +165,85 @@ export function describeAiSkillRowForPreview(row, skillsCatalog) {
|
||||
return `${name}: Intensität ${int}, Niveau ${from} → ${to}${prim}`
|
||||
}
|
||||
|
||||
/** KI-Vorschau → bearbeitbarer Entwurf (Rich-Text-Felder). */
|
||||
export function aiPreviewToQuickCreateDraft(preview, { title, focusAreaId, sketchPlain }) {
|
||||
const sketchHtml = aiPlainTextToMinimalHtml(sketchPlain)
|
||||
const instructionFields = {
|
||||
goal: sketchHtml,
|
||||
execution: '',
|
||||
preparation: '',
|
||||
trainer_notes: '',
|
||||
}
|
||||
for (const c of preview?.instructionChoices || []) {
|
||||
if (c.field && c.include !== false && c.afterHtml) {
|
||||
instructionFields[c.field] = String(c.afterHtml)
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
title: (title || '').trim(),
|
||||
focusAreaId: focusAreaId != null && focusAreaId !== '' ? String(focusAreaId) : '',
|
||||
summaryHtml:
|
||||
preview?.applySummary !== false && preview?.summaryAfterHtml ? String(preview.summaryAfterHtml) : '',
|
||||
instructionFields,
|
||||
skillChoices: (preview?.skillChoices || []).map((c) => ({ ...c })),
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* createExercise-Payload aus bestätigter Vorschau.
|
||||
* createExercise-Payload aus bearbeitetem Entwurf.
|
||||
* @throws {Error}
|
||||
*/
|
||||
export function buildQuickCreateExercisePayloadFromDraft(draft) {
|
||||
const title = (draft?.title || '').trim()
|
||||
if (title.length < 3) {
|
||||
throw new Error('Titel: mindestens 3 Zeichen.')
|
||||
}
|
||||
|
||||
const fid = Number(draft?.focusAreaId)
|
||||
if (!Number.isFinite(fid) || fid < 1) {
|
||||
throw new Error('Fokusbereich ist erforderlich.')
|
||||
}
|
||||
|
||||
const fields = draft?.instructionFields || {}
|
||||
let goal = (fields.goal || '').trim()
|
||||
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('Mindestens Ziel oder Durchführung ausfüllen.')
|
||||
}
|
||||
if (!stripHtmlToText(goal).trim()) goal = execution
|
||||
if (!stripHtmlToText(execution).trim()) execution = goal
|
||||
|
||||
let summary = (draft?.summaryHtml || '').trim() || null
|
||||
if (summary && !stripHtmlToText(summary).trim()) summary = null
|
||||
|
||||
const skills = (draft?.skillChoices || []).filter((c) => c.include).map((c) => c.after)
|
||||
|
||||
return {
|
||||
title,
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* createExercise-Payload aus bestätigter Vorschau (Checkbox-Modus).
|
||||
* @throws {Error}
|
||||
*/
|
||||
export function buildQuickCreateExercisePayloadFromPreview(preview, { title, focusAreaId, sketchPlain }) {
|
||||
|
||||
Reference in new issue
Block a user