add option
This commit is contained in:
parent
af89180d07
commit
9409c7256d
|
|
@ -82,9 +82,9 @@ const ImageBoxField = ({ name }: any) => {
|
||||||
</div>
|
</div>
|
||||||
<div className="ImageBox" onClick={handleButtonClick}>
|
<div className="ImageBox" onClick={handleButtonClick}>
|
||||||
{imagePreview ? (
|
{imagePreview ? (
|
||||||
<img src={imagePreview} onClick={handleButtonClick} alt="Preview" className="imagePreview" />
|
<img src={imagePreview} alt="Preview" className="imagePreview" />
|
||||||
) : (
|
) : (
|
||||||
<ImageIcon onClick={handleButtonClick} className="ImageBoxIcon" />
|
<ImageIcon className="ImageBoxIcon" />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<input
|
<input
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
position: relative;
|
position: relative;
|
||||||
min-height: 80px;
|
min-height: 80px;
|
||||||
// padding-inline: 20px;
|
|
||||||
> * {
|
> * {
|
||||||
width: 100% !important;
|
width: 100% !important;
|
||||||
min-width: 150px;
|
min-width: 150px;
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,18 @@
|
||||||
import { useFormikContext } from "formik";
|
import { useFormikContext } from "formik";
|
||||||
import React from "react";
|
import React, { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { GoArrowSwitch } from "react-icons/go";
|
import { GoArrowSwitch } from "react-icons/go";
|
||||||
import { useObjectToEdit } from "../../zustand/ObjectToEditState";
|
import { useObjectToEdit } from "../../zustand/ObjectToEditState";
|
||||||
import { Popconfirm, Popover } from "antd";
|
import { Checkbox, CheckboxProps, Popconfirm, Popover } from "antd";
|
||||||
import { CombinationKeyEnum } from "../../enums/CombinationKeyEnum";
|
import { CombinationKeyEnum } from "../../enums/CombinationKeyEnum";
|
||||||
import { PopconfirmProps } from "antd/lib";
|
import { PopconfirmProps } from "antd/lib";
|
||||||
|
import { SettingFilled } from "@ant-design/icons";
|
||||||
|
|
||||||
const Header = () => {
|
const Header = () => {
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
const { values, setValues } = useFormikContext<any>();
|
const { values, setValues } = useFormikContext<any>();
|
||||||
const { isBseQuestion, setIsBseQuestion } = useObjectToEdit();
|
const { isBseQuestion, setIsBseQuestion,ShowHint,setShowHint } = useObjectToEdit();
|
||||||
|
// const [Setting, setSetting] = useState(false)
|
||||||
const isEdited = ()=>{
|
const isEdited = ()=>{
|
||||||
|
|
||||||
if(isBseQuestion || values?.isBase === 1){
|
if(isBseQuestion || values?.isBase === 1){
|
||||||
|
|
@ -70,6 +72,25 @@ const Header = () => {
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
const handleOpenChange = (newOpen: boolean) => {
|
||||||
|
// setSetting(newOpen);
|
||||||
|
};
|
||||||
|
const onChange: CheckboxProps['onChange'] = (e) => {
|
||||||
|
setShowHint(e.target.checked);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const contentSetting = (
|
||||||
|
<div>
|
||||||
|
|
||||||
|
<Checkbox checked={ShowHint} onChange={onChange}>
|
||||||
|
{ t("header.show_hint")}
|
||||||
|
</Checkbox>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<header className="exercise_add_header mb-4">
|
<header className="exercise_add_header mb-4">
|
||||||
<article>
|
<article>
|
||||||
|
|
@ -82,6 +103,14 @@ const Header = () => {
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
|
<div className="question_header_setting">
|
||||||
|
<Popover onOpenChange={handleOpenChange} trigger="click" content={contentSetting}>
|
||||||
|
<SettingFilled/>
|
||||||
|
|
||||||
|
</Popover>
|
||||||
|
</div>
|
||||||
|
|
||||||
{
|
{
|
||||||
isEdited() ?
|
isEdited() ?
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ const App: React.FC = () => {
|
||||||
sort_by
|
sort_by
|
||||||
});
|
});
|
||||||
|
|
||||||
return <DataTable response={response} useColumns={useColumns} />;
|
return <DataTable response={response} useColumns={useColumns} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default App;
|
export default App;
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,13 @@ import TextField from "./TextField";
|
||||||
import ImageBoxField from "../../../../../Components/CustomFields/ImageBoxField/ImageBoxField";
|
import ImageBoxField from "../../../../../Components/CustomFields/ImageBoxField/ImageBoxField";
|
||||||
import { GoTrash } from "react-icons/go";
|
import { GoTrash } from "react-icons/go";
|
||||||
import { Popconfirm } from "antd";
|
import { Popconfirm } from "antd";
|
||||||
|
import { useObjectToEdit } from "../../../../../zustand/ObjectToEditState";
|
||||||
|
|
||||||
const ChoiceFields = ({ index, data }: { index: number; data: Choice }) => {
|
const ChoiceFields = ({ index, data }: { index: number; data: Choice }) => {
|
||||||
const formik = useFormikContext<any>();
|
const formik = useFormikContext<any>();
|
||||||
|
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
|
const { ShowHint } = useObjectToEdit();
|
||||||
|
|
||||||
const handleDeleteChoice = () => {
|
const handleDeleteChoice = () => {
|
||||||
console.log(index);
|
console.log(index);
|
||||||
|
|
@ -98,8 +100,9 @@ const ChoiceFields = ({ index, data }: { index: number; data: Choice }) => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="exercise_form_width">
|
<div className="exercise_form_width">
|
||||||
|
{ShowHint &&
|
||||||
<ValidationField
|
<ValidationField
|
||||||
className=" "
|
className="hint"
|
||||||
placeholder="_"
|
placeholder="_"
|
||||||
name={`answers.${index}.hint`}
|
name={`answers.${index}.hint`}
|
||||||
label="hint"
|
label="hint"
|
||||||
|
|
@ -108,6 +111,8 @@ const ChoiceFields = ({ index, data }: { index: number; data: Choice }) => {
|
||||||
showCount={false}
|
showCount={false}
|
||||||
autoSize={{ minRows: 2, maxRows: 10 }}
|
autoSize={{ minRows: 2, maxRows: 10 }}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ const Choices = () => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={index}
|
key={index}
|
||||||
|
className="Choices"
|
||||||
>
|
>
|
||||||
<ChoiceFields index={index} data={item} />
|
<ChoiceFields index={index} data={item} />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import { toast } from "react-toastify";
|
||||||
import ImageBoxField from "../../../../../../Components/CustomFields/ImageBoxField/ImageBoxField";
|
import ImageBoxField from "../../../../../../Components/CustomFields/ImageBoxField/ImageBoxField";
|
||||||
import { GoTrash } from "react-icons/go";
|
import { GoTrash } from "react-icons/go";
|
||||||
import { Popconfirm } from "antd";
|
import { Popconfirm } from "antd";
|
||||||
|
import { useObjectToEdit } from "../../../../../../zustand/ObjectToEditState";
|
||||||
|
|
||||||
const ChoiceFields = ({
|
const ChoiceFields = ({
|
||||||
index,
|
index,
|
||||||
|
|
@ -23,7 +24,7 @@ const ChoiceFields = ({
|
||||||
const formik = useFormikContext<any>();
|
const formik = useFormikContext<any>();
|
||||||
|
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
|
const { ShowHint } = useObjectToEdit();
|
||||||
const handleDeleteChoice = () => {
|
const handleDeleteChoice = () => {
|
||||||
const arrayLength = formik.values.Questions?.[parent_index].answers?.length;
|
const arrayLength = formik.values.Questions?.[parent_index].answers?.length;
|
||||||
|
|
||||||
|
|
@ -122,8 +123,9 @@ const ChoiceFields = ({
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="exercise_form_width">
|
<div className="exercise_form_width">
|
||||||
|
{ShowHint &&
|
||||||
<ValidationField
|
<ValidationField
|
||||||
className=" "
|
className="hint"
|
||||||
placeholder="_"
|
placeholder="_"
|
||||||
name={`Questions.${parent_index}.answers.${index}.hint`}
|
name={`Questions.${parent_index}.answers.${index}.hint`}
|
||||||
label="hint"
|
label="hint"
|
||||||
|
|
@ -132,6 +134,8 @@ const ChoiceFields = ({
|
||||||
showCount={false}
|
showCount={false}
|
||||||
autoSize={{ minRows: 2, maxRows: 10 }}
|
autoSize={{ minRows: 2, maxRows: 10 }}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,8 @@ const Choices = ({ parent_index }: { parent_index: number }) => {
|
||||||
).map((item: Choice, index: number) => {
|
).map((item: Choice, index: number) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
className="Choices ChoicesMalty"
|
||||||
|
key={index}
|
||||||
>
|
>
|
||||||
<ChoiceFields
|
<ChoiceFields
|
||||||
key={index}
|
key={index}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import { toast } from "react-toastify";
|
||||||
|
|
||||||
const Form = () => {
|
const Form = () => {
|
||||||
const formik = useFormikContext<any>();
|
const formik = useFormikContext<any>();
|
||||||
const { setSuccess, Success, setSavedQuestionData } = useObjectToEdit();
|
const { setSuccess, Success, setSavedQuestionData ,ShowHint} = useObjectToEdit();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setSavedQuestionData(formik.values);
|
setSavedQuestionData(formik.values);
|
||||||
|
|
@ -116,7 +116,7 @@ const Form = () => {
|
||||||
(item: Choice, parent_index: number) => {
|
(item: Choice, parent_index: number) => {
|
||||||
return (
|
return (
|
||||||
<div key={parent_index}>
|
<div key={parent_index}>
|
||||||
<div className="exercise_form">
|
<div className="exercise_form QuestionFIeld">
|
||||||
<QuestionFIeld
|
<QuestionFIeld
|
||||||
key={parent_index}
|
key={parent_index}
|
||||||
index={parent_index}
|
index={parent_index}
|
||||||
|
|
@ -138,6 +138,7 @@ const Form = () => {
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="exercise_form_width">
|
<div className="exercise_form_width">
|
||||||
|
{ShowHint &&
|
||||||
<ValidationField
|
<ValidationField
|
||||||
className=" "
|
className=" "
|
||||||
placeholder="_"
|
placeholder="_"
|
||||||
|
|
@ -148,6 +149,8 @@ const Form = () => {
|
||||||
autoSize={{ minRows: 2, maxRows: 10 }}
|
autoSize={{ minRows: 2, maxRows: 10 }}
|
||||||
showCount={false}
|
showCount={false}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
}
|
||||||
<MaltySelectTag parent_index={parent_index} />
|
<MaltySelectTag parent_index={parent_index} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import { toast } from "react-toastify";
|
||||||
const Form = () => {
|
const Form = () => {
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
const formik = useFormikContext<any>();
|
const formik = useFormikContext<any>();
|
||||||
const { setSuccess, Success } = useObjectToEdit();
|
const { setSuccess, Success,ShowHint } = useObjectToEdit();
|
||||||
|
|
||||||
const handleAddChoice = (fromKeyCombination: boolean = false) => {
|
const handleAddChoice = (fromKeyCombination: boolean = false) => {
|
||||||
formik.setFieldValue("answers", [
|
formik.setFieldValue("answers", [
|
||||||
|
|
@ -68,7 +68,9 @@ const Form = () => {
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
||||||
<div className="exercise_form_width">
|
<div className="exercise_form_width">
|
||||||
|
{ShowHint &&
|
||||||
<ValidationField
|
<ValidationField
|
||||||
className=" "
|
className=" "
|
||||||
placeholder="_"
|
placeholder="_"
|
||||||
|
|
@ -80,6 +82,8 @@ const Form = () => {
|
||||||
autoSize={{ minRows: 2, maxRows: 10 }}
|
autoSize={{ minRows: 2, maxRows: 10 }}
|
||||||
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
}
|
||||||
<SelectTag />
|
<SelectTag />
|
||||||
</div>
|
</div>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
.filter_header {
|
.filter_header {
|
||||||
padding: 20px 20px;
|
padding: 20px 20px;
|
||||||
border-radius: 10px 10px 0 0;
|
border-radius: 10px 10px 0 0;
|
||||||
box-shadow: 2px 2px 7px 2px rgba(0, 0, 0, 0.1);
|
box-shadow: 0px 0px 32px 2px #080F3414;
|
||||||
|
|
||||||
> div {
|
> div {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,7 @@
|
||||||
|
|
||||||
.exercise_add_header {
|
.exercise_add_header {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
gap: 30px;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 14px 20px;
|
padding: 14px 20px;
|
||||||
|
|
@ -142,6 +143,7 @@
|
||||||
box-shadow: 0px 0px 4px 2px rgba(0, 0, 0, 0.1);
|
box-shadow: 0px 0px 4px 2px rgba(0, 0, 0, 0.1);
|
||||||
div{
|
div{
|
||||||
margin-left: 25px;
|
margin-left: 25px;
|
||||||
|
display: flex;
|
||||||
}
|
}
|
||||||
img {
|
img {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
@ -263,3 +265,48 @@
|
||||||
font-size: 19px;
|
font-size: 19px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.Choices{
|
||||||
|
padding-inline: 20px;
|
||||||
|
.textarea_exercise,.hint{
|
||||||
|
width: calc(50vw - 10px) !important;
|
||||||
|
}
|
||||||
|
.ValidationField{
|
||||||
|
|
||||||
|
.text{
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.QuestionFIeld{
|
||||||
|
padding-inline: 10px;
|
||||||
|
.textarea_exercise{
|
||||||
|
width: calc(50vw - 10px) !important;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.ValidationField{
|
||||||
|
.text{
|
||||||
|
font-size: 17px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.Choices.ChoicesMalty{
|
||||||
|
.textarea_exercise,.hint{
|
||||||
|
width: calc(50vw - 20px) !important;
|
||||||
|
}
|
||||||
|
.ValidationField{
|
||||||
|
|
||||||
|
.text{
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.question_header_setting{
|
||||||
|
margin-inline: 40px;
|
||||||
|
}
|
||||||
|
|
@ -138,7 +138,9 @@
|
||||||
"edit": "تعديل",
|
"edit": "تعديل",
|
||||||
"change": "تغيير",
|
"change": "تغيير",
|
||||||
"role_list": "قائمة الأدوار",
|
"role_list": "قائمة الأدوار",
|
||||||
"managers":"مدراء"
|
"managers":"مدراء",
|
||||||
|
"hide_hint":"اخفاء الشرح",
|
||||||
|
"show_hint":"عرض الشرح"
|
||||||
},
|
},
|
||||||
"columns": {
|
"columns": {
|
||||||
"id": "الرقم التعريفي",
|
"id": "الرقم التعريفي",
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,9 @@ interface ModelState {
|
||||||
|
|
||||||
SavedQuestionData: any;
|
SavedQuestionData: any;
|
||||||
setSavedQuestionData: (data: any) => void;
|
setSavedQuestionData: (data: any) => void;
|
||||||
|
|
||||||
|
ShowHint: any;
|
||||||
|
setShowHint: (data: any) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useObjectToEdit = create<ModelState>((set) => ({
|
export const useObjectToEdit = create<ModelState>((set) => ({
|
||||||
|
|
@ -49,4 +52,6 @@ export const useObjectToEdit = create<ModelState>((set) => ({
|
||||||
setDeletedQuestions: (data) => set(() => ({ DeletedQuestions: data })),
|
setDeletedQuestions: (data) => set(() => ({ DeletedQuestions: data })),
|
||||||
SavedQuestionData: [],
|
SavedQuestionData: [],
|
||||||
setSavedQuestionData: (data) => set(() => ({ SavedQuestionData: data })),
|
setSavedQuestionData: (data) => set(() => ({ SavedQuestionData: data })),
|
||||||
|
ShowHint: true,
|
||||||
|
setShowHint: (data) => set(() => ({ ShowHint: data })),
|
||||||
}));
|
}));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user