fix: when you try to grow ManOfGraph, when you add lust leg, both of them bursts

This commit is contained in:
skeris 2023-12-04 00:54:44 +03:00
parent 525977609d
commit 6d3865d4ec
5 changed files with 11 additions and 7 deletions

@ -1,7 +1,7 @@
import { MessageIcon } from "@icons/messagIcon"; import { MessageIcon } from "@icons/messagIcon";
import { PointsIcon } from "@icons/questionsPage/PointsIcon"; import { PointsIcon } from "@icons/questionsPage/PointsIcon";
import { DeleteIcon } from "@icons/questionsPage/deleteIcon"; import { DeleteIcon } from "@icons/questionsPage/deleteIcon";
import TextareaAutosize from "@mui/base/TextareaAutosize"; import { TextareaAutosize } from "@mui/base/TextareaAutosize";
import { import {
Box, Box,
FormControl, FormControl,

@ -331,16 +331,17 @@ console.log(e.cy.data('firstNode'),"SKEEER",e.cy.data('changed'))
while (queue.length) { while (queue.length) {
const task = queue.pop() const task = queue.pop()
task.task.data('layer', task.layer) task.task.data('layer', task.layer)
console.log('SAMSHIIIIT',task.layer,task.task.data().layer) task.task.removeData('subtreeWidth')
const children = e.cy().edges(`[source="${task.task.id()}"]`).targets() const children = e.cy().edges(`[source="${task.task.id()}"]`).targets()
task.task.data('children', children.length) task.task.data('children', children.length)
if (children.length !== 0) { if (children.length !== 0) {
children.forEach(n => queue.push({ task: n, layer: task.layer + 1 })) children.forEach(n => queue.push({ task: n, layer: task.layer + 1 }))
} }
} }
queue.push({ parent: e, children: children.targets() }) queue.push({ parent: e, children: children })
while (queue.length) { while (queue.length) {
const task = queue.pop() const task = queue.pop()
console.log('WIIIING',task.parent.data(),task.children.length)
if (task.children.length === 0) { if (task.children.length === 0) {
task.parent.data('subtreeWidth', task.parent.height()) task.parent.data('subtreeWidth', task.parent.height())
continue continue
@ -363,7 +364,6 @@ console.log(e.cy.data('firstNode'),"SKEEER",e.cy.data('changed'))
e.data('oldPos', pos) e.data('oldPos', pos)
return pos return pos
} else { } else {
console.log(e.cy().data('firstNode'))
if (e.cy().data('firstNode') !== 'root') { if (e.cy().data('firstNode') !== 'root') {
e.cy().data('firstNode','nonroot') e.cy().data('firstNode','nonroot')
return {x:0,y:0} return {x:0,y:0}

@ -37,6 +37,7 @@ export default function BranchingQuestions() {
console.log(parentQuestion) console.log(parentQuestion)
useLayoutEffect(() => { useLayoutEffect(() => {
if (parentQuestion === null) return
if (parentQuestion.content.rule.main.length === 0) updateQuestion(parentQuestion.id, question => question.content.rule.main.push({ if (parentQuestion.content.rule.main.length === 0) updateQuestion(parentQuestion.id, question => question.content.rule.main.push({
next: targetQuestion.content.id, next: targetQuestion.content.id,
or: true, or: true,

@ -148,7 +148,7 @@ const SelectorType = ({ parentQuestion, targetQuestion, ruleIndex, setParentQues
</Box> </Box>
<Select <Select
multiple multiple
value={parentQuestion.content.rule.main[ruleIndex].rules[0].answers || []} value={parentQuestion.content?.rule?.main[ruleIndex]?.rules[0]?.answers || []}
onChange={(event: SelectChangeEvent) => { onChange={(event: SelectChangeEvent) => {
let newParentQuestion = JSON.parse(JSON.stringify(parentQuestion)) let newParentQuestion = JSON.parse(JSON.stringify(parentQuestion))
@ -518,4 +518,4 @@ const RatingInputsType = ({ parentQuestion, targetQuestion, ruleIndex, setParent
// default: ID string // default: ID string
// } // }
// } // }
// } // }

@ -37,7 +37,10 @@ export const BranchingQuestionsModal = ({ openedModalQuestions, setOpenedModalQu
}} }}
> >
<Box sx={{ margin: "0 auto", maxWidth: "350px" }}> <Box sx={{ margin: "0 auto", maxWidth: "350px" }}>
{questions.filter((q:AnyQuestion) => (q.type && !q.content.rule.parentId)).map((question: AnyTypedQuizQuestion, index:number) => ( {questions.filter((q:AnyQuestion) => {
console.log(q.content)
if (q.content === null) return true
return (q.type && !q.content.rule.parentId)}).map((question: AnyTypedQuizQuestion, index:number) => (
<Button <Button
key={question.content.id} key={question.content.id}
onClick={() => { onClick={() => {