2026-05-06 21:20:19 +02:00
|
|
|
|
import React from 'react'
|
|
|
|
|
|
import CatalogRulePicker from './CatalogRulePicker'
|
2026-05-06 17:15:44 +02:00
|
|
|
|
|
|
|
|
|
|
/**
|
2026-05-06 21:20:19 +02:00
|
|
|
|
* Fokusbereiche inkl. „nur ohne Zuordnung“; Regeln über CatalogRulePicker (+/−).
|
2026-05-06 17:15:44 +02:00
|
|
|
|
*/
|
|
|
|
|
|
export default function ExerciseFocusRulePicker({
|
|
|
|
|
|
focusOptions,
|
|
|
|
|
|
focusRules,
|
|
|
|
|
|
focusOnlyWithout,
|
|
|
|
|
|
legacyFocusAreaIds = [],
|
|
|
|
|
|
onPatch,
|
|
|
|
|
|
}) {
|
2026-05-06 21:20:19 +02:00
|
|
|
|
const legacyWarning =
|
|
|
|
|
|
Array.isArray(legacyFocusAreaIds) && legacyFocusAreaIds.length > 0 && !focusOnlyWithout
|
2026-05-06 17:15:44 +02:00
|
|
|
|
|
|
|
|
|
|
const setFocusOnly = (on) => {
|
|
|
|
|
|
if (on) {
|
|
|
|
|
|
onPatch({
|
|
|
|
|
|
focus_only_without: true,
|
|
|
|
|
|
exclude_without_focus: false,
|
|
|
|
|
|
focus_rules: [],
|
|
|
|
|
|
focus_area_ids: [],
|
|
|
|
|
|
})
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
onPatch({ focus_only_without: false })
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div className="exercise-focus-rule-picker">
|
|
|
|
|
|
<label style={{ display: 'flex', alignItems: 'center', gap: '10px', cursor: 'pointer', marginBottom: '10px' }}>
|
2026-05-06 21:20:19 +02:00
|
|
|
|
<input type="checkbox" checked={!!focusOnlyWithout} onChange={(e) => setFocusOnly(e.target.checked)} />
|
|
|
|
|
|
<span>
|
|
|
|
|
|
Nur Übungen <strong>ohne</strong> Fokusbereich (keine Zuordnung)
|
|
|
|
|
|
</span>
|
2026-05-06 17:15:44 +02:00
|
|
|
|
</label>
|
|
|
|
|
|
|
|
|
|
|
|
{!focusOnlyWithout ? (
|
|
|
|
|
|
<>
|
|
|
|
|
|
{legacyWarning ? (
|
2026-05-06 21:20:19 +02:00
|
|
|
|
<p className="muted" style={{ fontSize: '12px', marginTop: 0, marginBottom: '8px' }}>
|
|
|
|
|
|
Ältere ODER-Fokusliste aktiv — über die Chips auf der Übersicht entfernen.
|
2026-05-06 17:15:44 +02:00
|
|
|
|
</p>
|
|
|
|
|
|
) : null}
|
2026-05-06 21:20:19 +02:00
|
|
|
|
<CatalogRulePicker
|
|
|
|
|
|
label="Fokusbereiche"
|
|
|
|
|
|
hint="+ alle erforderlich (UND). − keine dieser Zuordnungen."
|
|
|
|
|
|
options={focusOptions}
|
|
|
|
|
|
rules={focusRules}
|
|
|
|
|
|
rulesFieldName="focus_rules"
|
|
|
|
|
|
idKind="numeric"
|
|
|
|
|
|
placeholder="Fokus …"
|
|
|
|
|
|
onPatch={onPatch}
|
|
|
|
|
|
/>
|
2026-05-06 17:15:44 +02:00
|
|
|
|
</>
|
|
|
|
|
|
) : (
|
2026-05-06 21:20:19 +02:00
|
|
|
|
<p className="muted" style={{ fontSize: '12px', marginTop: 0 }}>
|
|
|
|
|
|
Fokus-Regeln sind deaktiviert.
|
2026-05-06 17:15:44 +02:00
|
|
|
|
</p>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|