diff --git a/package.json b/package.json index 43f2c04c..f79c3503 100755 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "cypress-file-upload": "^5.0.8", "cytoscape": "^3.26.0", "cytoscape-popper": "^2.0.0", + "date-fns": "^3.0.4", "dayjs": "^1.11.10", "emoji-mart": "^5.5.2", "file-saver": "^2.0.5", diff --git a/src/pages/Questions/BranchingMap/CsComponent.tsx b/src/pages/Questions/BranchingMap/CsComponent.tsx index b3cd0c55..8289ccf1 100644 --- a/src/pages/Questions/BranchingMap/CsComponent.tsx +++ b/src/pages/Questions/BranchingMap/CsComponent.tsx @@ -118,37 +118,42 @@ function CsComponent({ }, [modalQuestionTargetContentId]) const addNode = ({ parentNodeContentId, targetNodeContentId }: { parentNodeContentId: string, targetNodeContentId?: string }) => { + if (quiz) { - //запрещаем работу родителя-ребенка если это один и тот же вопрос - if (parentNodeContentId === targetNodeContentId) return + //запрещаем работу родителя-ребенка если это один и тот же вопрос + if (parentNodeContentId === targetNodeContentId) return - const cy = cyRef?.current - const parentNodeChildren = cy?.$('edge[source = "' + parentNodeContentId + '"]')?.length - //если есть инфо о выбранном вопросе из модалки - берём родителя из инфо модалки. Иначе из значения дропа - const targetQuestion = { ...getQuestionByContentId(targetNodeContentId || dragQuestionContentId) } as AnyTypedQuizQuestion - if (Object.keys(targetQuestion).length !== 0 && parentNodeContentId && parentNodeChildren !== undefined) { - clearDataAfterAddNode({ parentNodeContentId, targetQuestion, parentNodeChildren }) - cy?.data('changed', true) - createResult(quiz?.backendId, targetQuestion.content.id) - const es = cy?.add([ - { - data: { - id: targetQuestion.content.id, - label: targetQuestion.title === "" || targetQuestion.title === " " ? "noname" : targetQuestion.title + const cy = cyRef?.current + const parentNodeChildren = cy?.$('edge[source = "' + parentNodeContentId + '"]')?.length + //если есть инфо о выбранном вопросе из модалки - берём родителя из инфо модалки. Иначе из значения дропа + const targetQuestion = { ...getQuestionByContentId(targetNodeContentId || dragQuestionContentId) } as AnyTypedQuizQuestion + if (Object.keys(targetQuestion).length !== 0 && parentNodeContentId && parentNodeChildren !== undefined) { + clearDataAfterAddNode({ parentNodeContentId, targetQuestion, parentNodeChildren }) + cy?.data('changed', true) + createResult(quiz.backendId, targetQuestion.content.id) + const es = cy?.add([ + { + data: { + id: targetQuestion.content.id, + label: targetQuestion.title === "" || targetQuestion.title === " " ? "noname" : targetQuestion.title + } + }, + { + data: { + source: parentNodeContentId, + target: targetQuestion.content.id + } } - }, - { - data: { - source: parentNodeContentId, - target: targetQuestion.content.id - } - } - ]) - cy?.layout(layoutOptions).run() - cy?.center(es) + ]) + cy?.layout(layoutOptions).run() + cy?.center(es) + } else { + enqueueSnackbar("Добавляемый вопрос не найден") + } + } else { - enqueueSnackbar("Добавляемый вопрос не найден") + enqueueSnackbar("Квиз не найден") } } @@ -232,7 +237,7 @@ function CsComponent({ return ( <> + mb="20px"> + } + checkedIcon={} + onChange={(_, value) => setSkipModal(value)} + checked={skipModal} + /> + } + label="Не спрашивать больше сегодня" + sx={{ + userSelect: "none", + margin: "0 0 10px", + color: theme.palette.grey2.main, + }} + /> diff --git a/src/stores/uiTools/store.ts b/src/stores/uiTools/store.ts index c8cd887f..52803348 100644 --- a/src/stores/uiTools/store.ts +++ b/src/stores/uiTools/store.ts @@ -10,7 +10,6 @@ export type UiTools = { canCreatePublic: boolean; whyCantCreatePublic: Record//ид вопроса и список претензий к нему openModalInfoWhyCantCreate: boolean; -lastDeletionNodeTime: number | null; deleteNodeId: string | null; }; export type WhyCantCreatePublic = { @@ -28,7 +27,6 @@ const initialState: UiTools = { canCreatePublic: false, whyCantCreatePublic: {}, openModalInfoWhyCantCreate: false, -lastDeletionNodeTime: null, deleteNodeId: null, }; diff --git a/yarn.lock b/yarn.lock index 5c6fbdc9..2b3e7508 100755 --- a/yarn.lock +++ b/yarn.lock @@ -4204,6 +4204,11 @@ data-urls@^2.0.0: whatwg-mimetype "^2.3.0" whatwg-url "^8.0.0" +date-fns@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-3.0.4.tgz#56eb7916d8d4666bf9be168ef84bed0deef1077c" + integrity sha512-+daptVi95nJ/D4TPS7/gbUqneVMA0Izr4qYAsL2ZZwtcDtEP8Zge765mbXhTqWYdTSG79/VtbBigQTluiE9DBQ== + dayjs@^1.10.4, dayjs@^1.11.10: version "1.11.10" resolved "https://registry.npmjs.org/dayjs/-/dayjs-1.11.10.tgz"