Merge branch 'dev' of penahub.gitlab.yandexcloud.net:frontend/squiz into server-empty-strings
This commit is contained in:
commit
60145514e2
@ -26,7 +26,7 @@ import { useQuestionsStore } from "@root/questions/store";
|
|||||||
import { updateOpenedModalSettingsId } from "@root/uiTools/actions";
|
import { updateOpenedModalSettingsId } from "@root/uiTools/actions";
|
||||||
import { updateRootContentId } from "@root/quizes/actions";
|
import { updateRootContentId } from "@root/quizes/actions";
|
||||||
import { useUiTools } from "@root/uiTools/store";
|
import { useUiTools } from "@root/uiTools/store";
|
||||||
import {useState} from "react";
|
import { useState } from "react";
|
||||||
import { updateSomeWorkBackend } from "@root/uiTools/actions";
|
import { updateSomeWorkBackend } from "@root/uiTools/actions";
|
||||||
import { DeleteFunction } from "@utils/deleteFunc";
|
import { DeleteFunction } from "@utils/deleteFunc";
|
||||||
|
|
||||||
@ -282,7 +282,11 @@ export default function ButtonsOptions({
|
|||||||
<IconButton
|
<IconButton
|
||||||
sx={{ borderRadius: "6px", padding: "2px" }}
|
sx={{ borderRadius: "6px", padding: "2px" }}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if(question.content.rule.parentId.length !== 0) {
|
if (question.type === null) {
|
||||||
|
console.log("удаление безтипового")
|
||||||
|
deleteQuestion(question.id);
|
||||||
|
}
|
||||||
|
if (question.content.rule.parentId.length !== 0) {
|
||||||
setOpenDelete(true)
|
setOpenDelete(true)
|
||||||
} else {
|
} else {
|
||||||
deleteQuestionWithTimeout(question.id, () => DeleteFunction(questions, question, quiz));
|
deleteQuestionWithTimeout(question.id, () => DeleteFunction(questions, question, quiz));
|
||||||
@ -305,7 +309,7 @@ export default function ButtonsOptions({
|
|||||||
background: "#FFFFFF",
|
background: "#FFFFFF",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Typography variant="h6" sx={{textAlign: "center"}}>
|
<Typography variant="h6" sx={{ textAlign: "center" }}>
|
||||||
Вы удаляете вопрос, участвующий в ветвлении. Все его потомки потеряют данные ветвления. Вы уверены, что хотите удалить вопрос?
|
Вы удаляете вопрос, участвующий в ветвлении. Все его потомки потеряют данные ветвления. Вы уверены, что хотите удалить вопрос?
|
||||||
</Typography>
|
</Typography>
|
||||||
<Box
|
<Box
|
||||||
|
|||||||
@ -315,6 +315,10 @@ export default function ButtonsOptionsAndPict({
|
|||||||
<IconButton
|
<IconButton
|
||||||
sx={{ borderRadius: "6px", padding: "2px" }}
|
sx={{ borderRadius: "6px", padding: "2px" }}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
if (question.type === null) {
|
||||||
|
console.log("удаление безтипового")
|
||||||
|
deleteQuestion(question.id);
|
||||||
|
}
|
||||||
if(question.content.rule.parentId.length !== 0) {
|
if(question.content.rule.parentId.length !== 0) {
|
||||||
setOpenDelete(true)
|
setOpenDelete(true)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -66,7 +66,7 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function QuestionsPageCard({ question, draggableProps, isDragging, index }: Props) {
|
export default function QuestionsPageCard({ question, draggableProps, isDragging, index }: Props) {
|
||||||
const maxLengthTextField = 225;
|
const maxLengthTextField = 225;
|
||||||
|
|
||||||
const { questions } = useQuestionsStore();
|
const { questions } = useQuestionsStore();
|
||||||
const [plusVisible, setPlusVisible] = useState<boolean>(false);
|
const [plusVisible, setPlusVisible] = useState<boolean>(false);
|
||||||
@ -277,6 +277,10 @@ const maxLengthTextField = 225;
|
|||||||
margin: "0 5px 0 10px",
|
margin: "0 5px 0 10px",
|
||||||
}}
|
}}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
if (question.type === null) {
|
||||||
|
console.log("удаление безтипового")
|
||||||
|
deleteQuestion(question.id);
|
||||||
|
}
|
||||||
if (question.content.rule.parentId.length !== 0) {
|
if (question.content.rule.parentId.length !== 0) {
|
||||||
setOpenDelete(true);
|
setOpenDelete(true);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -130,7 +130,7 @@ export default function EditPage() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const updateQuestionHint = useDebouncedCallback((questions: AnyTypedQuizQuestion[]) => {
|
const updateQuestionHint = useDebouncedCallback((questions: AnyTypedQuizQuestion[]) => {
|
||||||
const problems = checkQuestionHint(questions);
|
const problems = checkQuestionHint(questions, quiz);
|
||||||
useUiTools.setState({ whyCantCreatePublic: problems });
|
useUiTools.setState({ whyCantCreatePublic: problems });
|
||||||
if (Object.keys(problems).length > 0) {
|
if (Object.keys(problems).length > 0) {
|
||||||
updateQuiz(quiz?.id, (state) => {
|
updateQuiz(quiz?.id, (state) => {
|
||||||
|
|||||||
@ -30,7 +30,7 @@ export const ModalInfoWhyCantCreate = () => {
|
|||||||
{Object.values(whyCantCreatePublic).map((data) => {
|
{Object.values(whyCantCreatePublic).map((data) => {
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
<Typography color="#7e2aea">У вопроса "{data.name}"</Typography>
|
<Typography color="#7e2aea">{data.name === "quiz" ? "У квиза" : `У вопроса "${data.name}"`}</Typography>
|
||||||
{data.problems.map((problem) => (
|
{data.problems.map((problem) => (
|
||||||
<Typography p="5px 0">{problem}</Typography>
|
<Typography p="5px 0">{problem}</Typography>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@ -1,11 +1,14 @@
|
|||||||
import { AnyTypedQuizQuestion, QuestionBranchingRuleMain } from "@model/questionTypes/shared";
|
import { AnyTypedQuizQuestion, QuestionBranchingRuleMain } from "@model/questionTypes/shared";
|
||||||
import { WhyCantCreatePublic } from "@root/uiTools/store";
|
import { WhyCantCreatePublic } from "@root/uiTools/store";
|
||||||
import { getQuestionByContentId, updateQuestion } from "@root/questions/actions";
|
import { getQuestionByContentId, updateQuestion } from "@root/questions/actions";
|
||||||
|
import { Quiz } from "@model/quiz/quiz";
|
||||||
|
|
||||||
export const checkQuestionHint = (questions: AnyTypedQuizQuestion): Record<string, WhyCantCreatePublic> => {
|
export const checkQuestionHint = (questions: AnyTypedQuizQuestion, quiz:Quiz): Record<string, WhyCantCreatePublic> => {
|
||||||
|
|
||||||
const problems: any = {}
|
const problems: any = {}
|
||||||
|
|
||||||
|
if (quiz.config.startpageType === null) problems.quiz = {name: "quiz", problems: ["Не выбран тип стартовой страницы"]}
|
||||||
|
|
||||||
const pushProblem = (id: string, problem: string, title: string) => {
|
const pushProblem = (id: string, problem: string, title: string) => {
|
||||||
//Если первый вопрос с проблемой - создаём запись. Если не первый - добавляем проблему
|
//Если первый вопрос с проблемой - создаём запись. Если не первый - добавляем проблему
|
||||||
if (id in problems) {
|
if (id in problems) {
|
||||||
|
|||||||
@ -60,8 +60,6 @@ export const DeleteFunction = async (questions: any, question: any, quiz: any) =
|
|||||||
const result = questions.find(q => q.type === "result" && q.content.rule.parentId === question.content.id)
|
const result = questions.find(q => q.type === "result" && q.content.rule.parentId === question.content.id)
|
||||||
if (result) await deleteQuestion(result.id);
|
if (result) await deleteQuestion(result.id);
|
||||||
|
|
||||||
} else {
|
|
||||||
await deleteQuestion(question.id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user