diff --git a/src/pages/Questions/BranchingMap/CsComponent.tsx b/src/pages/Questions/BranchingMap/CsComponent.tsx index 3ecb1118..bee882cd 100644 --- a/src/pages/Questions/BranchingMap/CsComponent.tsx +++ b/src/pages/Questions/BranchingMap/CsComponent.tsx @@ -128,8 +128,6 @@ function CsComponent({ if ((parentQuestion?.type === "date" || parentQuestion?.type === "text" || parentQuestion?.type === "number" || parentQuestion?.type === "page") && parentQuestion.content.rule.children.length === 1 ) { - console.log(parentQuestion.content.rule.children) - console.log("parentQuestion.content.rule.children.length === 1",parentQuestion.content.rule.children.length === 1) enqueueSnackbar("у вопроса этого типа может быть только 1 потомок") return } @@ -140,8 +138,6 @@ function CsComponent({ clearDataAfterAddNode({ parentNodeContentId, targetQuestion, parentNodeChildren }) cy?.data('changed', true) createResult(quiz.backendId, targetQuestion.content.id) - console.log("Я собираюсь добавить узел из такого вопроса ", targetQuestion) - console.log("Я собираюсь добавить узел у которого папаша вот такой ", parentNodeContentId) const es = cy?.add([ { data: { diff --git a/src/pages/Questions/BranchingMap/hooks/usePopper.ts b/src/pages/Questions/BranchingMap/hooks/usePopper.ts index b022755a..de2a078b 100644 --- a/src/pages/Questions/BranchingMap/hooks/usePopper.ts +++ b/src/pages/Questions/BranchingMap/hooks/usePopper.ts @@ -229,7 +229,11 @@ export const usePopper = ({ updateOpenedModalSettingsId(item.id()); }); + console.log("собираюсь анализировать папашу") + console.log("Тип папаши ", parentQuestion.type) if (parentQuestion?.type === "date" || parentQuestion?.type === "text" || parentQuestion?.type === "number" || parentQuestion?.type === "page") { + console.log("Шестерня должна быть невидимая") + console.log("Тип папаши ", parentQuestion.type) gearElement.classList.add("popper-gear-none"); } diff --git a/src/pages/Questions/ButtonsOptions.tsx b/src/pages/Questions/ButtonsOptions.tsx index caeab9d1..7ab1b537 100644 --- a/src/pages/Questions/ButtonsOptions.tsx +++ b/src/pages/Questions/ButtonsOptions.tsx @@ -283,7 +283,6 @@ export default function ButtonsOptions({ sx={{ borderRadius: "6px", padding: "2px" }} onClick={() => { if (question.type === null) { - console.log("удаление безтипового") deleteQuestion(question.id); } if (question.content.rule.parentId.length !== 0) { diff --git a/src/pages/Questions/ButtonsOptionsAndPict.tsx b/src/pages/Questions/ButtonsOptionsAndPict.tsx index f29225f5..01a4da9e 100644 --- a/src/pages/Questions/ButtonsOptionsAndPict.tsx +++ b/src/pages/Questions/ButtonsOptionsAndPict.tsx @@ -316,7 +316,6 @@ export default function ButtonsOptionsAndPict({ sx={{ borderRadius: "6px", padding: "2px" }} onClick={() => { if (question.type === null) { - console.log("удаление безтипового") deleteQuestion(question.id); } if(question.content.rule.parentId.length !== 0) { diff --git a/src/pages/Questions/DraggableList/QuestionPageCard.tsx b/src/pages/Questions/DraggableList/QuestionPageCard.tsx index 6315b5de..bdcaf1c4 100644 --- a/src/pages/Questions/DraggableList/QuestionPageCard.tsx +++ b/src/pages/Questions/DraggableList/QuestionPageCard.tsx @@ -278,7 +278,6 @@ export default function QuestionsPageCard({ question, draggableProps, isDragging }} onClick={() => { if (question.type === null) { - console.log("удаление безтипового") deleteQuestion(question.id); } if (question.content.rule.parentId.length !== 0) { diff --git a/src/pages/Questions/QuestionSwitchWindowTool.tsx b/src/pages/Questions/QuestionSwitchWindowTool.tsx index e60f50ca..a56d3bd2 100644 --- a/src/pages/Questions/QuestionSwitchWindowTool.tsx +++ b/src/pages/Questions/QuestionSwitchWindowTool.tsx @@ -20,7 +20,6 @@ export const QuestionSwitchWindowTool = ({ openBranchingPage, setOpenBranchingPa const theme = useTheme(); const isMobile = useMediaQuery(theme.breakpoints.down(600)); const quiz = useCurrentQuiz(); - console.log("Я компонент в котором отвечала"); const openBranchingPageHC = () => { if (!openBranchingPage) { diff --git a/src/pages/startPage/EditPage.tsx b/src/pages/startPage/EditPage.tsx index 61528276..7ca5e54e 100755 --- a/src/pages/startPage/EditPage.tsx +++ b/src/pages/startPage/EditPage.tsx @@ -187,8 +187,6 @@ export default function EditPage() { } }; - console.log(quiz?.status); - return ( <> {/*хедер*/} diff --git a/src/stores/questions/actions.ts b/src/stores/questions/actions.ts index a5dcd65c..58dd2347 100644 --- a/src/stores/questions/actions.ts +++ b/src/stores/questions/actions.ts @@ -488,7 +488,6 @@ export const clearRuleForAll = () => { || question.content.rule.default.length > 0 || question.content.rule.parentId.length > 0) && question.type !== "result") { - console.log("вызываю очистку рул вопросов") updateQuestion(question.content.id, question => { question.content.rule.parentId = ""; question.content.rule.main = []; @@ -510,8 +509,6 @@ export const createResult = async ( //Мы получили запрос на создание резулта. Анализируем существует ли такой. Если да - просто делаем его активным const question = useQuestionsStore.getState().questions.find(q => q.type !== null && q?.content.rule.parentId === parentContentId) - console.log("Получил запрос на создание результа родителю ", parentContentId) - console.log("Ищу такой же результ в списке ", question) if (question) {//существует, делаем активным updateQuestion(question.id, (q) => { @@ -539,6 +536,7 @@ export const createResult = async ( type: "createBackResult", createdQuestion, }); + return createdQuestion } catch (error) { devlog("Error creating question", error); enqueueSnackbar("Не удалось создать вопрос"); diff --git a/src/ui_kit/QuizPreview/QuizPreviewQuestionTypes/Page.tsx b/src/ui_kit/QuizPreview/QuizPreviewQuestionTypes/Page.tsx index 1f4559e1..bae35d8b 100644 --- a/src/ui_kit/QuizPreview/QuizPreviewQuestionTypes/Page.tsx +++ b/src/ui_kit/QuizPreview/QuizPreviewQuestionTypes/Page.tsx @@ -8,7 +8,6 @@ interface Props { } export default function Page({ question }: Props) { - console.log(question); return ( 0) { //удалить из стора вопрос из дерева и очистить его потомков const clearQuestions = [] as string[]; + const parentQuestion = getQuestionByContentId(question.content.rule.parentId); + let startCountParentChildren = parentQuestion.content.rule.children + //записываем потомков , а их результаты удаляем const getChildren = (parentQuestion: AnyTypedQuizQuestion) => { questions.forEach((targetQuestion) => { @@ -41,18 +43,54 @@ export const DeleteFunction = async (questions: any, question: any, quiz: any) = ) + //чистим rule родителя - const parentQuestion = getQuestionByContentId(question.content.rule.parentId); const newRule = {}; + const parentChildren = [...parentQuestion.content.rule.children]; + + + + console.log("_________________УДАЛЯЕМЫЙ ВОПРОС_________________", question.content.id) + console.log(parentChildren) + console.log(question.content.id) + console.log(parentChildren.includes(question.content.id)) + + + if (parentChildren.includes(question.content.id)) + parentChildren.splice(parentQuestion.content.rule.children.indexOf(question.content.id), 1) + + console.log("получившийся массив ", parentChildren) newRule.main = parentQuestion.content.rule.main.filter((data) => data.next !== question.content.id); //удаляем условия перехода от родителя к этому вопросу newRule.parentId = parentQuestion.content.rule.parentId; newRule.default = parentQuestion.content.rule.parentId === question.content.id ? "" : parentQuestion.content.rule.parentId; - newRule.children = [...parentQuestion.content.rule.children].splice(parentQuestion.content.rule.children.indexOf(question.content.id), 1); + newRule.children = parentChildren await updateQuestion(question.content.rule.parentId, (PQ) => { PQ.content.rule = newRule; }); await deleteQuestion(question.id); + + const parentResult = questions.find(q => q.type === "result" && q.content.rule.parentId === parentQuestion.content.id) + + + + //сделать результ родителя видимым если у него не осталось потомков + console.log("пришло время анализировать сделать ли результат родителя видимым") + console.log("количество детей ", startCountParentChildren.length) + + + if (startCountParentChildren.length === 1) { + if (parentResult) { + console.log("я нашел результат родителя") + await updateQuestion(parentResult.content.id, q => { + q.content.usage = true + }) + } else { //почему-то не существует результа у родителя. Создаём. Новосозданные результы видны сразу + console.log("я не нашел результат родителя") + await createResult(quiz.backendId, parentQuestion.content.id) + } + } + } await deleteQuestion(question.id); diff --git a/src/utils/deleteTimeoutedQuestions.ts b/src/utils/deleteTimeoutedQuestions.ts index 19c18322..134faafb 100644 --- a/src/utils/deleteTimeoutedQuestions.ts +++ b/src/utils/deleteTimeoutedQuestions.ts @@ -6,12 +6,10 @@ import { DeleteFunction } from "@utils/deleteFunc"; type allQuestionsTypes = AnyTypedQuizQuestion | UntypedQuizQuestion export const deleteTimeoutedQuestions = async (questions: allQuestionsTypes[], quiz: Quiz|undefined) => { - console.log("Я отвечаю за удаление неудалёнышей при переключении. Привет, буде знакомы") const questionsForDeletion = questions.filter( ({ type, deleted }) => type && type !== "result" && deleted ) as AnyTypedQuizQuestion[]; if (questionsForDeletion.length > 0) { - console.log("меняю занятость беком на true") updateSomeWorkBackend(true) @@ -19,7 +17,6 @@ export const deleteTimeoutedQuestions = async (questions: allQuestionsTypes[], q questionsForDeletion.map(question => DeleteFunction(questions, question, quiz)) ) - console.log("______________меняю на 'можно редактировать дальше'______________") updateSomeWorkBackend(false) } }; \ No newline at end of file