feat: enhance UI and functionality in Training Framework pages
Deploy Development / deploy (push) Successful in 35s
Test Suite / pytest-backend (push) Successful in 7s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 6s
Test Suite / playwright-tests (push) Failing after 53s
Deploy Development / deploy (push) Successful in 35s
Test Suite / pytest-backend (push) Successful in 7s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 6s
Test Suite / playwright-tests (push) Failing after 53s
- Added new CSS styles for segment buttons and admin assignment matrix, improving layout and responsiveness. - Refactored AssignmentsTab component to utilize new styles and improve accessibility with aria-labels. - Introduced collapsible details for framework edit introduction, enhancing user guidance. - Updated TrainingPlanningPage to streamline button styling and improve visual consistency across components.
This commit is contained in:
1 parent
14884e6e55
commit
18a58cb5a5
5 files changed
+212
-161
No files matched your search
@@ -5,22 +5,24 @@ function AssignmentsTab({ styleDirections, targetGroups, assignments, loading, e
|
||||
const [saving, setSaving] = useState(false)
|
||||
|
||||
if (loading) {
|
||||
return <div style={{ textAlign: 'center', padding: '40px' }}><div className="spinner"></div></div>
|
||||
return (
|
||||
<div className="empty-state" style={{ padding: '2.5rem' }}>
|
||||
<div className="spinner" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
async function toggleAssignment(styleDirectionId, targetGroupId, currentlyAssigned) {
|
||||
setSaving(true)
|
||||
try {
|
||||
if (currentlyAssigned) {
|
||||
// Find and delete the assignment
|
||||
const assignment = assignments.find(
|
||||
a => a.style_direction_id === styleDirectionId && a.target_group_id === targetGroupId
|
||||
(a) => a.style_direction_id === styleDirectionId && a.target_group_id === targetGroupId
|
||||
)
|
||||
if (assignment) {
|
||||
await api.deleteStyleDirectionTargetGroup(assignment.id)
|
||||
}
|
||||
} else {
|
||||
// Create new assignment
|
||||
await api.createStyleDirectionTargetGroup({
|
||||
style_direction_id: styleDirectionId,
|
||||
target_group_id: targetGroupId,
|
||||
@@ -37,11 +39,10 @@ function AssignmentsTab({ styleDirections, targetGroups, assignments, loading, e
|
||||
|
||||
function isAssigned(styleDirectionId, targetGroupId) {
|
||||
return assignments.some(
|
||||
a => a.style_direction_id === styleDirectionId && a.target_group_id === targetGroupId
|
||||
(a) => a.style_direction_id === styleDirectionId && a.target_group_id === targetGroupId
|
||||
)
|
||||
}
|
||||
|
||||
// Group style directions by focus area
|
||||
const groupedStyles = styleDirections.reduce((acc, sd) => {
|
||||
const key = sd.focus_area_name || 'Ohne Fokusbereich'
|
||||
if (!acc[key]) acc[key] = []
|
||||
@@ -50,30 +51,30 @@ function AssignmentsTab({ styleDirections, targetGroups, assignments, loading, e
|
||||
}, {})
|
||||
|
||||
return (
|
||||
<div style={{ background: 'var(--surface)', borderRadius: '12px', padding: '20px' }}>
|
||||
<h2 style={{ marginTop: 0 }}>Zuordnungen: Stilrichtungen ↔ Zielgruppen</h2>
|
||||
{error && <div style={{ color: 'var(--danger)', padding: '16px', background: 'var(--surface2)', borderRadius: '8px', marginBottom: '16px' }}>{error}</div>}
|
||||
<div className="admin-assignments-wrap">
|
||||
<h2 className="admin-assignments-wrap__title">Zuordnungen: Stilrichtungen ↔ Zielgruppen</h2>
|
||||
{error && <div className="admin-matrix-alert">{error}</div>}
|
||||
|
||||
{targetGroups.length === 0 && (
|
||||
<div style={{ textAlign: 'center', color: 'var(--text3)', padding: '40px' }}>
|
||||
Keine Zielgruppen vorhanden. Bitte erst im Tab "Kataloge" anlegen.
|
||||
<div className="empty-state" style={{ padding: '2rem 1rem' }}>
|
||||
Keine Zielgruppen vorhanden. Bitte zuerst unter <strong>Kataloge</strong> anlegen.
|
||||
</div>
|
||||
)}
|
||||
|
||||
{styleDirections.length === 0 && (
|
||||
<div style={{ textAlign: 'center', color: 'var(--text3)', padding: '40px' }}>
|
||||
Keine Stilrichtungen vorhanden. Bitte erst im Tab "Hierarchie" anlegen.
|
||||
<div className="empty-state" style={{ padding: '2rem 1rem' }}>
|
||||
Keine Stilrichtungen vorhanden. Bitte zuerst unter <strong>Hierarchie</strong> anlegen.
|
||||
</div>
|
||||
)}
|
||||
|
||||
{targetGroups.length > 0 && styleDirections.length > 0 && (
|
||||
<div className="assignment-matrix-container">
|
||||
<table className="assignment-matrix">
|
||||
<div className="admin-assignments-matrix-container">
|
||||
<table className="admin-assignments-matrix">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style={{ position: 'sticky', left: 0, background: 'var(--surface)', zIndex: 2 }}>Stilrichtung</th>
|
||||
{targetGroups.map(tg => (
|
||||
<th key={tg.id} style={{ textAlign: 'center', padding: '12px' }}>
|
||||
<th className="admin-assignments-matrix__corner">Stilrichtung</th>
|
||||
{targetGroups.map((tg) => (
|
||||
<th key={tg.id} className="admin-assignments-matrix__th-narrow">
|
||||
{tg.name}
|
||||
</th>
|
||||
))}
|
||||
@@ -82,17 +83,18 @@ function AssignmentsTab({ styleDirections, targetGroups, assignments, loading, e
|
||||
<tbody>
|
||||
{Object.entries(groupedStyles).map(([focusAreaName, styles]) => (
|
||||
<React.Fragment key={focusAreaName}>
|
||||
<tr className="focus-area-header">
|
||||
<td colSpan={targetGroups.length + 1} style={{ background: 'var(--surface2)', padding: '8px 12px', fontWeight: 600, color: 'var(--text2)' }}>
|
||||
<tr>
|
||||
<td
|
||||
className="admin-assignments-matrix__focus-header"
|
||||
colSpan={targetGroups.length + 1}
|
||||
>
|
||||
{focusAreaName}
|
||||
</td>
|
||||
</tr>
|
||||
{styles.map(sd => (
|
||||
{styles.map((sd) => (
|
||||
<tr key={sd.id}>
|
||||
<td style={{ position: 'sticky', left: 0, background: 'var(--surface)', zIndex: 1, padding: '12px', fontWeight: 500 }}>
|
||||
{sd.name}
|
||||
</td>
|
||||
{targetGroups.map(tg => {
|
||||
<td className="admin-assignments-matrix__row-label">{sd.name}</td>
|
||||
{targetGroups.map((tg) => {
|
||||
const assigned = isAssigned(sd.id, tg.id)
|
||||
return (
|
||||
<td key={tg.id} style={{ textAlign: 'center', padding: '12px' }}>
|
||||
@@ -101,7 +103,8 @@ function AssignmentsTab({ styleDirections, targetGroups, assignments, loading, e
|
||||
checked={assigned}
|
||||
onChange={() => toggleAssignment(sd.id, tg.id, assigned)}
|
||||
disabled={saving}
|
||||
style={{ width: '20px', height: '20px', cursor: 'pointer' }}
|
||||
aria-label={`${sd.name} — ${tg.name}`}
|
||||
style={{ width: '20px', height: '20px', cursor: 'pointer', accentColor: 'var(--accent)' }}
|
||||
/>
|
||||
</td>
|
||||
)
|
||||
@@ -114,45 +117,6 @@ function AssignmentsTab({ styleDirections, targetGroups, assignments, loading, e
|
||||
</table>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<style>{`
|
||||
.assignment-matrix-container {
|
||||
overflow-x: auto;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.assignment-matrix {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
min-width: 600px;
|
||||
}
|
||||
|
||||
.assignment-matrix th,
|
||||
.assignment-matrix td {
|
||||
border: 1px solid var(--border);
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.assignment-matrix th {
|
||||
background: var(--surface2);
|
||||
font-weight: 600;
|
||||
color: var(--text1);
|
||||
}
|
||||
|
||||
.assignment-matrix tbody tr:hover {
|
||||
background: var(--surface2);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.assignment-matrix {
|
||||
font-size: 14px;
|
||||
}
|
||||
.assignment-matrix th,
|
||||
.assignment-matrix td {
|
||||
padding: 8px;
|
||||
}
|
||||
}
|
||||
`}</style>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user