стабильное создание line резулта, родитель удаляемой ноды разблокирует свой резулт
This commit is contained in:
parent
c043c7d1ae
commit
3ecddfc861
@ -220,7 +220,6 @@ export const usePopper = ({
|
|||||||
gearElement.style.zIndex = "1";
|
gearElement.style.zIndex = "1";
|
||||||
gearsContainer.current?.appendChild(gearElement);
|
gearsContainer.current?.appendChild(gearElement);
|
||||||
gearElement.addEventListener("mouseup", () => {
|
gearElement.addEventListener("mouseup", () => {
|
||||||
console.log("up");
|
|
||||||
updateOpenedModalSettingsId(item.id());
|
updateOpenedModalSettingsId(item.id());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import {
|
|||||||
updateQuestion,
|
updateQuestion,
|
||||||
getQuestionByContentId,
|
getQuestionByContentId,
|
||||||
clearRuleForAll,
|
clearRuleForAll,
|
||||||
|
createResult,
|
||||||
} from "@root/questions/actions";
|
} from "@root/questions/actions";
|
||||||
import { useQuestionsStore } from "@root/questions/store";
|
import { useQuestionsStore } from "@root/questions/store";
|
||||||
import { useCurrentQuiz } from "@root/quizes/hooks";
|
import { useCurrentQuiz } from "@root/quizes/hooks";
|
||||||
@ -15,6 +16,7 @@ import type {
|
|||||||
PresetLayoutOptions,
|
PresetLayoutOptions,
|
||||||
} from "cytoscape";
|
} from "cytoscape";
|
||||||
import type {
|
import type {
|
||||||
|
AnyTypedQuizQuestion,
|
||||||
QuestionBranchingRule,
|
QuestionBranchingRule,
|
||||||
QuestionBranchingRuleMain,
|
QuestionBranchingRuleMain,
|
||||||
} from "../../../../model/questionTypes/shared";
|
} from "../../../../model/questionTypes/shared";
|
||||||
@ -68,9 +70,20 @@ export const useRemoveNode = ({
|
|||||||
question.content.rule.default = "";
|
question.content.rule.default = "";
|
||||||
});
|
});
|
||||||
|
|
||||||
//чистим rule родителя
|
//Ищём родителя
|
||||||
const parentQuestion = getQuestionByContentId(parentQuestionContentId);
|
const parentQuestion = getQuestionByContentId(parentQuestionContentId);
|
||||||
|
|
||||||
|
//Делаем результат родителя активным
|
||||||
|
const parentResult = trashQuestions.find(q => q.type === "result" && q.content.rule.parentId === parentQuestionContentId)
|
||||||
|
if (parentResult) {
|
||||||
|
updateQuestion(parentResult.content.id, q => {
|
||||||
|
q.content.usage = true
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
createResult(quiz?.backendId, parentQuestionContentId)
|
||||||
|
}
|
||||||
|
|
||||||
|
//чистим rule родителя
|
||||||
if (!parentQuestion?.type) {
|
if (!parentQuestion?.type) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -153,6 +166,7 @@ export const useRemoveNode = ({
|
|||||||
quiz &&
|
quiz &&
|
||||||
cy?.edges(`[source="${parentQuestionContentId}"]`).length === 0
|
cy?.edges(`[source="${parentQuestionContentId}"]`).length === 0
|
||||||
) {
|
) {
|
||||||
|
console.log(parentQuestionContentId)
|
||||||
//createFrontResult(quiz.backendId, parentQuestionContentId);
|
//createFrontResult(quiz.backendId, parentQuestionContentId);
|
||||||
}
|
}
|
||||||
clearDataAfterRemoveNode({
|
clearDataAfterRemoveNode({
|
||||||
@ -188,7 +202,7 @@ export const useRemoveNode = ({
|
|||||||
cy?.data("changed", true);
|
cy?.data("changed", true);
|
||||||
cy?.layout(layoutOptions).run();
|
cy?.layout(layoutOptions).run();
|
||||||
|
|
||||||
//удаляем result всех потомков
|
//делаем result всех потомков неактивными
|
||||||
trashQuestions.forEach((qr) => {
|
trashQuestions.forEach((qr) => {
|
||||||
if (
|
if (
|
||||||
qr.type === "result" &&
|
qr.type === "result" &&
|
||||||
@ -196,7 +210,9 @@ export const useRemoveNode = ({
|
|||||||
(targetQuestion?.type &&
|
(targetQuestion?.type &&
|
||||||
qr.content.rule.parentId === targetQuestion.content.id))
|
qr.content.rule.parentId === targetQuestion.content.id))
|
||||||
) {
|
) {
|
||||||
deleteQuestion(qr.id);
|
updateQuestion(qr.content.id, q => {
|
||||||
|
q.content.usage = false
|
||||||
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@ -47,8 +47,6 @@ export const DeleteNodeModal = ({ removeNode }: DeleteNodeModalProps) => {
|
|||||||
const lastDeletionNodeTime = getLastDeletionNodeTime();
|
const lastDeletionNodeTime = getLastDeletionNodeTime();
|
||||||
const now = new Date().getTime();
|
const now = new Date().getTime();
|
||||||
|
|
||||||
console.log("hours", getHours(lastDeletionNodeTime));
|
|
||||||
|
|
||||||
const sameYear = isSameYear(lastDeletionNodeTime, now);
|
const sameYear = isSameYear(lastDeletionNodeTime, now);
|
||||||
const sameMonth = isSameMonth(lastDeletionNodeTime, now);
|
const sameMonth = isSameMonth(lastDeletionNodeTime, now);
|
||||||
const sameDay = isSameDay(lastDeletionNodeTime, now);
|
const sameDay = isSameDay(lastDeletionNodeTime, now);
|
||||||
|
|||||||
@ -66,7 +66,6 @@ export default function QuestionsPageCard({ question, questionIndex, draggablePr
|
|||||||
});
|
});
|
||||||
}, 200);
|
}, 200);
|
||||||
|
|
||||||
console.log(question)
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Paper
|
<Paper
|
||||||
|
|||||||
@ -13,7 +13,6 @@ export default function FormQuestionsPage() {
|
|||||||
const quiz = useCurrentQuiz();
|
const quiz = useCurrentQuiz();
|
||||||
|
|
||||||
if (!quiz) return null;
|
if (!quiz) return null;
|
||||||
console.log("Анкета")
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@ -62,8 +62,6 @@ export default function PageOptions({ disableInput, question }: Props) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(question.content.useImage);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Box
|
<Box
|
||||||
|
|||||||
@ -25,8 +25,6 @@ export const ResultSettings = () => {
|
|||||||
const [resultContract, setResultContract] = useState(true);
|
const [resultContract, setResultContract] = useState(true);
|
||||||
const isReadyToLeaveRef = useRef(true);
|
const isReadyToLeaveRef = useRef(true);
|
||||||
|
|
||||||
console.log(quiz)
|
|
||||||
console.log(results)
|
|
||||||
useEffect(
|
useEffect(
|
||||||
function calcIsReadyToLeave() {
|
function calcIsReadyToLeave() {
|
||||||
let isReadyToLeave = true;
|
let isReadyToLeave = true;
|
||||||
@ -47,7 +45,6 @@ export const ResultSettings = () => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const cnsl = results.filter(q=> q.content.usage)
|
const cnsl = results.filter(q=> q.content.usage)
|
||||||
console.log(cnsl)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{ maxWidth: "796px" }}>
|
<Box sx={{ maxWidth: "796px" }}>
|
||||||
|
|||||||
@ -52,9 +52,6 @@ export const ViewPage = () => {
|
|||||||
questions.filter(({ type }) => type) as AnyTypedQuizQuestion[]
|
questions.filter(({ type }) => type) as AnyTypedQuizQuestion[]
|
||||||
).sort((previousItem, item) => previousItem.page - item.page);
|
).sort((previousItem, item) => previousItem.page - item.page);
|
||||||
|
|
||||||
|
|
||||||
console.log(questions)
|
|
||||||
|
|
||||||
if (visualStartPage === undefined) return <></>;
|
if (visualStartPage === undefined) return <></>;
|
||||||
if (questions.length === 0 || (questions.length === 1 && questions[0].type === "result")) return <ApologyPage message="Нет созданных вопросов"/>
|
if (questions.length === 0 || (questions.length === 1 && questions[0].type === "result")) return <ApologyPage message="Нет созданных вопросов"/>
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -46,6 +46,7 @@ import { clearAuthToken } from "@frontend/kitui";
|
|||||||
import { logout } from "@api/auth";
|
import { logout } from "@api/auth";
|
||||||
import { AnyTypedQuizQuestion } from "@model/questionTypes/shared";
|
import { AnyTypedQuizQuestion } from "@model/questionTypes/shared";
|
||||||
import { ModalInfoWhyCantCreate } from "./ModalInfoWhyCantCreate";
|
import { ModalInfoWhyCantCreate } from "./ModalInfoWhyCantCreate";
|
||||||
|
import { type } from "os";
|
||||||
|
|
||||||
export default function EditPage() {
|
export default function EditPage() {
|
||||||
const quiz = useCurrentQuiz();
|
const quiz = useCurrentQuiz();
|
||||||
@ -59,14 +60,16 @@ export default function EditPage() {
|
|||||||
|
|
||||||
const questions = await questionApi.getList({ quiz_id: editQuizId });
|
const questions = await questionApi.getList({ quiz_id: editQuizId });
|
||||||
setQuestions(questions);
|
setQuestions(questions);
|
||||||
if (questions === null || !questions.find(q => q.type !== null && q.content?.rule.parentId === "line")) createResult(quiz?.backendId, "line")
|
|
||||||
|
//Всегда должен существовать хоть 1 резулт - "line"
|
||||||
|
console.log(questions)
|
||||||
|
|
||||||
|
if (!questions?.find(q=>q.type === "result" && q.content.includes(':"line"') || q.content.includes(":'line'"))) createResult(quiz?.backendId, "line")
|
||||||
|
|
||||||
};
|
};
|
||||||
getData();
|
getData();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
console.log(quiz)
|
|
||||||
console.log(questions)
|
|
||||||
|
|
||||||
const { openBranchingPanel, whyCantCreatePublic, canCreatePublic } = useUiTools();
|
const { openBranchingPanel, whyCantCreatePublic, canCreatePublic } = useUiTools();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|||||||
@ -180,16 +180,13 @@ export const deleteQuiz = async (quizId: string) => requestQueue.enqueue(async (
|
|||||||
export const updateRootContentId = (quizId: string, id: string) => {
|
export const updateRootContentId = (quizId: string, id: string) => {
|
||||||
|
|
||||||
if (id.length === 0) {//дерева больше не существует, все результаты неактивны кроме результата линейности
|
if (id.length === 0) {//дерева больше не существует, все результаты неактивны кроме результата линейности
|
||||||
console.log("дерева больше не существует")
|
|
||||||
useQuestionsStore.getState().questions.forEach((q) => {
|
useQuestionsStore.getState().questions.forEach((q) => {
|
||||||
if (q.type !== null && q.type === "result") {
|
if (q.type !== null && q.type === "result") {
|
||||||
if (q.content.rule.parentId === "line") {
|
if (q.content.rule.parentId === "line") {
|
||||||
console.log("Этому резулту линейности я буду ставить true", q)
|
|
||||||
if (q.content.usage === false) updateQuestion(q.id, (q) => {
|
if (q.content.usage === false) updateQuestion(q.id, (q) => {
|
||||||
q.content.usage = true
|
q.content.usage = true
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
console.log("Этому резулту я буду ставить false", q)
|
|
||||||
updateQuestion(q.id, (q) => {
|
updateQuestion(q.id, (q) => {
|
||||||
q.content.usage = false
|
q.content.usage = false
|
||||||
})
|
})
|
||||||
@ -197,10 +194,8 @@ export const updateRootContentId = (quizId: string, id: string) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else { //было создано дерево, результат линейности неактивен
|
} else { //было создано дерево, результат линейности неактивен
|
||||||
console.log("дерев создаёттса")
|
|
||||||
useQuestionsStore.getState().questions.forEach((q) => {
|
useQuestionsStore.getState().questions.forEach((q) => {
|
||||||
if (q.type !== null && q.content.rule.parentId === "line") {
|
if (q.type !== null && q.content.rule.parentId === "line") {
|
||||||
console.log("Этому резулту линейности я буду ставить false", q)
|
|
||||||
updateQuestion(q.id, (q) => {
|
updateQuestion(q.id, (q) => {
|
||||||
q.content.usage = false
|
q.content.usage = false
|
||||||
})
|
})
|
||||||
|
|||||||
@ -24,7 +24,6 @@ export default function SwitchStepPages({
|
|||||||
quizStartPageType,
|
quizStartPageType,
|
||||||
quizResults,
|
quizResults,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
console.log("Выбор текущей странички")
|
|
||||||
switch (activeStep) {
|
switch (activeStep) {
|
||||||
case 0: {
|
case 0: {
|
||||||
if (!quizType) return <StepOne />;
|
if (!quizType) return <StepOne />;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user