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