From 1a9c26ccf75f4acf5559709883c29b889ef021f2 Mon Sep 17 00:00:00 2001 From: Nastya Date: Tue, 19 Mar 2024 04:38:37 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BD=D0=B5=20=D0=BE=D1=82=D0=BA=D1=80=D1=8B?= =?UTF-8?q?=D0=B2=D0=B0=D0=B5=D1=82=D1=81=D1=8F=20=D0=BC=D0=BE=D0=B4=D0=B0?= =?UTF-8?q?=D0=BB=D0=BA=D0=B0=20=D0=B4=D0=BB=D1=8F=20=D0=BE=D1=81=D0=BE?= =?UTF-8?q?=D0=B1=D0=B5=D0=BD=D0=BD=D1=8B=D1=85,=20=D0=BD=D0=B5=20=D1=80?= =?UTF-8?q?=D0=B8=D1=81=D1=83=D0=B5=D1=82=D1=81=D1=8F=20=D0=B8=D0=BA=D0=BE?= =?UTF-8?q?=D0=BD=D0=BA=D0=B0=20=D0=BD=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9?= =?UTF-8?q?=D0=BA=D0=B8=20=D1=83=D1=81=D0=BB=D0=BE=D0=B2=D0=B8=D0=B9=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=BE=D1=81=D0=BE=D0=B1=D0=B5=D0=BD=D0=BD?= =?UTF-8?q?=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Questions/BranchingMap/CsNodeButtons.tsx | 13 +++++++------ src/pages/Questions/BranchingMap/helper.ts | 13 ++++++++++--- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/pages/Questions/BranchingMap/CsNodeButtons.tsx b/src/pages/Questions/BranchingMap/CsNodeButtons.tsx index 46c071cb..6c6b7656 100644 --- a/src/pages/Questions/BranchingMap/CsNodeButtons.tsx +++ b/src/pages/Questions/BranchingMap/CsNodeButtons.tsx @@ -48,7 +48,6 @@ export default function CsNodeButtons({ csElements, cyRef }: Props) { (acc, node) => ((acc[node.data.id] = {}), acc), {}, ); - return ( , - !csElement.data.isRoot && ( + (!csElement.data.isRoot && !isQuestionProhibited(csElement.data.qtype)) && ( { const buttonData = buttonRefsById.current[csElement.data.id]; if (buttonData) buttonData.settings = r; }} - onClick={() => { - updateOpenedModalSettingsId(csElement.data.id); - }} + onClick={() => { + updateOpenedModalSettingsId(csElement.data.id,); + }} /> ), + //оболочка узла { @@ -101,7 +101,8 @@ export default function CsNodeButtons({ csElements, cyRef }: Props) { }} onClick={() => { setModalQuestionParentContentId(csElement.data.id); - setOpenedModalQuestions(true); + console.log("csElement ", csElement) + setOpenedModalQuestions(!(isQuestionProhibited(csElement.data.type) && csElement.data.children > 0)); }} />, ])} diff --git a/src/pages/Questions/BranchingMap/helper.ts b/src/pages/Questions/BranchingMap/helper.ts index 911e7e80..94d59e60 100644 --- a/src/pages/Questions/BranchingMap/helper.ts +++ b/src/pages/Questions/BranchingMap/helper.ts @@ -23,8 +23,10 @@ export interface Node { isRoot: boolean; id: string; label: string; - qtype: QuestionType; + qtype: string; + type: string; parent?: string; + children: number; }; classes: string; } @@ -57,6 +59,9 @@ export const storeToNodes = (questions: AnyTypedQuizQuestion[]) => { const edges: Edge[] = []; questions.forEach((question) => { if (question.content.rule.parentId) { + const parentQuestion = { + ...getQuestionByContentId(question.content.rule.parentId), + } as AnyTypedQuizQuestion; let label = question.title === "" || question.title === " " ? "noname" @@ -68,7 +73,9 @@ export const storeToNodes = (questions: AnyTypedQuizQuestion[]) => { isRoot: question.content.rule.parentId === "root", id: question.content.id, label, - qtype: question.type + qtype: question.content.rule.parentId === "root" ? "root" : parentQuestion.type, + type: question.type, + children: question.content.rule.children.length }, classes: "multiline-auto", }); @@ -360,7 +367,7 @@ export const addNode = ({ } }; -export const isQuestionProhibited = (parentQType: QuestionType) => ( +export const isQuestionProhibited = (parentQType: string) => ( parentQType === "text" || parentQType === "date" || parentQType === "number" ||