2023-11-15 18:38:02 +00:00
|
|
|
|
import { DoubleArrowRight } from "@icons/questionsPage/DoubleArrowRight";
|
|
|
|
|
import { DoubleTick } from "@icons/questionsPage/DoubleTick";
|
|
|
|
|
import { VectorQuestions } from "@icons/questionsPage/VectorQuestions";
|
2023-11-16 16:41:25 +00:00
|
|
|
|
import { QuizQuestionVarImg } from "@model/questionTypes/varimg";
|
2023-09-18 10:22:09 +00:00
|
|
|
|
import {
|
2023-12-16 16:06:46 +00:00
|
|
|
|
Box, Button,
|
|
|
|
|
IconButton, Modal,
|
2023-11-15 18:38:02 +00:00
|
|
|
|
Tooltip,
|
|
|
|
|
Typography,
|
|
|
|
|
useMediaQuery,
|
|
|
|
|
useTheme,
|
2023-09-18 10:22:09 +00:00
|
|
|
|
} from "@mui/material";
|
2023-12-12 19:05:30 +00:00
|
|
|
|
import { copyQuestion, deleteQuestion, updateQuestion, clearRuleForAll, getQuestionByContentId, deleteQuestionWithTimeout } from "@root/questions/actions";
|
2023-11-15 18:38:02 +00:00
|
|
|
|
import MiniButtonSetting from "@ui_kit/MiniButtonSetting";
|
|
|
|
|
import { ReallyChangingModal } from "@ui_kit/Modal/ReallyChangingModal/ReallyChangingModal";
|
|
|
|
|
import { useEffect, useState } from "react";
|
2023-09-25 13:43:15 +00:00
|
|
|
|
import { CopyIcon } from "../../assets/icons/questionsPage/CopyIcon";
|
2023-11-15 18:38:02 +00:00
|
|
|
|
import Branching from "../../assets/icons/questionsPage/branching";
|
|
|
|
|
import Clue from "../../assets/icons/questionsPage/clue";
|
2023-09-25 13:43:15 +00:00
|
|
|
|
import { DeleteIcon } from "../../assets/icons/questionsPage/deleteIcon";
|
2023-11-15 18:38:02 +00:00
|
|
|
|
import { HideIcon } from "../../assets/icons/questionsPage/hideIcon";
|
2023-05-03 19:21:00 +00:00
|
|
|
|
import ImgIcon from "../../assets/icons/questionsPage/imgIcon";
|
2023-11-15 18:38:02 +00:00
|
|
|
|
import SettingIcon from "../../assets/icons/questionsPage/settingIcon";
|
2023-11-16 16:41:25 +00:00
|
|
|
|
import { QuizQuestionVariant } from "@model/questionTypes/variant";
|
2023-12-03 02:16:53 +00:00
|
|
|
|
import { updateOpenedModalSettingsId } from "@root/questions/actions";
|
2023-12-14 09:40:53 +00:00
|
|
|
|
import { updateOpenBranchingPanel, updateDesireToOpenABranchingModal } from "@root/uiTools/actions";
|
2023-12-05 23:34:40 +00:00
|
|
|
|
import { useQuestionsStore } from "@root/questions/store";
|
2023-12-04 11:44:08 +00:00
|
|
|
|
import { enqueueSnackbar } from "notistack";
|
2023-12-04 16:33:50 +00:00
|
|
|
|
import { useCurrentQuiz } from "@root/quizes/hooks";
|
2023-12-11 10:08:54 +00:00
|
|
|
|
import { updateRootContentId } from "@root/quizes/actions";
|
2023-12-16 16:06:46 +00:00
|
|
|
|
import {AnyTypedQuizQuestion} from "@model/questionTypes/shared";
|
2023-12-27 07:25:30 +00:00
|
|
|
|
import { updateSomeWorkBackend } from "@root/uiTools/actions";
|
|
|
|
|
import { DeleteFunction } from "@utils/deleteFunc";
|
2023-09-21 07:00:08 +00:00
|
|
|
|
|
2023-10-05 14:03:54 +00:00
|
|
|
|
|
2023-03-30 18:39:59 +00:00
|
|
|
|
interface Props {
|
2023-11-15 18:38:02 +00:00
|
|
|
|
switchState: string;
|
|
|
|
|
SSHC: (data: string) => void;
|
2023-11-16 16:41:25 +00:00
|
|
|
|
question: QuizQuestionVariant | QuizQuestionVarImg;
|
2023-03-30 18:39:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-18 10:22:09 +00:00
|
|
|
|
export default function ButtonsOptionsAndPict({
|
2023-11-15 18:38:02 +00:00
|
|
|
|
SSHC,
|
|
|
|
|
switchState,
|
|
|
|
|
question,
|
2023-09-18 10:22:09 +00:00
|
|
|
|
}: Props) {
|
2023-11-15 18:38:02 +00:00
|
|
|
|
const [buttonHover, setButtonHover] = useState<string>("");
|
|
|
|
|
const [openedReallyChangingModal, setOpenedReallyChangingModal] =
|
|
|
|
|
useState<boolean>(false);
|
|
|
|
|
const theme = useTheme();
|
|
|
|
|
const isMobile = useMediaQuery(theme.breakpoints.down(790));
|
|
|
|
|
const isIconMobile = useMediaQuery(theme.breakpoints.down(1050));
|
2023-12-12 19:05:30 +00:00
|
|
|
|
const { questions } = useQuestionsStore.getState();
|
2023-12-04 16:33:50 +00:00
|
|
|
|
const quiz = useCurrentQuiz();
|
2023-08-16 13:29:28 +00:00
|
|
|
|
|
2023-12-16 16:06:46 +00:00
|
|
|
|
const [openDelete, setOpenDelete] = useState<boolean>(false);
|
|
|
|
|
|
2023-11-15 18:38:02 +00:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (question.deleteTimeoutId) {
|
|
|
|
|
clearTimeout(question.deleteTimeoutId);
|
|
|
|
|
}
|
|
|
|
|
}, [question]);
|
2023-08-16 13:29:28 +00:00
|
|
|
|
|
2023-11-15 18:38:02 +00:00
|
|
|
|
return (
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
width: "100%",
|
|
|
|
|
background: "#f2f3f7",
|
|
|
|
|
height: isMobile ? "92px" : "70px",
|
2023-10-13 11:28:51 +00:00
|
|
|
|
}}
|
2023-11-15 18:38:02 +00:00
|
|
|
|
>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
padding: isMobile ? " 3px 12px 11px" : "20px",
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexWrap: isMobile ? "wrap" : "nowrap",
|
|
|
|
|
gap: "6px",
|
2023-12-16 00:31:40 +00:00
|
|
|
|
maxWidth: isMobile ? "200px" : undefined
|
2023-11-15 18:38:02 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<MiniButtonSetting
|
|
|
|
|
onMouseEnter={() => setButtonHover("setting")}
|
|
|
|
|
onMouseLeave={() => setButtonHover("")}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
SSHC("setting");
|
|
|
|
|
}}
|
|
|
|
|
sx={{
|
|
|
|
|
maxWidth: "104px",
|
|
|
|
|
minWidth: isIconMobile ? "30px" : "64px",
|
|
|
|
|
height: "30px",
|
|
|
|
|
backgroundColor:
|
|
|
|
|
switchState === "setting"
|
|
|
|
|
? theme.palette.brightPurple.main
|
|
|
|
|
: "transparent",
|
|
|
|
|
color:
|
|
|
|
|
switchState === "setting" ? "#ffffff" : theme.palette.grey3.main,
|
|
|
|
|
"&:hover": {
|
|
|
|
|
color:
|
|
|
|
|
switchState === "setting" ? theme.palette.grey3.main : null,
|
|
|
|
|
},
|
|
|
|
|
}}
|
2023-10-13 11:28:51 +00:00
|
|
|
|
>
|
2023-11-15 18:38:02 +00:00
|
|
|
|
<SettingIcon
|
|
|
|
|
color={
|
|
|
|
|
buttonHover === "setting"
|
|
|
|
|
? theme.palette.grey3.main
|
|
|
|
|
: switchState === "setting"
|
|
|
|
|
? "#ffffff"
|
|
|
|
|
: theme.palette.grey3.main
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
{isIconMobile ? null : "Настройки"}
|
|
|
|
|
</MiniButtonSetting>
|
|
|
|
|
<MiniButtonSetting
|
|
|
|
|
onMouseEnter={() => setButtonHover("help")}
|
|
|
|
|
onMouseLeave={() => setButtonHover("")}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
SSHC("help");
|
|
|
|
|
}}
|
|
|
|
|
sx={{
|
|
|
|
|
minWidth: isIconMobile ? "30px" : "64px",
|
|
|
|
|
maxWidth: "102px",
|
|
|
|
|
height: "30px",
|
|
|
|
|
backgroundColor:
|
|
|
|
|
switchState === "help"
|
|
|
|
|
? theme.palette.brightPurple.main
|
|
|
|
|
: "transparent",
|
|
|
|
|
color:
|
|
|
|
|
switchState === "help" ? "#ffffff" : theme.palette.grey3.main,
|
|
|
|
|
"&:hover": {
|
|
|
|
|
color: switchState === "help" ? theme.palette.grey3.main : null,
|
|
|
|
|
},
|
|
|
|
|
}}
|
2023-10-13 11:28:51 +00:00
|
|
|
|
>
|
2023-11-15 18:38:02 +00:00
|
|
|
|
<Clue
|
|
|
|
|
color={
|
|
|
|
|
buttonHover === "help"
|
|
|
|
|
? theme.palette.grey3.main
|
|
|
|
|
: switchState === "help"
|
|
|
|
|
? "#ffffff"
|
|
|
|
|
: theme.palette.grey3.main
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
{isIconMobile ? null : "Подсказка"}
|
|
|
|
|
</MiniButtonSetting>
|
|
|
|
|
<>
|
|
|
|
|
<Tooltip
|
|
|
|
|
arrow
|
|
|
|
|
placement="right"
|
|
|
|
|
componentsProps={{
|
|
|
|
|
tooltip: {
|
|
|
|
|
sx: {
|
|
|
|
|
background: "#fff",
|
|
|
|
|
borderRadius: "6px",
|
|
|
|
|
color: "#9A9AAF",
|
|
|
|
|
boxShadow: "0px 8px 24px rgba(210, 208, 225, 0.4)",
|
|
|
|
|
"& .MuiTooltip-arrow": {
|
|
|
|
|
color: "#FFF",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
title={
|
|
|
|
|
<Box>
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
color: "#4D4D4D",
|
|
|
|
|
fontWeight: "bold",
|
|
|
|
|
fontSize: "14px",
|
|
|
|
|
marginBottom: "10px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Будет показан при условии
|
|
|
|
|
</Typography>
|
|
|
|
|
<Typography sx={{ fontWeight: "bold", fontSize: "12px" }}>
|
|
|
|
|
Название
|
|
|
|
|
</Typography>
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
fontWeight: "bold",
|
|
|
|
|
fontSize: "12px",
|
|
|
|
|
marginBottom: "10px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Условие 1, Условие 2
|
|
|
|
|
</Typography>
|
|
|
|
|
<Typography sx={{ color: "#7E2AEA", fontSize: "12px" }}>
|
|
|
|
|
Все условия обязательны
|
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
<MiniButtonSetting
|
|
|
|
|
onMouseEnter={() => setButtonHover("branching")}
|
|
|
|
|
onMouseLeave={() => setButtonHover("")}
|
|
|
|
|
onClick={() => {
|
2023-12-14 17:58:56 +00:00
|
|
|
|
updateOpenBranchingPanel(true);
|
2023-12-12 19:05:30 +00:00
|
|
|
|
updateDesireToOpenABranchingModal(question.content.id);
|
2023-11-15 18:38:02 +00:00
|
|
|
|
}}
|
|
|
|
|
sx={{
|
2023-12-17 22:34:22 +00:00
|
|
|
|
display: quiz.config.type === "form" ? "none" : "flex",
|
2023-11-15 18:38:02 +00:00
|
|
|
|
height: "30px",
|
|
|
|
|
maxWidth: "103px",
|
|
|
|
|
minWidth: isIconMobile ? "30px" : "64px",
|
|
|
|
|
backgroundColor:
|
|
|
|
|
switchState === "branching"
|
|
|
|
|
? theme.palette.brightPurple.main
|
|
|
|
|
: "transparent",
|
|
|
|
|
color:
|
|
|
|
|
switchState === "branching"
|
|
|
|
|
? "#ffffff"
|
|
|
|
|
: theme.palette.grey3.main,
|
|
|
|
|
"&:hover": {
|
|
|
|
|
color:
|
|
|
|
|
switchState === "branching"
|
|
|
|
|
? theme.palette.grey3.main
|
|
|
|
|
: null,
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Branching
|
|
|
|
|
color={
|
|
|
|
|
buttonHover === "branching"
|
|
|
|
|
? theme.palette.grey3.main
|
|
|
|
|
: switchState === "branching"
|
|
|
|
|
? "#ffffff"
|
|
|
|
|
: theme.palette.grey3.main
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
{isIconMobile ? null : "Ветвление"}
|
|
|
|
|
</MiniButtonSetting>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
<MiniButtonSetting
|
|
|
|
|
onMouseEnter={() => setButtonHover("image")}
|
|
|
|
|
onMouseLeave={() => setButtonHover("")}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
SSHC("image");
|
|
|
|
|
}}
|
|
|
|
|
sx={{
|
|
|
|
|
height: "30px",
|
|
|
|
|
maxWidth: "123px",
|
|
|
|
|
minWidth: isIconMobile ? "30px" : "64px",
|
|
|
|
|
backgroundColor:
|
|
|
|
|
switchState === "image"
|
|
|
|
|
? theme.palette.brightPurple.main
|
|
|
|
|
: "transparent",
|
|
|
|
|
color:
|
|
|
|
|
switchState === "image" ? "#ffffff" : theme.palette.grey3.main,
|
|
|
|
|
"&:hover": {
|
|
|
|
|
color:
|
|
|
|
|
switchState === "image" ? theme.palette.grey3.main : null,
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<ImgIcon
|
|
|
|
|
color={
|
|
|
|
|
buttonHover === "image"
|
|
|
|
|
? theme.palette.grey3.main
|
|
|
|
|
: switchState === "image"
|
|
|
|
|
? "#ffffff"
|
|
|
|
|
: theme.palette.grey3.main
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
{isIconMobile ? null : "Изображение"}
|
|
|
|
|
</MiniButtonSetting>
|
|
|
|
|
<MiniButtonSetting
|
|
|
|
|
onClick={() => setOpenedReallyChangingModal(true)}
|
|
|
|
|
sx={{
|
|
|
|
|
minWidth: "30px",
|
|
|
|
|
height: "30px",
|
|
|
|
|
backgroundColor: "#FEDFD0",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<DoubleTick style={{ color: "#FC712F", fontSize: "9px" }} />
|
|
|
|
|
</MiniButtonSetting>
|
|
|
|
|
<MiniButtonSetting
|
|
|
|
|
onClick={() => setOpenedReallyChangingModal(true)}
|
|
|
|
|
sx={{
|
|
|
|
|
minWidth: "30px",
|
|
|
|
|
height: "30px",
|
|
|
|
|
backgroundColor: "#FEDFD0",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<DoubleArrowRight style={{ color: "#FC712F", fontSize: "9px" }} />
|
|
|
|
|
</MiniButtonSetting>
|
|
|
|
|
<MiniButtonSetting
|
|
|
|
|
onClick={() => setOpenedReallyChangingModal(true)}
|
|
|
|
|
sx={{
|
|
|
|
|
minWidth: "30px",
|
|
|
|
|
height: "30px",
|
|
|
|
|
backgroundColor: "#FEDFD0",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<VectorQuestions style={{ color: "#FC712F", fontSize: "9px" }} />
|
|
|
|
|
</MiniButtonSetting>
|
|
|
|
|
</>
|
|
|
|
|
</Box>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
padding: "20px",
|
|
|
|
|
}}
|
2023-10-13 09:09:28 +00:00
|
|
|
|
>
|
2023-11-15 18:38:02 +00:00
|
|
|
|
<IconButton sx={{ borderRadius: "6px", padding: "0px 2px" }}>
|
|
|
|
|
<HideIcon style={{ color: "#4D4D4D" }} />
|
|
|
|
|
</IconButton>
|
|
|
|
|
<IconButton
|
|
|
|
|
sx={{ borderRadius: "6px" }}
|
|
|
|
|
onClick={() => copyQuestion(question.id, question.quizId)}
|
|
|
|
|
>
|
|
|
|
|
<CopyIcon style={{ color: "#4D4D4D" }} />
|
|
|
|
|
</IconButton>
|
|
|
|
|
<IconButton
|
|
|
|
|
sx={{ borderRadius: "6px", padding: "2px" }}
|
2023-12-12 19:05:30 +00:00
|
|
|
|
onClick={() => {
|
2023-12-16 16:06:46 +00:00
|
|
|
|
if(question.content.rule.parentId.length !== 0) {
|
|
|
|
|
setOpenDelete(true)
|
|
|
|
|
} else {
|
2023-12-27 07:25:30 +00:00
|
|
|
|
deleteQuestionWithTimeout(question.id, () => DeleteFunction(questions, question, quiz));
|
2023-12-16 16:06:46 +00:00
|
|
|
|
}
|
2023-11-15 18:38:02 +00:00
|
|
|
|
}}
|
2023-11-27 23:07:24 +00:00
|
|
|
|
data-cy="delete-question"
|
2023-11-15 18:38:02 +00:00
|
|
|
|
>
|
|
|
|
|
<DeleteIcon style={{ color: "#4D4D4D" }} />
|
|
|
|
|
</IconButton>
|
2023-12-16 16:06:46 +00:00
|
|
|
|
<Modal open={openDelete} onClose={() => setOpenDelete(false)}>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
position: "absolute",
|
|
|
|
|
top: "50%",
|
|
|
|
|
left: "50%",
|
|
|
|
|
transform: "translate(-50%, -50%)",
|
|
|
|
|
padding: "30px",
|
|
|
|
|
borderRadius: "10px",
|
|
|
|
|
background: "#FFFFFF",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Typography variant="h6" sx={{textAlign: "center"}}>
|
|
|
|
|
Вы удаляете вопрос, участвующий в ветвлении. Все его потомки потеряют данные ветвления. Вы уверены, что хотите удалить вопрос?
|
|
|
|
|
</Typography>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
marginTop: "30px",
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "center",
|
|
|
|
|
gap: "15px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Button
|
|
|
|
|
variant="contained"
|
|
|
|
|
sx={{ minWidth: "150px" }}
|
|
|
|
|
onClick={() => setOpenDelete(false)}
|
|
|
|
|
>
|
|
|
|
|
Отмена
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
variant="contained"
|
|
|
|
|
sx={{ minWidth: "150px" }}
|
|
|
|
|
onClick={() => {
|
2023-12-27 07:25:30 +00:00
|
|
|
|
deleteQuestionWithTimeout(question.id, () => DeleteFunction(questions, question, quiz));
|
2023-12-16 16:06:46 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Подтвердить
|
|
|
|
|
</Button>
|
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
|
|
|
|
</Modal>
|
2023-11-15 18:38:02 +00:00
|
|
|
|
</Box>
|
|
|
|
|
<ReallyChangingModal
|
|
|
|
|
opened={openedReallyChangingModal}
|
|
|
|
|
onClose={() => setOpenedReallyChangingModal(false)}
|
|
|
|
|
/>
|
|
|
|
|
</Box>
|
|
|
|
|
);
|
2023-04-15 09:10:59 +00:00
|
|
|
|
}
|