diff --git a/src/pages/Questions/BranchingMap/CsComponent.tsx b/src/pages/Questions/BranchingMap/CsComponent.tsx index 49d34257..84e90793 100644 --- a/src/pages/Questions/BranchingMap/CsComponent.tsx +++ b/src/pages/Questions/BranchingMap/CsComponent.tsx @@ -216,6 +216,7 @@ function CsComponent({ } } + const removeNode = ({ targetNodeContentId }: { targetNodeContentId: string }) => { const deleteNodes = [] as string[] const deleteEdges: any = [] @@ -331,6 +332,7 @@ function CsComponent({ } + useEffect(() => { if (startCreate) { addNode({ parentNodeContentId: startCreate }); @@ -734,13 +736,13 @@ function CsComponent({ }; //node?.on("position", update); -let pressed = false + let pressed = false let hide = false - cy?.on('mousedown',() => {pressed = true}) - cy?.on('mouseup',() => { + cy?.on('mousedown', () => { pressed = true }) + cy?.on('mouseup', () => { pressed = false hide = false - + const gc = gearsContainer.current if (gc) gc.style.display = 'block' @@ -750,23 +752,23 @@ let pressed = false if (pc) pc.style.display = 'block' if (xc) xc.style.display = 'block' if (lc) lc.style.display = 'block' - update() + update() }) - cy?.on('mousemove',() => { + cy?.on('mousemove', () => { if (pressed && !hide) { hide = true const gc = gearsContainer.current if (gc) gc.style.display = 'none' - const pc = plusesContainer.current - const xc = crossesContainer.current - const lc = layoutsContainer.current - if (pc) pc.style.display = 'none' - if (xc) xc.style.display = 'none' - if (lc) lc.style.display = 'block' + const pc = plusesContainer.current + const xc = crossesContainer.current + const lc = layoutsContainer.current + if (pc) pc.style.display = 'none' + if (xc) xc.style.display = 'none' + if (lc) lc.style.display = 'block' } - }); - + }); + cy?.on("zoom render", onZoom); }); }; diff --git a/src/pages/Questions/BranchingMap/FirstNodeField.tsx b/src/pages/Questions/BranchingMap/FirstNodeField.tsx index a72ed3c2..4526510a 100644 --- a/src/pages/Questions/BranchingMap/FirstNodeField.tsx +++ b/src/pages/Questions/BranchingMap/FirstNodeField.tsx @@ -1,6 +1,6 @@ import { Box } from "@mui/material" import { useEffect, useRef, useState } from "react"; -import { updateDragQuestionContentId, updateQuestion } from "@root/questions/actions" +import { deleteQuestion, updateDragQuestionContentId, updateQuestion } from "@root/questions/actions" import { updateRootContentId } from "@root/quizes/actions" import { useCurrentQuiz } from "@root/quizes/hooks" import { useQuestionsStore } from "@root/questions/store" @@ -11,8 +11,9 @@ interface Props { modalQuestionTargetContentId: string; } export const FirstNodeField = ({ setOpenedModalQuestions, modalQuestionTargetContentId }: Props) => { + const quiz = useCurrentQuiz(); - const { dragQuestionContentId } = useQuestionsStore() + const { dragQuestionContentId, questions } = useQuestionsStore() const Container = useRef(null); const modalOpen = () => setOpenedModalQuestions(true) @@ -22,6 +23,11 @@ export const FirstNodeField = ({ setOpenedModalQuestions, modalQuestionTargetCon if (dragQuestionContentId) { updateRootContentId(quiz?.id, dragQuestionContentId) updateQuestion(dragQuestionContentId, (question) => question.content.rule.parentId = "root") + //если были результаты - удалить + questions.forEach((q) => { + if (q.type === 'result') deleteQuestion(q.id) + }) + } } else { enqueueSnackbar("Нет информации о взятом опроснике") @@ -44,6 +50,10 @@ export const FirstNodeField = ({ setOpenedModalQuestions, modalQuestionTargetCon if (modalQuestionTargetContentId) { updateRootContentId(quiz?.id, modalQuestionTargetContentId) updateQuestion(modalQuestionTargetContentId, (question) => question.content.rule.parentId = "root") + //если были результаты - удалить + questions.forEach((q) => { + if (q.type === 'result') deleteQuestion(q.id) + }) } } else { enqueueSnackbar("Нет информации о взятом опроснике") diff --git a/src/pages/Questions/ButtonsOptions.tsx b/src/pages/Questions/ButtonsOptions.tsx index 62a776e4..3906d7cb 100644 --- a/src/pages/Questions/ButtonsOptions.tsx +++ b/src/pages/Questions/ButtonsOptions.tsx @@ -11,7 +11,7 @@ import { useMediaQuery, useTheme, } from "@mui/material"; -import { copyQuestion, deleteQuestion, updateOpenBranchingPanel, updateDesireToOpenABranchingModal } from "@root/questions/actions"; +import { copyQuestion, deleteQuestion, updateOpenBranchingPanel, updateDesireToOpenABranchingModal, updateOpenedModalSettingsId, clearRuleForAll } from "@root/questions/actions"; import MiniButtonSetting from "@ui_kit/MiniButtonSetting"; import { CopyIcon } from "../../assets/icons/questionsPage/CopyIcon"; import Branching from "../../assets/icons/questionsPage/branching"; @@ -22,7 +22,7 @@ import type { AnyTypedQuizQuestion } from "../../model/questionTypes/shared"; import { useCurrentQuiz } from "@root/quizes/hooks"; import { enqueueSnackbar } from "notistack"; import { useQuestionsStore } from "@root/questions/store"; -import { updateOpenedModalSettingsId } from "@root/questions/actions"; +import { updateRootContentId } from "@root/quizes/actions"; interface Props { switchState: string; @@ -40,7 +40,7 @@ export default function ButtonsOptions({ const isMobile = useMediaQuery(theme.breakpoints.down(790)); const isWrappMiniButtonSetting = useMediaQuery(theme.breakpoints.down(920)); const quiz = useCurrentQuiz(); - const { openBranchingPanel } = useQuestionsStore.getState() + const { questions } = useQuestionsStore.getState() const openedModal = () => { updateOpenedModalSettingsId(question.id) diff --git a/src/pages/ResultPage/ResultSettings.tsx b/src/pages/ResultPage/ResultSettings.tsx index cc98f79b..1f393426 100644 --- a/src/pages/ResultPage/ResultSettings.tsx +++ b/src/pages/ResultPage/ResultSettings.tsx @@ -33,7 +33,6 @@ export const ResultSettings = () => { isReadyToLeave = false; } }); - console.log(`setting isReadyToLeaveRef to ${isReadyToLeave}`); isReadyToLeaveRef.current = isReadyToLeave; }, [results]) diff --git a/yarn.lock b/yarn.lock index 37993e50..55e74472 100755 --- a/yarn.lock +++ b/yarn.lock @@ -1409,7 +1409,7 @@ "@frontend/kitui@^1.0.54": version "1.0.54" - resolved "https://penahub.gitlab.yandexcloud.net/api/v4/projects/21/packages/npm/@frontend/kitui/-/@frontend/kitui-1.0.54.tgz" + resolved "https://penahub.gitlab.yandexcloud.net/api/v4/projects/21/packages/npm/@frontend/kitui/-/@frontend/kitui-1.0.54.tgz#0235d5a8effb9b92351471c3c7775f28cb2839f6" integrity sha1-AjXVqO/7m5I1FHHDx3dfKMsoOfY= dependencies: immer "^10.0.2"