Implement collapse functionality in EvaluationDetailPage and DimensionCard components, allowing users to collapse all dimension cards simultaneously for improved usability and organization.
This commit is contained in:
@@ -51,6 +51,8 @@ interface DimensionCardProps {
|
||||
index: number;
|
||||
evaluationId?: string;
|
||||
onScoreChange: (dimensionId: string, data: Partial<DimensionScore>) => void;
|
||||
/** Increment to collapse this card (e.g. from "Tout fermer" button) */
|
||||
collapseAllTrigger?: number;
|
||||
}
|
||||
|
||||
function parseRubric(rubric: string): string[] {
|
||||
@@ -76,7 +78,7 @@ function parseQuestions(s: string | null | undefined): string[] {
|
||||
const inputClass =
|
||||
"w-full rounded border border-zinc-300 dark:border-zinc-600 bg-white dark:bg-zinc-700/80 px-2.5 py-1.5 text-sm text-zinc-900 dark:text-zinc-100 placeholder-zinc-400 dark:placeholder-zinc-500 focus:border-cyan-500 focus:ring-1 focus:ring-cyan-500/30";
|
||||
|
||||
export function DimensionCard({ dimension, score, index, evaluationId, onScoreChange }: DimensionCardProps) {
|
||||
export function DimensionCard({ dimension, score, index, evaluationId, onScoreChange, collapseAllTrigger }: DimensionCardProps) {
|
||||
const [notes, setNotes] = useState(score?.candidateNotes ?? "");
|
||||
const hasQuestions = parseQuestions(dimension.suggestedQuestions).length > 0;
|
||||
const [expanded, setExpanded] = useState(hasQuestions);
|
||||
@@ -88,6 +90,13 @@ export function DimensionCard({ dimension, score, index, evaluationId, onScoreCh
|
||||
}
|
||||
}, [evaluationId, dimension.id]);
|
||||
|
||||
useEffect(() => {
|
||||
if (collapseAllTrigger != null && collapseAllTrigger > 0) {
|
||||
setExpanded(false);
|
||||
if (evaluationId) setStoredExpanded(evaluationId, dimension.id, false);
|
||||
}
|
||||
}, [collapseAllTrigger, evaluationId, dimension.id]);
|
||||
|
||||
const toggleExpanded = () => {
|
||||
setExpanded((e) => {
|
||||
const next = !e;
|
||||
|
||||
Reference in New Issue
Block a user