fix: create results on addNode logic - we should rewrite this as ASAP
This commit is contained in:
parent
a2ccd7ae50
commit
f453bbab1b
@ -7,7 +7,7 @@ import { useCurrentQuiz } from "@root/quizes/hooks";
|
|||||||
import { updateRootContentId } from "@root/quizes/actions"
|
import { updateRootContentId } from "@root/quizes/actions"
|
||||||
import { AnyTypedQuizQuestion } from "@model/questionTypes/shared"
|
import { AnyTypedQuizQuestion } from "@model/questionTypes/shared"
|
||||||
import { useQuestionsStore } from "@root/questions/store";
|
import { useQuestionsStore } from "@root/questions/store";
|
||||||
import { deleteQuestion, updateQuestion, getQuestionByContentId, clearRuleForAll } from "@root/questions/actions";
|
import { deleteQuestion, updateQuestion, getQuestionByContentId, clearRuleForAll, createFrontResult } from "@root/questions/actions";
|
||||||
import { updateOpenedModalSettingsId, } from "@root/uiTools/actions";
|
import { updateOpenedModalSettingsId, } from "@root/uiTools/actions";
|
||||||
import { cleardragQuestionContentId } from "@root/uiTools/actions";
|
import { cleardragQuestionContentId } from "@root/uiTools/actions";
|
||||||
import { withErrorBoundary } from "react-error-boundary";
|
import { withErrorBoundary } from "react-error-boundary";
|
||||||
@ -51,6 +51,7 @@ type Popper = {
|
|||||||
type NodeSingularWithPopper = NodeSingular & {
|
type NodeSingularWithPopper = NodeSingular & {
|
||||||
popper: (config: PopperConfig) => Popper;
|
popper: (config: PopperConfig) => Popper;
|
||||||
};
|
};
|
||||||
|
let counter = 0;
|
||||||
|
|
||||||
const stylesheet: Stylesheet[] = [
|
const stylesheet: Stylesheet[] = [
|
||||||
{
|
{
|
||||||
@ -160,7 +161,7 @@ function CsComponent({
|
|||||||
}, [modalQuestionTargetContentId])
|
}, [modalQuestionTargetContentId])
|
||||||
|
|
||||||
const addNode = ({ parentNodeContentId, targetNodeContentId }: { parentNodeContentId: string, targetNodeContentId?: string }) => {
|
const addNode = ({ parentNodeContentId, targetNodeContentId }: { parentNodeContentId: string, targetNodeContentId?: string }) => {
|
||||||
|
console.log('AN', counter++, parentNodeContentId,targetNodeContentId)
|
||||||
|
|
||||||
//запрещаем работу родителя-ребенка если это один и тот же вопрос
|
//запрещаем работу родителя-ребенка если это один и тот же вопрос
|
||||||
if (parentNodeContentId === targetNodeContentId) return
|
if (parentNodeContentId === targetNodeContentId) return
|
||||||
@ -170,10 +171,11 @@ function CsComponent({
|
|||||||
const parentNodeChildren = cy?.$('edge[source = "' + parentNodeContentId + '"]')?.length
|
const parentNodeChildren = cy?.$('edge[source = "' + parentNodeContentId + '"]')?.length
|
||||||
//если есть инфо о выбранном вопросе из модалки - берём родителя из инфо модалки. Иначе из значения дропа
|
//если есть инфо о выбранном вопросе из модалки - берём родителя из инфо модалки. Иначе из значения дропа
|
||||||
const targetQuestion = { ...getQuestionByContentId(targetNodeContentId || dragQuestionContentId) } as AnyTypedQuizQuestion
|
const targetQuestion = { ...getQuestionByContentId(targetNodeContentId || dragQuestionContentId) } as AnyTypedQuizQuestion
|
||||||
|
console.log('AN1', targetQuestion, parentNodeContentId,parentNodeChildren)
|
||||||
if (Object.keys(targetQuestion).length !== 0 && Object.keys(targetQuestion).length !== 0 && parentNodeContentId && parentNodeChildren !== undefined) {
|
if (Object.keys(targetQuestion).length !== 0 && parentNodeContentId && parentNodeChildren !== undefined) {
|
||||||
clearDataAfterAddNode({ parentNodeContentId, targetQuestion, parentNodeChildren })
|
clearDataAfterAddNode({ parentNodeContentId, targetQuestion, parentNodeChildren })
|
||||||
cy?.data('changed', true)
|
cy?.data('changed', true)
|
||||||
|
createFrontResult(quiz.backendId, targetQuestion.content.id)
|
||||||
const es = cy?.add([
|
const es = cy?.add([
|
||||||
{
|
{
|
||||||
data: {
|
data: {
|
||||||
@ -197,6 +199,7 @@ function CsComponent({
|
|||||||
|
|
||||||
const clearDataAfterAddNode = ({ parentNodeContentId, targetQuestion, parentNodeChildren }: { parentNodeContentId: string, targetQuestion: AnyTypedQuizQuestion, parentNodeChildren: number }) => {
|
const clearDataAfterAddNode = ({ parentNodeContentId, targetQuestion, parentNodeChildren }: { parentNodeContentId: string, targetQuestion: AnyTypedQuizQuestion, parentNodeChildren: number }) => {
|
||||||
|
|
||||||
|
console.log('AN2', parentNodeContentId,parentNodeChildren,targetQuestion)
|
||||||
const parentQuestion = { ...getQuestionByContentId(parentNodeContentId) } as AnyTypedQuizQuestion
|
const parentQuestion = { ...getQuestionByContentId(parentNodeContentId) } as AnyTypedQuizQuestion
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user