Compare commits
2 Commits
ce1a1843a0
...
45a960bce3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45a960bce3 | ||
|
|
1556648532 |
|
|
@ -17,12 +17,13 @@ const EditLazyModal = React.lazy(() => import("./EditLaTexModal"));
|
|||
const LaTeXInputMemo: React.FC<any> = React.memo(({ field ,form, label, ...props }) => {
|
||||
const { name ,value} = field;
|
||||
|
||||
const { setFieldValue ,touched ,errors } = form;
|
||||
const { setFieldValue ,touched ,errors ,getFieldProps,values} = form;
|
||||
|
||||
const { ShowLatexOption, Success } = useObjectToEdit();
|
||||
const [showPreview, setShowPreview] = useState(false);
|
||||
const Preview = parseTextAndLatex(value ?? "");
|
||||
|
||||
|
||||
const onPreviewChange: CheckboxProps['onChange'] = (e) => {
|
||||
setShowPreview(e.target.checked);
|
||||
};
|
||||
|
|
@ -68,6 +69,31 @@ const LaTeXInputMemo: React.FC<any> = React.memo(({ field ,form, label, ...prop
|
|||
|
||||
const isError = !!touched?.[name] && !!errors?.[name];
|
||||
const errorMessage = isError ? errors?.[name] as string ?? "" : "" ;
|
||||
|
||||
|
||||
|
||||
console.log(values);
|
||||
|
||||
let metaName = name.substring(0, name.lastIndexOf('.'));
|
||||
if (metaName.includes('.')) { metaName += ".meta";} else {metaName += "meta"}
|
||||
console.log(metaName);
|
||||
const meta = getFieldProps(metaName).value ;
|
||||
console.log(meta);
|
||||
const direction = meta?.direction === "ltr" ? "ltr" : "rtl"
|
||||
|
||||
const [Dir, setDir] = useState<"ltr" | "rtl">(direction)
|
||||
|
||||
const handleChangeDirection = ()=>{
|
||||
if(Dir === "ltr"){
|
||||
setDir("rtl")
|
||||
setFieldValue(metaName,{...(meta ?? {}), direction:"rtl"})
|
||||
}else{
|
||||
setDir("ltr")
|
||||
setFieldValue(metaName,{...(meta ?? {}), direction:"ltr"})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='LaTeXInput'>
|
||||
<label htmlFor={name} className="text">
|
||||
|
|
@ -84,18 +110,25 @@ const LaTeXInputMemo: React.FC<any> = React.memo(({ field ,form, label, ...prop
|
|||
onChange={handleChangeInput}
|
||||
value={curCentValue}
|
||||
onBlur={onBlur}
|
||||
dir={Dir}
|
||||
{...props}
|
||||
/>
|
||||
<div className='LaTeXInputOptions'>
|
||||
<Checkbox onChange={handleChangeDirection} checked={direction === "ltr"} >{t("header.change_direction")}</Checkbox>
|
||||
|
||||
|
||||
{ShowLatexOption && (
|
||||
<div className='LaTeXInputOptions'>
|
||||
<>
|
||||
<Checkbox onChange={onPreviewChange}>{t("header.show_preview")}</Checkbox>
|
||||
<button type='button' className='addMML' onClick={showModal}>
|
||||
<FaPlus/> {t("MML")}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</>
|
||||
)}
|
||||
|
||||
</div>
|
||||
|
||||
{showPreview && (
|
||||
<div className='showPreviewInput'>
|
||||
{Preview?.map((item: any, index: number) => {
|
||||
|
|
|
|||
|
|
@ -15,9 +15,6 @@ export const areFieldPropsEqual = (
|
|||
const nextValue = nextProps.field.value;
|
||||
|
||||
return (
|
||||
prevValue === nextValue
|
||||
&&
|
||||
prevError === nextError &&
|
||||
prevTouched === nextTouched
|
||||
false
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ const AddPage: React.FC = () => {
|
|||
lessons_ids: [lesson_id],
|
||||
canAnswersBeShuffled,
|
||||
hint: DataToSend?.hint,
|
||||
meta : DataToSend?.meta
|
||||
|
||||
};
|
||||
|
||||
mutateAsync(newBseQuestion).then((data: any) => {
|
||||
|
|
@ -56,6 +58,8 @@ const AddPage: React.FC = () => {
|
|||
tags,
|
||||
lessons_ids: [lesson_id],
|
||||
answers,
|
||||
meta : item?.meta
|
||||
|
||||
});
|
||||
});
|
||||
console.log(newBseQuestionId, "newBseQuestionId");
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@ import { useObjectToEdit } from "../../../zustand/ObjectToEditState";
|
|||
import { removeStringKeys } from "../../../utils/removeStringKeys";
|
||||
import SpinContainer from "../../../Components/Layout/SpinContainer";
|
||||
import { Question } from "../../../types/Item";
|
||||
import { toast } from "react-toastify";
|
||||
import { deletePathSegments } from "../../../utils/deletePathSegments";
|
||||
import BaseFormContainer from "./Model/EditForm/BaseFormContainer";
|
||||
import FormContainer from "./Model/EditForm/FormContainer";
|
||||
import { handleValidateBaseQuestion, handleValidateSingleQuestion } from "./Model/ValidationFn";
|
||||
|
|
@ -61,6 +59,7 @@ const EditPage: React.FC = () => {
|
|||
id: DataToSend?.id,
|
||||
content: DataToSend?.content,
|
||||
content_image: DataToSend?.content_image ?? "",
|
||||
meta : DataToSend?.meta
|
||||
};
|
||||
if (
|
||||
typeof UpdateBseQuestion?.content_image === "string" &&
|
||||
|
|
|
|||
|
|
@ -59,7 +59,6 @@ const TableHeader = () => {
|
|||
setObjectToEdit(null)
|
||||
}
|
||||
}, [])
|
||||
console.log(objectToEdit);
|
||||
|
||||
return (
|
||||
<div className="TableWithHeader">
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@ export const getInitialValues = (objectToEdit: Question): any => {
|
|||
return { ...item };
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
|
||||
id: objectToEdit?.id ?? null,
|
||||
content: objectToEdit?.content ?? "",
|
||||
content_image: objectToEdit?.content_image ?? "",
|
||||
|
|
@ -17,6 +19,7 @@ export const getInitialValues = (objectToEdit: Question): any => {
|
|||
parent_id: objectToEdit?.parent_id ?? "",
|
||||
answers: objectToEdit?.answers ?? null,
|
||||
tags: tags ?? [],
|
||||
meta : objectToEdit?.meta ?? { direction : "rtl" }
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -83,6 +86,8 @@ export const getInitialValuesBase = (objectToEdit: Question): any => {
|
|||
hint: objectToEdit?.hint ?? "",
|
||||
isBase: 0,
|
||||
tags,
|
||||
meta : objectToEdit?.meta ?? { direction : "rtl" }
|
||||
|
||||
};
|
||||
});
|
||||
|
||||
|
|
@ -98,6 +103,8 @@ export const getInitialValuesBase = (objectToEdit: Question): any => {
|
|||
canAnswersBeShuffled: objectToEdit?.canAnswersBeShuffled ? 1 : 0,
|
||||
hint: objectToEdit?.hint ?? null,
|
||||
Questions: questions,
|
||||
meta : objectToEdit?.meta ?? { direction : "rtl" }
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,9 @@
|
|||
import { HaveDuplicatedArrayValue } from "../../utils/hasDuplicateArrayValue";
|
||||
|
||||
const Dummy = () => {
|
||||
const isDuplicated = HaveDuplicatedArrayValue([{name:"name"},{name:"name3"},{name:"nam"}],"name")
|
||||
console.log(isDuplicated,"isDuplicated");
|
||||
|
||||
return (
|
||||
<div className="DummyHomePage">
|
||||
<div>asd</div>
|
||||
<div> asd </div>
|
||||
<div>mohammed karim -_- </div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@
|
|||
.LaTeXInputOptions{
|
||||
display: flex;
|
||||
padding: 10px;
|
||||
|
||||
}
|
||||
.text{
|
||||
margin-bottom: 7px !important;
|
||||
|
|
|
|||
|
|
@ -153,7 +153,8 @@
|
|||
"add_MML":"إضافة MML",
|
||||
"show_preview":"عرض المعاينة",
|
||||
"show_MMl":" MML عرض",
|
||||
"financial_collection":"التحصيلات"
|
||||
"financial_collection":"التحصيلات",
|
||||
"change_direction":"تغيير الاتجاه"
|
||||
},
|
||||
"columns": {
|
||||
"id": "الرقم التعريفي",
|
||||
|
|
|
|||
|
|
@ -317,6 +317,7 @@ export interface Question {
|
|||
hint?: string;
|
||||
tags: tags[];
|
||||
lessons:any
|
||||
meta?:{}
|
||||
}
|
||||
|
||||
export type report = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user