08/04/2024 - 22h30

recette2
cherif 2024-04-08 22:43:36 +02:00
parent 1facc7163b
commit 63f584336a
2 changed files with 154 additions and 28 deletions

View File

@ -44,7 +44,10 @@ import Autocomplete from '@mui/material/Autocomplete';
import { gridClasses } from '@mui/x-data-grid';
import { PiDotsThree } from "react-icons/pi";
import Link from '@mui/material/Link';
import { CiCircleMinus } from "react-icons/ci";
import { LiaSave } from "react-icons/lia";
import { IoMdAddCircleOutline } from "react-icons/io";
const Partner_Config_Formulaires = (props) => {
@ -74,7 +77,7 @@ const Partner_Config_Formulaires = (props) => {
const columns = [
{ field: '_id', headerName: '_id', hide: true },
{ field: 'id', headerName: 'id', hide: true },
{ field: 'code', headerName: 'code', flex: 1, hide: false, editable: false , renderCell: (params) => <ExpandableCell_50 {...params} />, },
{ field: 'code', headerName: 'code', flex: 1, hide: false, editable: false, renderCell: (params) => <ExpandableCell_50 {...params} />, },
{ field: 'nom', headerName: 'nom', flex: 1, hide: false, editable: false, renderCell: (params) => <ExpandableCell_50 {...params} />, },
{ field: 'type', headerName: 'Type', flex: 1, hide: false, editable: false, renderCell: (params) => <ExpandableCell_50 {...params} />, },
{ field: 'description', headerName: 'description', flex: 1, hide: true, editable: false, renderCell: (params) => <ExpandableCell_50 {...params} />, },
@ -178,8 +181,9 @@ const Partner_Config_Formulaires = (props) => {
const columns_question = [
{ field: '_id', headerName: '_id', hide: true },
{ field: '_id', headerName: '_id', hide: true },
{ field: 'id', headerName: 'id', hide: true },
{ field: 'list_choix', headerName: 'list_choix', hide: true },
{ field: 'question', headerName: 'question', flex: 1, hide: false, editable: false, renderCell: (params) => <ExpandableCell_50 {...params} />, },
{ field: 'type', headerName: 'type', flex: 1, hide: false, editable: false, renderCell: (params) => <ExpandableCell_50 {...params} />, },
{ field: 'max_note', headerName: 'max_note', flex: 1, hide: true, editable: false, renderCell: (params) => <ExpandableCell_50 {...params} />, },
@ -726,6 +730,7 @@ const Partner_Config_Formulaires = (props) => {
{ "id": "note", "label": "Note ", "value": "note" },
{ "id": "bool", "label": "Oui/Non", "value": "bool" },
{ "id": "entier", "label": "Entier", "value": "entier" },
{ "id": "qcm", "label": "Qcm", "value": "qcm" },
{ "id": "", "label": "", "value": "" },
]
@ -951,6 +956,8 @@ const Partner_Config_Formulaires = (props) => {
setquestion_max_note("");
setDialog_Question_open(true);
settab_qcm_choix([]);
}
const [Add_Update_One_Question_api, setAdd_Update_One_Question_api] = useState();
@ -975,6 +982,16 @@ const Partner_Config_Formulaires = (props) => {
form.append("question", question_question);
form.append("type", question_type);
form.append("max_note", question_max_note);
var local_list_choix = []
for(let i = 0; i < tab_qcm_choix.length; i++){
var choix = "reponse";
var val = String(tab_qcm_choix[i])
var node = {};
node[choix] = val;
local_list_choix.push(node);
}
form.append("list_choix", JSON.stringify(local_list_choix));
if (String(selected_question_id).length > 2) {
form.append("question_id", selected_question_id);
@ -997,6 +1014,9 @@ const Partner_Config_Formulaires = (props) => {
setquestion_question("");
setquestion_type("");
setquestion_max_note("");
settab_qcm_choix([]);
setadd_new_qcm_choix("");
setnew_qcm_choix_value("");
Get_Given_Formulaire_Data(selected_id);
@ -1108,6 +1128,35 @@ const Partner_Config_Formulaires = (props) => {
})
}
const [nb_qcm_choix, setnb_qcm_choix] = useState(3);
const [tab_qcm_choix, settab_qcm_choix] = useState([]);
const [add_new_qcm_choix, setadd_new_qcm_choix] = useState("");
const [new_qcm_choix_value, setnew_qcm_choix_value] = useState("");
function add_new_list_to_qcm() {
var current_tab_qcm_choix = tab_qcm_choix;
current_tab_qcm_choix.push(new_qcm_choix_value);
settab_qcm_choix(current_tab_qcm_choix);
setnew_qcm_choix_value("");
}
function remove_last_list_to_qcm() {
var current_tab_qcm_choix = tab_qcm_choix;
var new_current_tab_qcm_choix = [];
for (let i = 0; i < current_tab_qcm_choix.length - 1; i++)
new_current_tab_qcm_choix.push(current_tab_qcm_choix[i]);
current_tab_qcm_choix.pop();
setnew_qcm_choix_value("");
settab_qcm_choix(new_current_tab_qcm_choix);
}
return (
<div className="partner_configuration_technique">
{isLoading && <div className="loader-container">
@ -1201,6 +1250,66 @@ const Partner_Config_Formulaires = (props) => {
</div>}
{String(question_type) === "qcm" && <div className="session_caract_Dialog" > QCM
{tab_qcm_choix &&
tab_qcm_choix.map((choix) => (
<div>
<TextField
value={choix}
autoFocus
margin="dense"
id="field_question_qcm"
name="field_question_qcm"
fullWidth
onChange={(e) => {
// setquestion_max_note(e.target.value);
}
}
/>
</div>
))}
<nav className="icone_bton_add_reduce" onClick={(event) => {
setadd_new_qcm_choix("1")
}}>
<IoMdAddCircleOutline /> add</nav>
<nav className="icone_bton_add_reduce" onClick={(event) => {
remove_last_list_to_qcm();
setadd_new_qcm_choix("");
}} > <CiCircleMinus /> remove</nav>
{add_new_qcm_choix && String(add_new_qcm_choix) === "1" &&
<div>
<TextField
autoFocus
margin="dense"
id="field_question_qcm_new"
name="field_question_qcm_new"
fullWidth
value={new_qcm_choix_value}
onChange={(e) => {
setnew_qcm_choix_value(e.target.value);
}
}
/>
<LiaSave onClick={(event) => {
setadd_new_qcm_choix("");
add_new_list_to_qcm();
}} className="icone_bton_add_reduce"> record </LiaSave>
</div>
}
</div>}
</DialogContent>
@ -1780,7 +1889,7 @@ const Partner_Config_Formulaires = (props) => {
<div className="div_row" style={{ "padding": "10px" }}>
<div className="div_row" style={{ "textAlign": "right", "marginTop": "0.5rem" }}>
<Button className="bton_emarge" style={{ "minWidth": "10rem" }} onClick={(event) => {
@ -1830,6 +1939,8 @@ const Partner_Config_Formulaires = (props) => {
question: (item).question,
type: (item).type,
max_note: (item).max_note,
list_choix: (item).list_choix,
}
))}
@ -1844,6 +1955,14 @@ const Partner_Config_Formulaires = (props) => {
setquestion_question(newSelectionModel.row.question);
setquestion_type(newSelectionModel.row.type);
setquestion_max_note(newSelectionModel.row.max_note);
var tmp_tab = []
for(let i = 0; i < newSelectionModel.row.list_choix.length; i++){
tmp_tab.push(newSelectionModel.row.list_choix[i]['reponse_qcm'] );
}
settab_qcm_choix(tmp_tab);
setDialog_Question_open(true);
}}
@ -2045,7 +2164,7 @@ const Partner_Config_Formulaires = (props) => {
</div>
<div className="div_row" style={{ "padding": "10px" }}>
<div className="div_row" style={{ "textAlign": "right", "marginTop": "0.5rem" }}>
<Button className="bton_emarge" style={{ "minWidth": "10rem" }} onClick={(event) => {

View File

@ -3,8 +3,8 @@
.tooltip_css {
background: #81BC3A;
z-index: 9999;
}
}
.Mui-disabled {
font-size: small !important;
padding: 0px !important;
@ -249,7 +249,7 @@
width: 6%;
}
.icon_plus_line {
width: 3%;
}
@ -821,7 +821,7 @@
width: 6%;
}
.icon_plus_line {
width: 4%;
}
@ -1332,7 +1332,7 @@
}
.css-11u53oe-MuiSelect-select-MuiInputBase-input-MuiOutlinedInput-input {
padding: 1px !important;
@ -1420,7 +1420,7 @@
width: 8%;
}
.icon_plus_line {
width: 3%;
}
@ -2236,7 +2236,7 @@
text-align: center;
}
.css-l4u8b9-MuiInputBase-root-MuiInput-root{
.css-l4u8b9-MuiInputBase-root-MuiInput-root {
text-align: left !important;
}
@ -2265,17 +2265,24 @@
margin-right: 10px;
}
.icone_bton_add_reduce {
font-size: large;
cursor: pointer;
}
}
// end media
.css-md26zr-MuiInputBase-root-MuiOutlinedInput-root{
.css-md26zr-MuiInputBase-root-MuiOutlinedInput-root {
height: 3.5rem !important;
}
.css-1bp1ao6{
.css-1bp1ao6 {
height: 3.5rem !important;
}
@ -2338,27 +2345,27 @@
align-items: center;
text-align: center;
margin-bottom: 0.5rem !important;
}
.separator::before,
.separator::after {
}
.separator::before,
.separator::after {
content: '';
flex: 1;
border-bottom: 1px solid #e0e0e0;
}
.separator:not(:empty)::before {
margin-right: .35em;
}
.separator:not(:empty)::after {
margin-left: .35em;
}
}
.MuiSelect-select{
.separator:not(:empty)::before {
margin-right: .35em;
}
.separator:not(:empty)::after {
margin-left: .35em;
}
.MuiSelect-select {
//height: 3rem !important;
}
}
}