first commit

This commit is contained in:
2025-12-09 11:54:54 +09:00
commit d832c8445e
212 changed files with 49182 additions and 0 deletions

View File

@@ -0,0 +1,134 @@
import { useEffect, useRef, useState } from "react";
import axios from "axios";
import { Button, Modal, Table } from "react-bootstrap";
import React from "react";
import * as XLSX from 'xlsx';
import ExcelJS from 'exceljs'
import { saveAs } from 'file-saver';
import { TableDataRow } from "@modules/TypeModule";
import { URL_SEED } from "@modules/AxiosModule";
import { useRecoilValue } from "recoil";
import { loginToken, memberInfo } from "@token/Token";
export const CapiModal = (props:{
show:boolean,
onHide:() => void,
getInterViewerList: () => void
}) => {
const info = useRecoilValue(memberInfo);
const token = useRecoilValue(loginToken);
const [tableData, setTableData] = useState<TableDataRow[]>([]);
const hiddenInput = useRef<HTMLInputElement>(null);
const readFile = (file:any) => {
const reader = new FileReader();
reader.onload = (e: ProgressEvent<FileReader>) => {
const arrayBuffer: ArrayBuffer = e.target!.result as ArrayBuffer;
const data = new Uint8Array(arrayBuffer);
const workbook = XLSX.read(data, {type: "array"});
const worksheet = workbook.Sheets[workbook.SheetNames[0]];
const dataJson: TableDataRow[] = XLSX.utils.sheet_to_json(worksheet);
setTableData(dataJson);
};
reader.readAsArrayBuffer(file);
}
const uploadFile = () => {
if(hiddenInput.current){
hiddenInput.current.click();
}
}
const readToFile = (e:React.ChangeEvent<HTMLInputElement>) => {
const file = e.currentTarget.files;
if(file){
readFile(file[0]);
}
}
const insertInterViewer = () => {
if(window.confirm("업로드 하시겠습니까?")){
const interViewerArray:any[] = [];
tableData.map((ele) => {
interViewerArray.push({
id: Object.values(ele)[0],
pwd: Object.values(ele)[1],
info: Object.values(ele)[2] ?? "",
regMember: info.member_code
})
})
axios.post(URL_SEED+'/capi/saveInterviewer', interViewerArray, {
headers: {
'Authorization': `Bearer ${token.access}`,
}
}).then((response) => {
if(response.status === 200){
alert("성공적으로 업로드됐습니다");
setTableData([]);
props.getInterViewerList();
props.onHide();
}
}).catch((error) => {
console.log("saveInterviewer Error: ", error);
if(error.response.status === 409){
alert(error.response.data.errorMessage);
return false
}
})
}
}
return(
<Modal show={props.show} size="xl" backdrop='static'>
<Modal.Header>
<Modal.Title className="text-center">
면접원 업로드
</Modal.Title>
</Modal.Header>
<Modal.Body className="logicForm" style={{maxHeight:"600px!important", height:"600px", overflowY:"auto"}}>
<div className="mb-2">
<Button className="mr-2" variant="primary" onClick={uploadFile}>파일 선택</Button>
<input type="file" name="capi_list" ref={hiddenInput} style={{display:"none"}} onChange={readToFile} accept=".xlsx, .xls, .csv"/>
</div>
<React.Fragment>
<Table className="tbe-wrap quota-tbl text-center mt-2" style={{tableLayout:"fixed"}}>
<thead>
<tr className="tbe-tr" style={{borderRadius: "4px 4px 0 0"}}>
<th style={{borderRight: "2px solid #fff", borderRadius:"0 4px 0 0 "}}>면접원 이름(ID)</th>
<th style={{borderRight: "2px solid #fff", borderRadius:"0 4px 0 0 "}}>면접원 전화번호(PW)</th>
<th style={{borderRight: "2px solid #fff", borderRadius:"0 4px 0 0 "}}>정보</th>
</tr>
</thead>
<tbody>
{
tableData && tableData.map((ele, idx) => {
return(
<tr key={idx}>
{
Object.values(ele).map((objEle, objIdx) => {
return(
<td key={objIdx} style={{backgroundColor: "#fff"}}>{objEle}</td>
)
})
}
</tr>
)
})
}
</tbody>
</Table>
</React.Fragment>
</Modal.Body>
<Modal.Footer>
<div className='mt-2 mr-1 float-right'>
<Button className='project-save-btn mr-2' variant="primary" onClick={insertInterViewer}>저장</Button>
<Button variant="secondary" onClick={()=>{props.onHide()}}>닫기</Button>
</div>
</Modal.Footer>
</Modal>
)
}

View File

@@ -0,0 +1,178 @@
import { useEffect, useState } from "react";
import { useRecoilValue } from "recoil";
import axios from "axios";
import { Button, Modal, Form, Table, InputGroup } from "react-bootstrap";
import { questionInfoType } from "@modules/TypeModule";
import Editor from "@monaco-editor/react";
import { URL_SEED } from "@modules/AxiosModule";
import { loginToken, memberInfo } from "@token/Token";
import { useQuery } from "@tanstack/react-query";
export const CodeBoardModal = (props:{
show:boolean,
onHide:() => void,
// modalQidTitle:string,
// projectCode:string,
questionInfo:questionInfoType[],
// questionUniqueKey:number
}) => {
const [modalShow, setModalShow] = useState(false);
const [codeList, setCodeList] = useState<number>(1);
const listTab = () => {
setCodeList(1)
}
const writeTab = () => {
setCodeList(2)
}
return(
<Modal show={props.show} size="xl" backdrop='static'>
<Modal.Header>
<Modal.Title className="text-center">
코드 게시판
</Modal.Title>
</Modal.Header>
<Modal.Body className="logicForm" style={{maxHeight:"600px!important", height:"600px", overflowY:"auto"}}>
<div className="mb-2">
<Button className="mr-2" value="1" variant={codeList === 1 ? "primary":"secondary"} onClick={listTab}>목록</Button>
<Button value="2" variant={codeList === 2 ? "primary":"secondary"} onClick={writeTab}>작성</Button>
</div>
{
codeList === 1 ?
<>
<div className="mb-2">
<Form.Control
id='codeListSearch'
list='searchCodeList'
placeholder="리스트"
aria-describedby="basic-addon2"
style={{width:"90%"}}
className='d-inline-block'
autoComplete="off"
// onKeyDown={enterPress}
// onChange={(e) => setSearchText(e.currentTarget.value)}
// value={ searchText }
/>
<datalist id='searchCodeList'>
{/* {
props.answerUser.map((ele) => {
return(
<option key={ele.answerId} value={ele.answerId}>{ele.answerId}</option>
)
})
} */}
</datalist>
<Button className='ml-1 codeBoardListBtn' variant="light" id="codeListSearchBtn">
검색
</Button>
</div>
<Table className="tbe-wrap quota-tbl text-center mt-2" style={{tableLayout:"fixed"}}>
<thead>
<tr className="tbe-tr" style={{borderRadius: "4px 4px 0 0"}}>
<th className="codeBoardHeader" style={{borderRight: "2px solid #fff", borderRadius:"4px 0 0 0 "}}>제목 & 태그</th>
<th style={{borderRight: "2px solid #fff", borderRadius:"0 4px 0 0 "}}>등록자</th>
</tr>
</thead>
<tbody>
<tr className="tbe-tr">
<td style={{backgroundColor:"#f3f4f5", border:"3px solid #fff"}}>
<span style={{color:"#1CAE81"}}>dd</span><br/>
<span className='codeHashtag mr-1'>
{ "#태그"} { "#태그"}
</span>
</td>
<td style={{backgroundColor:"#f3f4f5", border:"3px solid #fff"}}>aaa</td>
</tr>
<tr className="tbe-tr">
<td style={{backgroundColor:"#f3f4f5", border:"3px solid #fff"}}>
<span style={{color:"#1CAE81"}}>dd</span><br/>
<span className='codeHashtag mr-1'>
{ "#태그"} { "#태그"}
</span>
</td>
<td style={{backgroundColor:"#f3f4f5", border:"3px solid #fff"}}>aaa</td>
</tr>
<tr className="tbe-tr">
<td style={{backgroundColor:"#f3f4f5", border:"3px solid #fff"}}>
<span style={{color:"#1CAE81"}}>dd</span><br/>
<span className='codeHashtag mr-1'>
{ "#태그"} { "#태그"}
</span>
</td>
<td style={{backgroundColor:"#f3f4f5", border:"3px solid #fff"}}>aaa</td>
</tr>
</tbody>
</Table>
</> //코드 게시판 - 목록 end
:
<>
<div className="mb-2">
<input
id="codeHeader"
type="text"
className="mr-2"
style={{width:"90%"}}
placeholder=' 하드코딩 제목'
// value={ numericOpenPrefix }
// onChange={(e) => setNumericOpenPrefix(e.currentTarget.value)}
//onKeyUp={(e) => setNumericOpenPrefix(e.currentTarget.value)}
/>
<Button className='ml-1 codeBoardWriteBtn' variant="primary" id="saveCodeBtn">
저장
</Button>
</div>
{
<div className="input-group input-group-sm mt-3 mb-3" style={{height:"98%"}}>
<Editor
height="100%"
language="javascript"
theme="vs-dark"
// value={ onLoadCode }
// onChange={ (value) => setOnLoadCode(String(value)) }
options={{
fontSize: 16,
formatOnType: true,
autoClosingBrackets: "always",
minimap: { enabled: false },
}}
/>
</div>
}
{/* <Row> */}
<div className='mt-3'> 태그 입력
<InputGroup className="mb-3 w-50" id="hashtagInput">
<Form.Control
id='hashtagInput'
// ref={hashText}
placeholder="입력해 주세요."
aria-describedby="basic-addon2"
// onKeyDown={handleOnKeyPressHashTag}
// onClick={addHashTag}
/>
<Button className='ml-1' variant="outline-secondary" id="tagButton" >
추가
</Button>
</InputGroup>
</div>
{/* </Row> */}
<div>
코드설명
</div>
<textarea style={{width:"100%"}}/>
</>
}
</Modal.Body>
<Modal.Footer>
<div className='mt-2 mr-1 float-right'>
{codeList === 2 ? <Button className='project-save-btn mr-2' variant="primary" >저장</Button> : ""}
<Button variant="secondary" onClick={()=>{props.onHide()}}>닫기</Button>
</div>
</Modal.Footer>
</Modal>
)
}

View File

@@ -0,0 +1,142 @@
import { useEffect, useRef, useState } from "react";
import { useRecoilValue } from "recoil";
import axios from "axios";
import { Button, Modal, Row, Col } from "react-bootstrap";
import { memberInfo } from "@token/Token";
import { URL_FLOWER } from "@modules/AxiosModule";
import { blobToFile } from "@modules/Function";
import FilePondPluginImageExifOrientation from "filepond-plugin-image-exif-orientation";
import FilePondPluginImagePreview from "filepond-plugin-image-preview";
import { FilePond, registerPlugin } from "react-filepond";
import "filepond/dist/filepond.min.css";
import "filepond-plugin-image-preview/dist/filepond-plugin-image-preview.css";
registerPlugin(FilePondPluginImageExifOrientation, FilePondPluginImagePreview);
export const FileUploadModal = (props:{
skey: string,
show :boolean,
onHide: () => void
}) => {
const info = useRecoilValue(memberInfo);
const fileRef = useRef<FilePond>(null);
const [uploadedFiles, setUploadedFiles] = useState<any[]>([])
// eslint-disable-next-line react-hooks/exhaustive-deps
const uploadFiles = () => {
const fileData = fileRef.current?.getFiles()
.filter((fileItem)=>fileItem.file.name !== undefined)
.map((fileItem) => fileItem.file) || [];
let uploadData = new FormData();
uploadData.append("security_code", props.skey );
uploadData.append("member_code", String(info.member_code));
if(fileData.length > 0){
fileData.map((fileEle) => {
if(!(fileEle instanceof File)){
let newFile = blobToFile(fileEle, fileEle.name);
uploadData.append("upload_file", newFile);
}
else{
uploadData.append("upload_file", fileEle);
}
})
axios.post(URL_FLOWER+'/files/projectFilesUpload', uploadData, {headers: {"Content-Type": "multipart/form-data"}})
.then((response) => {
if(response.status === 200){
alert('저장 되었습니다');
props.onHide();
}
})
.catch((error)=>{
console.log("projectFilesUpload Error:", error)
});
}
else{
axios.post(URL_FLOWER+'/files/projectFilesEmpty', uploadData, {headers: {}})
.then((response) => {
if(response.status === 200){
alert('저장 되었습니다');
props.onHide();
}
})
.catch((error)=>{
console.log("projectFilesEmpty Error:", error)
});
}
}
useEffect(() => {
if(props.show){
fetch(URL_FLOWER+'/files/projectFiles?sc='+props.skey)
.then(response => response.json())
.then(fileUrls => {
const fileItems = fileUrls.map((url:string) => ({
source: url,
options: { type: 'server' }
}));
setUploadedFiles(fileItems);
});
}
}, [props.show]);
useEffect(() => {
const handleKeySave = (e: { key: string; ctrlKey: boolean; preventDefault: () => void; }) => {
if(props.show && e.ctrlKey && e.key?.toLowerCase() === "s"){
e.preventDefault();
uploadFiles();
}
}
window.addEventListener('keydown', handleKeySave);
return () => {
window.removeEventListener('keydown', handleKeySave);
};
},[props.show, uploadFiles])
return (
<Modal show={props.show} size="lg" backdrop='static'>
<Modal.Header>
<Modal.Title className="text-center">
{"파일 업로드"}
</Modal.Title>
</Modal.Header>
<Modal.Body className="fileUpload">
<Row className='p-3'>
<Col md={12}>
<ul className="file-ul mb-2" >
<li className="file-li">
<div className="file-wrap">
<FilePond
ref={fileRef}
credits={false}
allowReorder={true}
allowMultiple={true}
maxFiles={50}
files={uploadedFiles}
styleButtonRemoveItemPosition='right'
iconRemove='<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" style="width: 20px; transform:translate(-4.5px, -1px);">
<g id="icon_close">
<path id="Vector" d="M6.96967 6.96967C7.26256 6.67678 7.73744 6.67678 8.03033 6.96967L12 10.9393L15.9697 6.96967C16.2626 6.67678 16.7374 6.67678 17.0303 6.96967C17.3232 7.26256 17.3232 7.73744 17.0303 8.03033L13.0607 12L17.0303 15.9697C17.3232 16.2626 17.3232 16.7374 17.0303 17.0303C16.7374 17.3232 16.2626 17.3232 15.9697 17.0303L12 13.0607L8.03033 17.0303C7.73744 17.3232 7.26256 17.3232 6.96967 17.0303C6.67678 16.7374 6.67678 16.2626 6.96967 15.9697L10.9393 12L6.96967 8.03033C6.67678 7.73744 6.67678 7.26256 6.96967 6.96967Z" fill="#ffffff"/>
</g>
</svg>
'// <-- 리무브 아이콘 넣기
labelIdle='파일 업로드'
/>
</div>
</li>
</ul>
</Col>
</Row>
</Modal.Body>
<Modal.Footer>
<div className='mt-2 mr-1 float-right'>
<Button className='project-save-btn mr-2' variant="primary" onClick={uploadFiles} >저장</Button>
<Button variant="secondary" onClick={()=>{props.onHide()}}>닫기</Button>
</div>
</Modal.Footer>
</Modal>
)
}

View File

@@ -0,0 +1,229 @@
import { useEffect, useState } from "react";
import { useRecoilValue } from "recoil";
import axios from "axios";
import { Button, Modal, Form } from "react-bootstrap";
import { questionInfoType } from "@modules/TypeModule";
import Editor, { loader } from "@monaco-editor/react";
import { URL_SEED } from "@modules/AxiosModule";
import { loginToken, memberInfo } from "@token/Token";
import { useQuery } from "@tanstack/react-query";
import { CodeBoardModal } from "./CodeBoardModal";
export const SetHardcodeModal = (props:{
show:boolean,
onHide:() => void,
modalQidTitle:string,
projectCode:string,
questionInfo:questionInfoType[],
questionUniqueKey:number
}) => {
type historyCodeDto = {
id: string;
questionUniqueKey: number;
projectCode: string;
hardCodeType: number;
content: string;
regMember: number;
}
type historyCodeType = {
content: string;
hardCodeType: number;
projectCode: string;
questionUniqurKey: number;
regDate: string;
regMember: number;
}
const token = useRecoilValue(loginToken);
const member = useRecoilValue(memberInfo);
const [selectTab, setSelectTab] = useState<number>(1);
const [totalHistoryCode, setTotalHistoryCode] = useState<historyCodeDto[]>([]);
const [onLoadCode, setOnLoadCode] = useState<string>("");
const [onNextCode, setOnNextCode] = useState<string>("");
const [historyArray, setHistoryArray] = useState([]);
const [codeBoardModal, setCodeBoardModal] = useState(false);
loader.config({
paths: { vs: 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.31.1/min/vs' } });
//vs: 'https://www.unpkg.com/monaco-editor/min/vs',
/** 코드게시판 */
const codeLib = () => {
setCodeBoardModal(true)
}
const historyChange = (e:React.ChangeEvent<HTMLInputElement>) => {
let historySelect:historyCodeType[] = historyArray.filter((ele:historyCodeType) => ele.regDate === e.currentTarget.value);
if(historySelect.length > 0 && selectTab === 1){
setOnLoadCode(historySelect[0]?.content);
}else{
setOnNextCode(historySelect[0]?.content);
}
if(e.currentTarget.value === ""){
hardCodeHistory();
}
}
const hardCodingInsert = () => {
// hardcode document. 입력 방지
let notInWord = /document\.\w*/gi;
if(notInWord.test(onLoadCode) || notInWord.test(onNextCode)){
alert("'document.'은 사용할 수 없는 예약어 입니다.");
return false;
}
let data = {
id: historyArray.length === 0 ? "0" : totalHistoryCode[0]?.id,
questionUniqueKey: props.questionUniqueKey,
projectCode: props.projectCode,
hardCodeType: selectTab,
content: selectTab === 1 ? onLoadCode : onNextCode,
regMember: member.member_code
}
axios.post(URL_SEED+'/hardcode/saveHardCode', data, {
headers: {
'Authorization': `Bearer ${token.access}`,
}
}).then((response) => {
if(response.status === 200){
alert("저장되었습니다.");
props.onHide();
}
}).catch((error) => {
console.log("saveHardCode Error :",error);
})
}
const hardCodeHistory = async () => {
try {
const response = await axios.get(URL_SEED+'/hardcode/getHardCode', {
headers: {
'Authorization': `Bearer ${token.access}`,
},
params: {
projectCode: props.projectCode,
questionUniqueKey: props.questionUniqueKey,
type: selectTab
}
})
if(response.data.hardCodeDto){
if(selectTab === 1){
setOnLoadCode(response.data.hardCodeDto.content);
}else{
setOnNextCode(response.data.hardCodeDto.content);
}
setHistoryArray(response.data.hardCodeHistoryDtoList);
setTotalHistoryCode([response.data.hardCodeDto]);
}else{
setOnLoadCode("//설문 진입 시 동작하는 하드코드");
setOnNextCode("//다음 버튼 클릭 시 동작하는 하드코드");
}
} catch(error) {
console.log("getHardCodeError:", error);
}
}
useEffect(() => {
setSelectTab(1);
},[props.questionUniqueKey])
useEffect(() => {
hardCodeHistory();
},[props.questionUniqueKey, selectTab])
useEffect(() => {
const handleKeySave = (e: { key: string; ctrlKey: boolean; preventDefault: () => void; }) => {
if(props.show && e.ctrlKey && e.key?.toLowerCase() === "s"){
e.preventDefault();
hardCodingInsert();
}
}
window.addEventListener('keydown', handleKeySave);
return () => {
window.removeEventListener('keydown', handleKeySave);
};
},[props.show, props.questionUniqueKey, onLoadCode, onNextCode])
return (
<Modal show={props.show} size="xl" backdrop='static'>
<Modal.Header>
<Modal.Title className="text-center">
{props.modalQidTitle} 하드코딩 설정
</Modal.Title>
</Modal.Header>
<Modal.Body className="harcodeForm" style={{height:"750px"}}>
<div style={{height:"100%"}}>
<div className="w-15 mb-1" style={{ float:"left"}}>
<Button value={1} onClick={ (e) => {setSelectTab(Number(e.currentTarget.value))} } className={selectTab === 1 ? 'btn btn-primary mr-1' : 'btn btn-secondary mr-1'}>onLoad</Button>
<Button value={2} onClick={ (e) => {setSelectTab(Number(e.currentTarget.value))} } className={selectTab === 2 ? 'btn btn-primary' : 'btn btn-secondary'} >nextClick</Button>
</div>
<div className="w-15 mb-1">
<div className='custom-sel'>
<Button onClick={ codeLib } className='btn btn-secondary float-right'>코드 게시판</Button>
{
<CodeBoardModal show={codeBoardModal} onHide={() => setCodeBoardModal(false)} questionInfo={props.questionInfo}/>
}
<Form.Control style={{cursor:"pointer", width:"18vh", height:"3vh"}} onChange={ historyChange } className='ml-1 mr-1 float-right sel-box' as='select'>
<option value=''>{'Code History'}</option>
{
historyArray.map((ele:historyCodeType, index:number) => {
return(
<option key={index} value={ele.regDate}>{ele.regDate}</option>
)
})
}
</Form.Control>
</div>
</div>
<div style={{maxHeight:"95%",height:"95%"}}>
{
selectTab === 1 ?
<div className="input-group input-group-sm mt-3 mb-3" style={{height:"98%"}}>
<Editor
height="100%"
language="javascript"
theme="vs-dark"
value={ onLoadCode }
onChange={ (value) => setOnLoadCode(String(value)) }
options={{
fontSize: 16,
formatOnType: true,
autoClosingBrackets: "always",
minimap: { enabled: false },
}}
/>
</div>
:
<div className="input-group input-group-sm mt-3 mb-3" style={{height:"98%"}}>
<Editor
height="100%"
language="javascript"
theme="vs-dark"
value={ onNextCode }
onChange={ (value) => setOnNextCode(String(value)) }
options={{
fontSize: 16,
formatOnType: true,
autoClosingBrackets: "always",
minimap: { enabled: false },
}}
/>
</div>
}
</div>
</div>
</Modal.Body>
<Modal.Footer>
<div className='mt-2 mr-1 float-right'>
<Button className='project-save-btn mr-2' variant="primary" onClick={ hardCodingInsert }>저장</Button>
<Button variant="secondary" onClick={()=>{props.onHide()}}>닫기</Button>
</div>
</Modal.Footer>
</Modal>
);
}

View File

@@ -0,0 +1,107 @@
import { useEffect, useRef, useState } from "react";
import axios from "axios";
import { Button, Form, Modal, Table } from "react-bootstrap";
import React from "react";
import * as XLSX from 'xlsx';
import ExcelJS from 'exceljs'
import { saveAs } from 'file-saver';
import { TableDataRow } from "@modules/TypeModule";
import { URL_SEED, URL_SUN } from "@modules/AxiosModule";
import { useRecoilValue } from "recoil";
import { loginToken, memberInfo } from "@token/Token";
export const InterviewerSurveyDel = (props:{
show:boolean,
onHide:() => void,
selectSurveyId:any,
capiLoginInfo:any
getProjectList:() => void;
capiProjectClickStatus:() => void;
}) => {
const [deleteReason, setDeleteReason] = useState("");
const interViewersurveyDataDeleteRequest = () => {
if(deleteReason.length === 0){
alert("삭제 이유를 기입하여주세요.");
return false;
}
if(window.confirm("해당 데이터를 삭제하시겠습니까?")){
const data = {
interviewerId: props.capiLoginInfo.code,
projectCode: props.selectSurveyId.projectCode,
answerId: props.selectSurveyId.answerId,
reason: deleteReason,
result: 0
}
axios.post(URL_SUN +'/capi/surveyDataDeleteRequest', data, {
}).then((response) => {
alert("삭제 되었습니다.");
props.onHide()
props.getProjectList();
props.capiProjectClickStatus();
}).catch((error) => {
console.log("surveyDataDeleteRequest Error:", error);
})
}
}
return(
<Modal show={props.show} size="xl" backdrop='static'>
<Modal.Header>
<Modal.Title className="text-center">
샘플 삭제
</Modal.Title>
</Modal.Header>
<Modal.Body className="logicForm" style={{maxHeight:"450px!important", height:"450px", overflowY:"auto"}}>
<React.Fragment>
<Table className="tbe-list text-center mt-2" style={{tableLayout:"fixed", textAlign:"center"}}>
<thead>
<tr style={{borderRadius: "4px 4px 0 0"}}>
<th style={{borderRight: "2px solid #fff", borderRadius:"4px 0 0 0 "}}>ID</th>
<th style={{borderRight: "2px solid #fff", borderRadius:"0 4px 0 0 "}}>진행 문항</th>
<th style={{borderRight: "2px solid #fff", borderRadius:"0 4px 0 0 "}}>최종입력</th>
{/* <th style={{borderRight: "2px solid #fff", borderRadius:"0 4px 0 0 "}}>쿼터 정보</th> */}
<th style={{borderRight: "2px solid #fff", borderRadius:"0 4px 0 0 "}}>상태</th>
</tr>
</thead>
<tbody>
<tr >
<td>{props.selectSurveyId.answerId}</td>
<td>{props.selectSurveyId.answerEndQuestionId}</td>
<td>{props.selectSurveyId.answerEndDate}</td>
{/* <td>쿼터</td> */}
<td>
{ props.selectSurveyId.answerState === 1 ? "진행"
: props.selectSurveyId.answerState === 10 ? "완료"
: props.selectSurveyId.answerState === 98 ? "쿼터아웃"
: props.selectSurveyId.answerState === 99 ? "스크린"
: null
}
</td>
</tr>
</tbody>
</Table>
<Form.Label>삭제 사유</Form.Label>
<div>
<textarea style={{width:"100%", height:"200px"}}
onChange={(e) => setDeleteReason(e.target.value)}
value={deleteReason}
placeholder="삭제 사유를 적어주세요."
/>
</div>
</React.Fragment>
</Modal.Body>
<Modal.Footer>
<div className='mt-2 mr-1 float-right'>
<Button className='project-save-btn mr-2' variant="danger" onClick={interViewersurveyDataDeleteRequest}>삭제</Button>
<Button variant="secondary" onClick={()=>{props.onHide()}}>닫기</Button>
</div>
</Modal.Footer>
</Modal>
)
}

View File

@@ -0,0 +1,245 @@
import { useRef, useState, useEffect } from "react";
import { Button, Modal } from "react-bootstrap";
import { SetterOrUpdater, useRecoilState } from "recoil";
import { modalProcessStatus } from "@token/Token";
import type { questionInfoType, labelInfoType } from "@modules/TypeModule";
import SunEditor from "suneditor-react";
import SunEditorCore from "suneditor/src/lib/core";
import "suneditor/dist/css/suneditor.min.css";
export const LabelModal = (props:{
show:boolean,
onHide: () => void,
dimesionText:string,
labelDimension:number,
questionUpdate:questionInfoType,
setQuestionUpdate:SetterOrUpdater<questionInfoType>
}) => {
const editor = useRef<SunEditorCore>();
const [labelValue, setLabelValue] = useState('');
const [labelTextArray, setLabelTextArray] = useState<labelInfoType[] | undefined>([])
const [modalProcess, setModalProcess] = useRecoilState(modalProcessStatus);
const getSunEditorInstance = (SunEditor: SunEditorCore) => {
editor.current = SunEditor
}
const makeLabelString = (context:labelInfoType[]) => {
let editorArea = "";
context.forEach((ele) => {
editorArea += "<div>" + ele.value + "|" + ele.label + "</div>";
})
setLabelValue(editorArea);
}
useEffect(() => {
if(props.show === true){
if(props.labelDimension === 1){
setLabelTextArray([...props.questionUpdate.scalar_label!.label_info]);
}
if(props.labelDimension === 2){
setLabelTextArray([...props.questionUpdate.matrix_label!.label_info]);
}
if(props.labelDimension === 3){
setLabelTextArray([...props.questionUpdate.tensor_label!.label_info]);
}
}
},[props.questionUpdate.question_unique_key, props.show, props.labelDimension, props.questionUpdate.question_type])
useEffect(() => {
if(labelTextArray !== undefined){
makeLabelString(labelTextArray);
}
}, [labelTextArray]);
const makeLabelContent = (content:string) => {
content = content.replace(/<br>/g,"<\/div><div>")
.replace(/<p[^>]*>(.*?)<\/p>/g, "<div>$1</div>")
.replace(/<\/?(table|tbody|tr|td)[^>]*>/g, "");
const pattern = /<div>[\s\S]*?<\/div>/g;
const matches = content.match(pattern);
const filteredMatches = matches?.filter(match => {
const contentWithoutTags = match.replace(/<[^>]+>/g, '');
return contentWithoutTags
});
return filteredMatches;
}
const onHide = () => {
setLabelValue('');
setLabelTextArray([]);
props.onHide(); // 모달 닫기
}
// eslint-disable-next-line react-hooks/exhaustive-deps
const mackContent = (content:string) => {
let tempContent = content !== '' ? content : labelValue;
const addQuestionInfo = makeLabelContent(tempContent);
let infoArray:labelInfoType[] = [];
addQuestionInfo?.map((ele:string, index:number) => {
let setValue = index+1;
let setLabel = ele;
let valuePattern = /(\d+\|)/gi;
let isNotPattern = /{n}/gi;
let isEtcPattern = /{T(?!N)(\|?.)*}/gi;
let isEtcNumberPattern = /{TN(\|?.)*}/gi;
const isEtc = isEtcPattern.test(ele);
const isEtcNumber = isEtcNumberPattern.test(ele);
const isNot = isNotPattern.test(ele);
const regexValue = ele.match(valuePattern);
if(regexValue){
setLabel = setLabel.replace(regexValue[0], "");
setValue = Number(regexValue[0].replace("|",""));
}
setLabel = setLabel.replace(/<div>/g, "").replace(/<\/div>/g, "");
infoArray.push(
{
order: index + 1,
value: setValue,
label: setLabel,
open_type: 0,
decimal_point: 0,
not_duplicate: 0,
prefix: "",
suffix: "",
placeholder:"",
range: "",
is_etc: isEtc === true ? 1 : isEtcNumber === true ? 2 : 0,
is_not: isNot === true ? 1 : 0
}
)
})
if(verifyLabelInfo(infoArray)){
setLabelInfo(infoArray)
}
}
const setLabelInfo = (infoArray:labelInfoType[]) => {
let tempQuestionUpdate = {...props.questionUpdate};
switch (props.labelDimension){
case 1:
tempQuestionUpdate.scalar_label!.label_info = infoArray;
break;
case 2:
tempQuestionUpdate.matrix_label!.label_info = infoArray;
break;
case 3:
tempQuestionUpdate.tensor_label!.label_info = infoArray;
break;
}
props.setQuestionUpdate(tempQuestionUpdate)
setLabelValue('');
setLabelTextArray([]);
alert('등록되었습니다');
setModalProcess({
modalProcessStatus: true
});
props.onHide();
}
const verifyLabelInfo = (infoArray:labelInfoType[]) : boolean => {
const duplicateValue = infoArray.filter((item, i) => {
return (
infoArray.findIndex((item2, j) => {
return item.value === item2.value;
}) !== i
);
});
if(duplicateValue.length > 0){
alert('중복된 값이 있습니다.');
return false;
}
if(infoArray.filter((ele) => ele.label === '').length > 0){
if(!window.confirm('빈 보기가 있습니다. 그래도 저장하시겠습니까?')){
return false;
}
}
return true;
}
useEffect(() => {
const handleKeySave = (e: { key: string; ctrlKey: boolean; preventDefault: () => void; }) => {
if(props.show && e.ctrlKey && e.key?.toLowerCase() === "s"){
e.preventDefault();
mackContent('');
}
}
window.addEventListener('keydown', handleKeySave);
return () => {
window.removeEventListener('keydown', handleKeySave);
};
},[props.show, mackContent, labelValue])
return (
<Modal show={props.show} onHide={props.onHide} size="lg" backdrop='static'>
<Modal.Header>
<Modal.Title>
{
props.dimesionText +' 보기 설정'
}
</Modal.Title>
</Modal.Header>
<Modal.Body>
{
props.show ?
<SunEditor
getSunEditorInstance={getSunEditorInstance}
setOptions={{
buttonList: [
["undo", "redo"],
// ['paragraphStyle', 'blockquote'],
["bold", "underline", "italic"],
["fontColor", "hiliteColor"],
// ['math'] //You must add the 'katex' library at options to use the 'math' plugin.
//['imageGallery'], // You must add the "imageGalleryUrl".
// ["fullScreen", "showBlocks", "codeView"],
["removeFormat"],
["align"],
["fontSize"]
//['save'],
// '/', Line break
], // Or Array of button list, eg. [['font', 'align'], ['image']]
fontSize : [
8, 10, 14, 18, 24, 36
],
defaultTag: "div",
minHeight: "300px",
showPathLabel: false,
callBackSave: function (contents) {
mackContent(contents) //안에
}
}}
lang={'ko'}
onChange={(e) => setLabelValue(e)}
// onKeyUp={handleKeyUp}
setContents={labelValue}
autoFocus={true}
/>
: null
}
</Modal.Body>
<span className='explain ml-3 mb-1' style={{"marginTop":"-10px"}}>
이미지 태그 예시: {'{IMG|파일명|100px|100px}'}<br/>
PDF 태그 예시: {'{PDF|파일명|하이퍼링크 텍스트}'}<br/>
비디오 태그 예시: {'{VID|파일명 or 링크|100%|100%}'}
</span>
<Modal.Footer>
<Button className='project-save-btn' variant="primary" onClick={()=> {mackContent('')}}>등록</Button>
<Button variant="secondary" onClick={onHide}>닫기</Button>
</Modal.Footer>
</Modal>
)
}

View File

@@ -0,0 +1,312 @@
import { useCallback, useEffect, useState } from "react";
import { Button, Modal } from "react-bootstrap";
import {useRecoilState } from "recoil";
import axios from "axios";
import type { logicType, questionInfoType } from "@modules/TypeModule";
import { URL_SEED } from "@modules/AxiosModule";
import { loginToken, memberInfo } from "@token/Token";
import { LogicChild} from "@componentsQuestionSetup/LogicChild";
import { DndProvider } from "react-dnd";
import { HTML5Backend } from "react-dnd-html5-backend";
import update from "immutability-helper";
export const SetLogicModal = (props:{
show:boolean,
onHide:()=>void,
modalQidTitle:string,
projectCode:string,
questionInfo:questionInfoType[],
questionUniqueKey:number
}) => {
interface logicDataType {
project_code:string
question_unique_key:number
before_logic:logicType[]
after_logic:logicType[]
reg_member:number
}
const [info, setInfo] = useRecoilState(memberInfo);
const [token, setToken] = useRecoilState(loginToken);
const [logicData, setLogicData] = useState<logicDataType|null>(null)
const [beforeLogicArray, setBeforeLogicArray] = useState<logicType[]>([]);
const [afterLogicArray, setAfterLogicArray] = useState<logicType[]>([]);
const getLogicInfo = () => {
axios.get(URL_SEED+'/question/getQuestionLogic', {
params: {
project_code : props.projectCode,
question_unique_key: props.questionUniqueKey
},
headers: {
'Authorization': `Bearer ${token.access}`,
}
}).then((response) => {
if(response.status === 200){
if(response.data.before_logic !== null){
setBeforeLogicArray(response.data.before_logic);
}else{
setBeforeLogicArray([]);
}
if(response.data.after_logic !== null){
setAfterLogicArray(response.data.after_logic);
}else{
setAfterLogicArray([]);
}
}
}).catch(error => {
console.log("getQuestionLogic", error);
})
}
const verifyLogic = async () => {
setLogicData(null);
let qidCondition = /\b([A-Za-z]\w+)+(?![^\[]*\])/g
let valueCondition = /[=<>!]+\s*(?:[\d\/\,]*(\"\")*)/g
if(beforeLogicArray.length === 0){
setBeforeLogicArray([]);
}
if(afterLogicArray.length === 0){
setAfterLogicArray([]);
}
/** 사전로직에 빈값 확인 */
if(beforeLogicArray.filter((ele) => ele.logic === "" || ele.page === "").length > 0){
alert("빈값이 있습니다.");
return false;
}
/** 사후로직에 빈값 확인 */
if(afterLogicArray.filter((ele) => ele.logic === "" || ele.page === "").length > 0){
alert("빈값이 있습니다.");
return false;
}
let errorBeforeString = "";
beforeLogicArray.some((ele, idx) => {
let beforeLogicText = ele.logic?.toUpperCase().trim(); // 모든 공백 제거
let leftCount = [...beforeLogicText.matchAll(/\(/g)].length
let rightCount = [...beforeLogicText.matchAll(/\)/g)].length
if(leftCount !== rightCount){
errorBeforeString = `사전로직 ${(idx+1)}번째의 괄호를 확인해 주세요`;
return true;
}
let qidArray = [...beforeLogicText.matchAll(qidCondition)].filter((fele)=> !["AND","OR"].includes(fele[0]));
qidArray.some((mele) => {
if(props.questionInfo.filter((fele) => fele.question_id === mele[0]).length === 0){
errorBeforeString = `사전로직 ${(idx+1)}번째의 QID를 확인해 주세요`;
return true;
}
})
if(errorBeforeString){
return true;
}
})
if(errorBeforeString){
alert(errorBeforeString);
return false;
}
/** 사후로직에 빈값 확인 */
let errorAfterString = "";
afterLogicArray.some((ele, idx) => {
let afterLogicText = ele.logic.toUpperCase().trim(); // 모든 공백 제거
let leftCount = [...afterLogicText.matchAll(/\(/g)].length
let rightCount = [...afterLogicText.matchAll(/\)/g)].length
if(leftCount !== rightCount){
errorAfterString = `사후로직 ${(idx+1)}번째의 괄호를 확인해 주세요`;
return true;
}
let qidArray = [...afterLogicText.matchAll(qidCondition)].filter((fele)=> !["AND","OR"].includes(fele[0]));
qidArray.some((mele) => {
if(props.questionInfo.filter((fele) => fele.question_id === mele[0]).length === 0){
errorAfterString = `사후로직 ${(idx+1)}번째의 QID를 확인해 주세요`;
return true;
}
})
if(errorAfterString){
return true;
}
})
if(errorAfterString){
alert(errorAfterString);
return false;
}
/** 로직 검증 */
const data = {
project_code: props.projectCode,
question_unique_key: props.questionUniqueKey,
before_logic: beforeLogicArray,
after_logic: afterLogicArray,
reg_member: info.member_code
}
axios.post(URL_SEED+'/question/doLogicVerify', data , {
headers: {
'Authorization': `Bearer ${token.access}`,
}
}).then((response) => {
if(response.status === 200){
setLogicData({...data})
}
}).catch((error) => {
alert(error.response.data.errorMessage);
console.log("doLogicVerifyError:", error)
})
}
useEffect(()=>{
if(logicData){
//////insert logic
axios.post(URL_SEED+'/question/setQuestionLogic', logicData , {
headers: {
'Authorization': `Bearer ${token.access}`,
}
}).then((response)=>{
if(response.status === 200){
alert("저장되었습니다.");
setBeforeLogicArray([]);
setAfterLogicArray([]);
setLogicData(null);
props.onHide();
}
}).catch((error)=>{
console.log("setQuestionLogicError ", error);
})
}
},[logicData])
const addBeforeLogicBtn = () => {
setBeforeLogicArray([...beforeLogicArray, {"logic":"","page":""}]);
}
const addAfterLogicBtn = () => {
setAfterLogicArray([...afterLogicArray, {"logic":"","page":""}]);
}
const moveBeforeLogicChild = useCallback((dragIndex:number, hoverIndex:number) => {
setBeforeLogicArray((prevValues) =>
update(prevValues, {
$splice: [
[dragIndex, 1],
[hoverIndex, 0, prevValues[dragIndex]]
]
})
);
}, []);
const renderBeforeLogicChild = useCallback((logicData:logicType, logicArray:logicType[], questionInfo:questionInfoType[], eleIndex:number, questionUK:number) => {
return (
<LogicChild
key={eleIndex}
logicGroup={"before"}
logicData={logicData}
questionInfo={questionInfo}
eleIndex={eleIndex}
logicArray = {logicArray}
questionUK={questionUK}
setLogicArray = {setBeforeLogicArray}
moveLogicChild = {moveBeforeLogicChild}
/>
)
}, []);
const moveAfterLogicChild = useCallback((dragIndex:number, hoverIndex:number) => {
setAfterLogicArray((prevValues) =>
update(prevValues, {
$splice: [
[dragIndex, 1],
[hoverIndex, 0, prevValues[dragIndex]]
]
})
);
}, []);
const renderAfterLogicChild = useCallback((logicData:logicType, logicArray:logicType[], questionInfo:questionInfoType[], eleIndex:number, questiuonUK:number) => {
return (
<LogicChild
key={eleIndex}
logicGroup={"after"}
logicData={logicData}
questionInfo={questionInfo}
eleIndex={eleIndex}
logicArray = {logicArray}
questionUK={questiuonUK}
setLogicArray = {setAfterLogicArray}
moveLogicChild = {moveAfterLogicChild}
/>
)
}, []);
useEffect(() => {
if(props.show){
getLogicInfo();
}
},[props.show])
//s단축키
useEffect(() => {
const logicSaveCtrl = (e: { key: string; ctrlKey: boolean; preventDefault: () => void; }) => {
if(props.show && e.ctrlKey && e.key?.toLowerCase() === "s"){
e.preventDefault();
verifyLogic();
}
}
window.addEventListener('keydown', logicSaveCtrl);
return () => {
window.removeEventListener('keydown', logicSaveCtrl);
};
},[props.show, verifyLogic])
return (
<Modal show={props.show} size="lg" backdrop='static'>
<Modal.Header>
<Modal.Title className="text-center">
{props.modalQidTitle} 로직설정
</Modal.Title>
</Modal.Header>
<Modal.Body className="logicForm" style={{maxHeight: "600px!important",height:"600px"}}>
<div style={{height:"50%"}}>
<div className="mb-2 logic-title">사전 로직</div>
<div>
<Button onClick={ addBeforeLogicBtn }>사전 로직추가</Button>
</div>
<DndProvider backend={HTML5Backend}>
<div style={{overflowY:"auto",maxHeight:"75%",height:"75%"}}>
{
beforeLogicArray?.map((ele, index) => renderBeforeLogicChild( ele, beforeLogicArray, props.questionInfo, index, props.questionUniqueKey))
}
</div>
</DndProvider>
</div>
<div className="logicForm" style={{height:"50%"}}>
<div className="mb-2 logic-title" >사후 로직</div>
<div>
<Button onClick={ addAfterLogicBtn }>사후 로직추가</Button>
</div>
<DndProvider backend={HTML5Backend}>
<div style={{overflowY:"auto",maxHeight:"75%",height:"75%"}}>
{
afterLogicArray?.map((ele, index) => renderAfterLogicChild( ele, afterLogicArray, props.questionInfo, index, props.questionUniqueKey))
}
</div>
</DndProvider>
</div>
</Modal.Body>
<Modal.Footer>
<div className='mt-2 mr-1 float-right'>
<Button className='project-save-btn mr-2' variant="primary" onClick={ verifyLogic }>저장</Button>
<Button variant="secondary" onClick={()=>{props.onHide()}}>닫기</Button>
</div>
</Modal.Footer>
</Modal>
);
}

View File

@@ -0,0 +1,998 @@
import React, { useEffect, useState } from "react"
import { SetterOrUpdater, useRecoilState, useRecoilValue } from "recoil"
import { Button, Form, Modal } from "react-bootstrap"
import type { autoRecodeArray, labelInfoType, questionInfoType } from "@modules/TypeModule"
import { regexPureNum, regexNumRange, regexSetNumRange, regexDateRange, regexSetDateRange, regexAuto } from "@modules/Function";
import { loginToken, memberInfo, modalProcessStatus, projectInfo } from "@token/Token"
import { Switch } from "@mui/material"
import axios from "axios";
import { URL_SEED } from "@modules/AxiosModule";
export const ScalarNumericModal = (props:{
show:boolean,
onHide: () => void,
questionUpdate:questionInfoType,
setQuestionUpdate:SetterOrUpdater<questionInfoType>
}) => {
const [modalProcess, setModalProcess] = useRecoilState(modalProcessStatus);
const [numericOpenType, setNumericOpenType] = useState<number | undefined>(1);
const [numericDecimalPoint, setNumericDecimalPoint] = useState<number | undefined>(0);
const [numericOpenPrefix, setNumericOpenPrefix] = useState<string | undefined>("");
const [numericOpenRange, setNumericOpenRange] = useState<string | undefined>("");
const [numericOpenPostfix, setNumericOpenPostfix] = useState<string | undefined>("");
// useEffect(() => {
// setNumericDecimalPoint(0);
// if(props.questionUpdate.scalar_label?.label_info[0].open_type !== numericOpenType){
// setNumericOpenRange("");
// }
// else{
// setNumericOpenRange(props.questionUpdate.scalar_label?.label_info[0]?.range);
// }
// },[numericOpenType])
useEffect(() => {
if(props.questionUpdate.scalar_label){
setNumericOpenType(props.questionUpdate.scalar_label?.label_info[0]?.open_type);
setNumericDecimalPoint(props.questionUpdate.scalar_label?.label_info[0]?.decimal_point);
setNumericOpenPrefix(props.questionUpdate.scalar_label?.label_info[0]?.prefix);
setNumericOpenRange(props.questionUpdate.scalar_label?.label_info[0]?.range);
setNumericOpenPostfix(props.questionUpdate.scalar_label?.label_info[0]?.suffix);
}
},[props.questionUpdate.scalar_label])
const rangeChange = (e:React.ChangeEvent<HTMLInputElement>) => {
if(numericOpenType === 3){
setNumericOpenRange(regexDateRange(e.currentTarget.value))
}else{
setNumericOpenRange(regexNumRange(e.currentTarget.value))
}
}
const setRangeText = (e:React.ChangeEvent<HTMLInputElement>) => {
if(numericOpenType === 3){
setNumericOpenRange(regexSetDateRange(e.currentTarget.value))
}else{
setNumericOpenRange(regexSetNumRange(e.currentTarget.value))
}
}
const mackContent = () => {
let infoArray:labelInfoType[] = [];
infoArray.push(
{
order: 1,
value: 1,
label: '',
open_type: numericOpenType,
decimal_point: numericDecimalPoint,
not_duplicate: 0,
prefix: numericOpenPrefix,
range: numericOpenRange,
placeholder:"",
suffix: numericOpenPostfix,
is_etc: 0,
is_not: 0
}
)
setModalProcess({
modalProcessStatus: true
});
props.onHide();
let tempQuestionUpdate = {...props.questionUpdate}
tempQuestionUpdate.scalar_label!.label_info = infoArray;
props.setQuestionUpdate(tempQuestionUpdate);
alert('등록되었습니다');
}
//s단축키
useEffect(() => {
const handleKeySave = (e: { key: string; ctrlKey: boolean; preventDefault: () => void; }) => {
if(props.show && e.ctrlKey && e.key?.toLowerCase() === "s"){
e.preventDefault();
mackContent();
}
}
window.addEventListener('keydown', handleKeySave);
return () => {
window.removeEventListener('keydown', handleKeySave);
};
},[props.show, mackContent])
return(
<Modal show={props.show} onHide={props.onHide} size="xl" backdrop='static'>
<Modal.Header>
<Modal.Title>
{ "Numeric Open 설정" }
</Modal.Title>
</Modal.Header>
<Modal.Body>
{
props.show ?
<div className="input-group input-group-sm mt-1 mb-3">
<div className='custom-sel mr-2' style={{"width":"15%"}}>
<Form.Control as='select' className='sel-box' value={ numericOpenType } onChange={ (e) => setNumericOpenType(Number(e.currentTarget.value)) }>
<option value={1}>일반</option>
<option value={2}>소수점</option>
<option value={3}>날짜</option>
</Form.Control>
</div>
{ numericOpenType === 2 ?
<input
type="text"
className="mr-2"
style={{"width":"15%"}}
placeholder='소수점 자리'
value={ numericDecimalPoint }
onChange={(e) => setNumericDecimalPoint(Number(regexPureNum(e.currentTarget.value)))}
//onKeyUp={(e) => setNumericDecimalPoint(Number(regexPureNum(e.currentTarget.value)))}
/>
:
null}
<input
type="text"
className="mr-2"
style={{"width":"20%"}}
placeholder='Pre Text'
value={ numericOpenPrefix }
onChange={(e) => setNumericOpenPrefix(e.currentTarget.value)}
//onKeyUp={(e) => setNumericOpenPrefix(e.currentTarget.value)}
/>
<input
type="text"
className="mr-2"
style={numericOpenType !== 2 ? {"width":"40%"} : {"width":"20%"}}
placeholder={ numericOpenType === 3 ? '범위 지정 ex) 2024/01/31~2024/12/31' : "범위 지정 ex) 1~99" }
value={ numericOpenRange }
onChange={ rangeChange }
onBlur={ setRangeText }
/>
<input
type="text"
className="mr-2"
style={{"width":"20%"}}
placeholder='Post Text'
value={ numericOpenPostfix }
onChange={(e) => setNumericOpenPostfix(e.currentTarget.value)}
//onKeyUp={(e) => setNumericOpenPostfix(e.currentTarget.value)}
/>
</div>
: null
}
</Modal.Body>
<Modal.Footer>
<Button className='project-save-btn' variant="primary" onClick={ mackContent }>등록</Button>
<Button variant="secondary" onClick={props.onHide}>닫기</Button>
</Modal.Footer>
</Modal>
)
}
export const ScalarStringModal = (props:{
show:boolean,
onHide: () => void,
questionUpdate:questionInfoType,
setQuestionUpdate:SetterOrUpdater<questionInfoType>
}) => {
const [modalProcess, setModalProcess] = useRecoilState(modalProcessStatus);
const [stringOpenType, setStringOpenType] = useState<number | undefined>(1);
const [stringOpenPrefix, setStringOpenPrefix] = useState<string | undefined>("");
// 복수제출 버튼 Toggle
const [stringScalarToggle, setStringScalarToggle] = useState<boolean | undefined>(false);
const [stringOpenPlaceHolder, setStringOpenPlaceHolder] = useState<string | undefined>("");
const [stringOpenPostfix, setStringOpenPostfix] = useState<string | undefined>("");
useEffect(() => {
if(stringOpenType !== 4 && stringOpenType !== 5){
setStringScalarToggle(false);
}
},[stringOpenType])
useEffect(() => {
if(props.questionUpdate.scalar_label){
setStringOpenType(props.questionUpdate.scalar_label?.label_info[0]?.open_type);
setStringOpenPrefix(props.questionUpdate.scalar_label?.label_info[0]?.prefix);
setStringScalarToggle(props.questionUpdate.scalar_label?.label_info[0]?.not_duplicate === 0 ? false : true);
setStringOpenPlaceHolder(props.questionUpdate.scalar_label?.label_info[0]?.placeholder);
setStringOpenPostfix(props.questionUpdate.scalar_label?.label_info[0]?.suffix);
}
},[props.questionUpdate.scalar_label])
const mackContent = () => {
let infoArray:labelInfoType[] = [];
infoArray.push(
{
order: 1,
value: 1,
label: '',
open_type: stringOpenType,
decimal_point: 0,
not_duplicate: stringScalarToggle === false ? 0 : 1,
prefix: stringOpenPrefix,
range: "",
placeholder: stringOpenPlaceHolder,
suffix: stringOpenPostfix,
is_etc: 0,
is_not: 0
}
)
setModalProcess({
modalProcessStatus: true
});
props.onHide();
let tempQuestionUpdate = {...props.questionUpdate}
tempQuestionUpdate.scalar_label!.label_info = infoArray;
props.setQuestionUpdate(tempQuestionUpdate);
alert('등록되었습니다');
}
//s단축키
useEffect(() => {
const handleKeySave = (e: { key: string; ctrlKey: boolean; preventDefault: () => void; }) => {
if(props.show && e.ctrlKey && e.key?.toLowerCase() === "s"){
e.preventDefault();
mackContent();
}
}
window.addEventListener('keydown', handleKeySave);
return () => {
window.removeEventListener('keydown', handleKeySave);
};
},[props.show, mackContent])
return(
<Modal show={props.show} onHide={props.onHide} size="xl" backdrop='static'>
<Modal.Header>
<Modal.Title>
{ "String Open 설정" }
</Modal.Title>
</Modal.Header>
<Modal.Body>
{
props.show ?
<div className="input-group input-group-sm mt-1 mb-3">
<div className='custom-sel mr-2' style={{"width":"15%"}}>
<Form.Control as='select' className='sel-box'
value={ stringOpenType }
onChange={(e) => setStringOpenType(Number(e.currentTarget.value))}
>
<option value={1}>일반</option>
<option value={2}>한글</option>
<option value={3}>영어</option>
<option value={4}>이메일</option>
<option value={5}>전화번호</option>
<option value={6}>장문</option>
</Form.Control>
</div>
{
stringOpenType === 4 || stringOpenType === 5 ?
<Form>
<div>
<span style={{cursor:"pointer"}} onClick={ () => {setStringScalarToggle(!stringScalarToggle)}}>
<Switch
name="stringMulti"
checked={ stringScalarToggle }
onChange={() => { setStringScalarToggle(!stringScalarToggle)}}
/>
<span className='mb-1 mr-3' style={{"fontSize":"15px"}}>중복 막기</span>
</span>
</div>
</Form>
:
<Form style={{"width":"12%"}} />
}
{ stringOpenType !== 6 ?
<input
type="text"
className="mr-2"
style={{"width":"20%"}}
placeholder='Pre Text'
value={ stringOpenPrefix }
onChange={(e) => setStringOpenPrefix(e.currentTarget.value)}
onKeyUp={(e) => setStringOpenPrefix(e.currentTarget.value)}
/> :null
}
<input
type="text"
className="mr-2"
style={stringOpenType !== 6 ? {"width":"25%"} : {"width":"65%"}}
placeholder='Placeholder 지정'
value={ stringOpenPlaceHolder }
onChange={(e) => setStringOpenPlaceHolder(e.currentTarget.value)}
onKeyUp={(e) => setStringOpenPlaceHolder(e.currentTarget.value)}
/>
{ stringOpenType !== 6 ?
<input
type="text"
className="mr-2"
style={{"width":"20%"}}
placeholder='Post Text'
value={ stringOpenPostfix }
onChange={(e) => setStringOpenPostfix(e.currentTarget.value)}
onKeyUp={(e) => setStringOpenPostfix(e.currentTarget.value)}
/>
:null
}
</div>
: null
}
</Modal.Body>
<Modal.Footer>
<Button className='project-save-btn' variant="primary" onClick={ mackContent }>등록</Button>
<Button variant="secondary" onClick={props.onHide}>닫기</Button>
</Modal.Footer>
</Modal>
)
}
export const MatrixNumericModal = (props:{
show:boolean,
onHide: () => void,
questionUpdate:questionInfoType,
setQuestionUpdate:SetterOrUpdater<questionInfoType>
}) => {
const [modalProcess, setModalProcess] = useRecoilState(modalProcessStatus);
const [selectedOption, setSelectedOption] = useState(1);
const [matrixOpenArray, setMatrixOpenArray] = useState<labelInfoType[]>([]);
const addMatrixOpen = () => {
setMatrixOpenArray([...matrixOpenArray, {
order: 1,
value: 1,
label: '',
open_type: 1,
decimal_point: 0,
not_duplicate: 0,
prefix: "",
range: "",
placeholder:"",
suffix: "",
is_etc: 0,
is_not: 0
}])
}
useEffect(() => {
setMatrixOpenArray(props.questionUpdate.matrix_label!.label_info);
},[props.questionUpdate.matrix_label?.label_info])
const changeOption = (e:any, index:number) => {
changeOpenType(e, index);
setSelectedOption(e.currentTarget.value);
}
const changeAttrText = (e:React.ChangeEvent<HTMLInputElement>, index:number) => {
e.preventDefault();
let newArray = [...matrixOpenArray];
newArray[index].label = e.target.value;
setMatrixOpenArray(newArray);
}
const changeOpenType = (e:any, index:number) => {
e.preventDefault();
let newArray = [...matrixOpenArray];
let logicData = Number(e.target.value);
newArray[index].open_type = logicData
setMatrixOpenArray(newArray);
}
const changePrefixText = (e:React.ChangeEvent<HTMLInputElement>, index:number) => {
e.preventDefault();
let newArray = [...matrixOpenArray];
newArray[index].prefix = e.target.value;
setMatrixOpenArray(newArray);
}
const changeRangeText = (e:React.ChangeEvent<HTMLInputElement>, index:number) => {
e.preventDefault();
let newArray = [...matrixOpenArray];
if(matrixOpenArray[index]?.open_type === 3){
newArray[index].range = regexDateRange(e.target.value);
}else{
newArray[index].range = regexNumRange(e.target.value);
}
setMatrixOpenArray(newArray);
}
const changeDecimalPointText = (e:React.ChangeEvent<HTMLInputElement>, index:number) => {
e.preventDefault();
let newArray = [...matrixOpenArray];
newArray[index].decimal_point = Number(regexPureNum(e.target.value));
setMatrixOpenArray(newArray);
}
const setRangeText = (e:React.ChangeEvent<HTMLInputElement>, index:number) => {
e.preventDefault();
let newArray = [...matrixOpenArray];
if(matrixOpenArray[index]?.open_type === 2){
newArray[index].range = regexSetDateRange(e.target.value);
}else{
newArray[index].range = regexSetNumRange(e.target.value);
}
setMatrixOpenArray(newArray);
}
const changePostfixText = (e:React.ChangeEvent<HTMLInputElement>, index:number) => {
e.preventDefault();
let newArray = [...matrixOpenArray];
newArray[index].suffix = e.target.value;
setMatrixOpenArray(newArray);
}
const mackContent = () => {
let emptyFlag = false;
let infoArray:labelInfoType[] = [];
matrixOpenArray.map((matrixEle, matrixIdx) => {
let setValue = matrixIdx+1;
let setLabel = matrixEle;
let valuePattern = /(\d+\|)/gi;
const regexValue = matrixEle.label?.match(valuePattern);
if(regexValue){
setLabel.label = setLabel.label?.split("|")[1];
setValue = Number(regexValue[0].replace("|",""));
}
if(matrixEle.label?.trim()===""){
emptyFlag=true;
}
infoArray.push(
{
order: matrixIdx + 1,
value: setValue,
label: matrixEle.label,
open_type: matrixEle.open_type,
decimal_point: matrixEle.decimal_point,
prefix: matrixEle.prefix,
range: matrixEle.range,
placeholder: matrixEle.placeholder,
suffix: matrixEle.suffix,
is_etc: 0,
is_not: 0
}
)
})
if(emptyFlag){
alert('속성은 공백으로 설정할 수 없습니다.');
}
else{
setModalProcess({
modalProcessStatus: true
});
props.onHide();
let tempQuestionUpdate = {...props.questionUpdate}
tempQuestionUpdate.matrix_label!.label_info = infoArray;
props.setQuestionUpdate(tempQuestionUpdate);
alert('등록되었습니다');
}
}
const removeMatrixOpen = (e:React.MouseEvent<HTMLImageElement>, index:number) =>{
let newArray = [...matrixOpenArray].filter((ele, arrIdx) => index !== arrIdx );
setMatrixOpenArray(newArray);
}
const matrixOpenChild = (index:number) => {
return (
<div key={index} className="input-group input-group-sm mt-3">
<input
type="text"
className="mr-2"
style={{"width":"15%"}}
placeholder='속성'
value={ matrixOpenArray[index]?.label }
onChange={(e) => changeAttrText(e, index)}
/>
<div className='custom-sel mr-2' style={{"width":"15%"}}>
<Form.Control as='select' className='sel-box'
value={ matrixOpenArray[index]?.open_type }
onChange={ (e) => changeOption(e, index) }
>
<option value={1}>일반</option>
<option value={2}>소수점</option>
<option value={3}>날짜</option>
</Form.Control>
</div>
{matrixOpenArray[index]?.open_type === 2 ?
<input
type="text"
className="mr-2"
style={{"width":"10%"}}
placeholder='소수점 자리'
value={ matrixOpenArray[index]?.decimal_point }
onChange={(e) => changeDecimalPointText(e, index)}
/>
:null}
<input
type="text"
className="mr-2"
style={{"width":"15%"}}
placeholder='Pre Text'
value={ matrixOpenArray[index]?.prefix }
onChange={(e) => changePrefixText(e, index)}
/>
<input
type="text"
className="mr-2"
style={{"width":"20%"}}
placeholder={matrixOpenArray[index]?.open_type === 3 ? '범위 지정 ex) 2024/01/31~2024/12/31' : '범위 지정 ex) 1~99'}
value={ matrixOpenArray[index]?.range }
onChange={(e) => changeRangeText(e, index)}
onBlur={(e) => setRangeText(e, index)}
/>
<input
type="text"
className="mr-2"
style={{"width":"15%"}}
placeholder='Post Text'
value={ matrixOpenArray[index]?.suffix }
onChange={(e) => changePostfixText(e, index)}
/>
<img className="mr-2" src={'/public_img/Intersect.svg'} onClick={ (e) => removeMatrixOpen(e, index) }/>
</div>
)
}
//s단축키
useEffect(() => {
const handleKeySave = (e: { key: string; ctrlKey: boolean; preventDefault: () => void; }) => {
if(props.show && e.ctrlKey && e.key.toLowerCase() === "s"){
e.preventDefault();
mackContent();
}
}
window.addEventListener('keydown', handleKeySave);
return () => {
window.removeEventListener('keydown', handleKeySave);
};
},[props.show, mackContent])
return(
<Modal show={props.show} onHide={props.onHide} size="xl" backdrop='static'>
<Modal.Header>
<Modal.Title>
{ "Matrix Numeric 설정" }
</Modal.Title>
</Modal.Header>
<Modal.Body style={{"overflowY":"scroll"}}>
{
props.show ?
<React.Fragment>
<div>
<Button onClick={ addMatrixOpen } >Open 문항 추가</Button>
</div>
{
matrixOpenArray?.map((ele, index) => matrixOpenChild(index))
}
</React.Fragment>
: null
}
</Modal.Body>
<Modal.Footer>
<Button className='project-save-btn' variant="primary" onClick={ mackContent }>등록</Button>
<Button variant="secondary" onClick={props.onHide}>닫기</Button>
</Modal.Footer>
</Modal>
)
}
export const MatrixStringModal = (props:{
show:boolean,
onHide: () => void,
questionUpdate:questionInfoType,
setQuestionUpdate:SetterOrUpdater<questionInfoType>
}) => {
const [modalProcess, setModalProcess] = useRecoilState(modalProcessStatus);
const [matrixOpenArray, setMatrixOpenArray] = useState<labelInfoType[]>([]);
// 복수제출 버튼 Toggle
const [stringMulti, setStringMulti] = useState(false);
const addMatrixOpen = () => {
setMatrixOpenArray([...matrixOpenArray, {
order: 1,
value: 1,
label: '',
open_type: 1,
decimal_point: 0,
not_duplicate: 0,
prefix: "",
range: "",
placeholder:"",
suffix: "",
is_etc: 0,
is_not: 0
}])
}
useEffect(() => {
setMatrixOpenArray(props.questionUpdate.matrix_label!.label_info);
},[props.questionUpdate.matrix_label?.label_info])
const changeAttrText = (e:React.ChangeEvent<HTMLInputElement>, index:number) => {
e.preventDefault();
let newArray = [...matrixOpenArray];
newArray[index].label = e.target.value;
setMatrixOpenArray(newArray);
}
const changeDupulicate = (e:React.MouseEvent<HTMLElement>, index:number) => {
e.preventDefault();
let newArray = [...matrixOpenArray];
newArray[index].not_duplicate = stringMulti === false ? 0 : 1;
setMatrixOpenArray(newArray);
}
const changeOpenType = (e:any, index:number) => {
e.preventDefault();
let newArray = [...matrixOpenArray];
let logicData = Number(e.target.value);
newArray[index].open_type = logicData
if(logicData !== 4 && logicData !== 5){
newArray[index].not_duplicate = 0;
}
setMatrixOpenArray(newArray);
}
const changePrefixText = (e:React.ChangeEvent<HTMLInputElement>, index:number) => {
e.preventDefault();
let newArray = [...matrixOpenArray];
newArray[index].prefix = e.target.value;
setMatrixOpenArray(newArray);
}
const changePalaceHolderText = (e:React.ChangeEvent<HTMLInputElement>, index:number) => {
e.preventDefault();
let newArray = [...matrixOpenArray];
newArray[index].placeholder = e.target.value;
setMatrixOpenArray(newArray);
}
const changePostfixText = (e:React.ChangeEvent<HTMLInputElement>, index:number) => {
e.preventDefault();
let newArray = [...matrixOpenArray];
newArray[index].suffix = e.target.value;
setMatrixOpenArray(newArray);
}
const mackContent = () => {
let emptyFlag = false;
let infoArray:labelInfoType[] = [];
matrixOpenArray.map((matrixEle, matrixIdx) => {
let setValue = matrixIdx+1;
let setLabel = matrixEle;
let valuePattern = /(\d+\|)/gi;
const regexValue = matrixEle.label?.match(valuePattern);
if(regexValue){
setLabel.label = setLabel.label?.split("|")[1];
setValue = Number(regexValue[0].replace("|",""));
}
if(matrixEle.label?.trim() === ""){
emptyFlag = true;
}
infoArray.push(
{
order: matrixIdx + 1,
value: setValue,
label: matrixEle.label,
open_type: matrixEle.open_type,
decimal_point: 0,
not_duplicate: matrixEle.not_duplicate,
prefix: matrixEle.prefix,
range: "",
placeholder:matrixEle.placeholder,
suffix: matrixEle.suffix,
is_etc: 0,
is_not: 0
}
)
})
if(emptyFlag){
alert('속성은 공백으로 설정할 수 없습니다.');
}
else{
setModalProcess({
modalProcessStatus: true
});
props.onHide();
let tempQuestionUpdate = {...props.questionUpdate}
tempQuestionUpdate.matrix_label!.label_info = infoArray;
props.setQuestionUpdate(tempQuestionUpdate);
alert('등록되었습니다');
}
}
const removeMatrixOpen = (e:React.MouseEvent<HTMLImageElement>, index:number) =>{
let newArray = [...matrixOpenArray].filter((ele, arrIdx) => index !== arrIdx );
setMatrixOpenArray(newArray);
}
const matrixOpenChild = (index:number) => {
return (
<div key={index} className="input-group input-group-sm mt-1 mb-3">
<input
type="text"
className="mr-2"
style={{"width":"15%"}}
placeholder='속성'
value={ matrixOpenArray[index]?.label }
onChange={(e) => changeAttrText(e, index)}
/>
<div className='custom-sel mr-2' style={{"width":"10%"}}>
<Form.Control as='select' className='sel-box'
value={ matrixOpenArray[index]?.open_type }
onChange={(e) => changeOpenType(e, index)}
>
<option value={1}>일반</option>
<option value={2}>한글</option>
<option value={3}>영어</option>
<option value={4}>이메일</option>
<option value={5}>전화번호</option>
{
props.questionUpdate.question_dimension === 3? null//tensor일 경우 장문 지우기
:
<option value={6}>장문</option>
}
</Form.Control>
</div>
{
matrixOpenArray[index]?.open_type === 4 || matrixOpenArray[index]?.open_type === 5 ?
<Form>
<div>
<span style={{cursor:"pointer"}} onClick={ (e) => { changeDupulicate (e, index); setStringMulti(!stringMulti) } }>
<Switch name="stringMulti" checked={ matrixOpenArray[index].not_duplicate === 0 ? false : true } onChange={ () => setStringMulti(!stringMulti) } />
<span className='mb-1 mr-3' style={{"fontSize":"15px"}}>중복 막기</span>
</span>
</div>
</Form>
:
<Form style={{"width":"12%"}} />
}
<input
type="text"
className="mr-2"
style={{"width":"15%"}}
placeholder='Pre Text'
value={ matrixOpenArray[index]?.prefix }
onChange={(e) => changePrefixText(e, index)}
/>
<input
type="text"
className="mr-2"
style={{"width":"15%"}}
placeholder='Placeholder 지정'
value={ matrixOpenArray[index]?.placeholder }
onChange={(e) => changePalaceHolderText(e, index)}
/>
<input
type="text"
className="mr-2"
style={{"width":"15%"}}
placeholder='Post Text'
value={ matrixOpenArray[index]?.suffix }
onChange={(e) => changePostfixText(e, index)}
/>
<img className="mr-2" src={'/public_img/Intersect.svg'} onClick={ (e) => removeMatrixOpen(e, index) }/>
</div>
)
}
//s단축키
useEffect(() => {
const handleKeySave = (e: { key: string; ctrlKey: boolean; preventDefault: () => void; }) => {
if(props.show && e.ctrlKey && e.key.toLowerCase() === "s"){
e.preventDefault();
mackContent();
}
}
window.addEventListener('keydown', handleKeySave);
return () => {
window.removeEventListener('keydown', handleKeySave);
};
},[props.show, mackContent])
return(
<Modal show={props.show} onHide={props.onHide} size="xl" backdrop='static'>
<Modal.Header>
<Modal.Title>
{ "Matrix String Open 설정" }
</Modal.Title>
</Modal.Header>
<Modal.Body style={{"overflowY":"scroll"}}>
{
props.show ?
<React.Fragment>
<div>
<Button onClick={ addMatrixOpen }>Open 문항 추가</Button>
</div>
{
matrixOpenArray?.map((ele, index) => matrixOpenChild(index))
}
</React.Fragment>
: null
}
</Modal.Body>
<Modal.Footer>
<Button className='project-save-btn' variant="primary" onClick={ mackContent }>등록</Button>
<Button variant="secondary" onClick={props.onHide}>닫기</Button>
</Modal.Footer>
</Modal>
)
}
export const AutoRecodeModal = (props:{
show:boolean,
onHide: () => void,
questionUpdate:questionInfoType,
setQuestionUpdate:SetterOrUpdater<questionInfoType>,
setAutoRecodeArray:SetterOrUpdater<autoRecodeArray[]>
}) => {
const [autoArray, setAutoArray] = useState<autoRecodeArray[]>([]);
const info = useRecoilValue(memberInfo);
const project = useRecoilValue(projectInfo);
const token = useRecoilValue(loginToken);
let defaultAuto = {
idx: 0,
projectCode: project.prjcode,
questionUniqueKey: props.questionUpdate.question_unique_key,
recodeValue: 0,
recodeCondition: "",
regMember: info.member_code
}
useEffect(() => {
let autoEmptyArray:autoRecodeArray[] = [...autoArray];
if(autoEmptyArray.length > 0){
props.questionUpdate.scalar_label?.label_info.map((ele, idx) => {
if(ele.value !== autoEmptyArray[idx]?.recodeValue){
autoEmptyArray.push({...defaultAuto, recodeValue: Number(ele.value)});
}
})
}else{
props.questionUpdate.scalar_label?.label_info.map((ele:labelInfoType, idx:number) => {
autoEmptyArray.push({...defaultAuto, recodeValue: Number(ele.value)});
})
}
if(props.questionUpdate.question_dimension !== 9){
autoEmptyArray = [];
}
setAutoArray(autoEmptyArray);
},[props.questionUpdate.question_dimension, props.questionUpdate.scalar_label?.label_info])
useEffect(() => {
let autoData = {
projectCode: project.prjcode,
questionUniqueKey:props.questionUpdate.question_unique_key
}
axios.post(URL_SEED+'/question/getAutoRecode', autoData, {
headers: {
'Authorization': `Bearer ${token.access}`,
}
}).then((response) => {
if(response.status === 200){
setAutoArray(response.data);
}
}).catch((error) => {
console.log("getAutoRecode :", error);
})
},[props.questionUpdate.question_unique_key])
//s단축키
useEffect(() => {
const handleKeySave = (e: { key: string; ctrlKey: boolean; preventDefault: () => void; }) => {
if(props.show && e.ctrlKey && e.key.toLowerCase() === "s"){
e.preventDefault();
autoSave();
}
}
window.addEventListener('keydown', handleKeySave);
return () => {
window.removeEventListener('keydown', handleKeySave);
};
},[props.show])
const autoValueChange = (e:React.ChangeEvent<HTMLInputElement>, value:number) => {
let copyArray:autoRecodeArray[] = [...autoArray];
if(copyArray.length > 0){
props.questionUpdate.scalar_label?.label_info.map((ele, idx) => {
if(ele.value !== copyArray[idx]?.recodeValue){
copyArray.push({...defaultAuto, recodeValue: Number(ele.value)});
}
})
}else{
props.questionUpdate.scalar_label?.label_info.map((ele, idx) => {
copyArray.push({...defaultAuto, recodeValue: Number(ele.value)});
})
}
copyArray.filter((ele) => {
if (ele.recodeValue === value) {
ele.recodeCondition = regexAuto(e.currentTarget.value);
}
});
if (props.questionUpdate.question_type === 41 && copyArray.length > 0) {
copyArray[0].recodeCondition = regexAuto(e.currentTarget.value);
}
setAutoArray(copyArray);
}
const autoSave = () => {
props.setAutoRecodeArray(autoArray);
alert("저장되었습니다.");
props.onHide();
}
return(
<div>
{ props.questionUpdate.question_dimension === 9 ?
<Modal show={props.show} size="lg" backdrop='static'>
<Modal.Header>
<Modal.Title className="text-center">
{
props.questionUpdate.auto_type === 1 ? "Auto Recode" : "Brand Recode"
}
</Modal.Title>
</Modal.Header>
<Modal.Body className="AutoRecodeForm" style={{maxHeight:"600px!important", height:"600px", overflowY:"auto",textAlign:"center"}} >
{
props.questionUpdate.scalar_label?.label_info.length === 0 && props.questionUpdate.question_type !== 41?
"보기를 입력해주세요."
:
props.questionUpdate.question_type === 41 ?
<div className="txt-list lbl-wrap">
<span className="tbe-pre">{"1"}</span>
<div className="txt-list txt-list-post">
<input
type="text"
style={{width:"100%"}}
value={autoArray[0]?.recodeCondition}
onChange={(e) => autoValueChange(e, Number(1))}
/>
</div>
</div>
:
props.questionUpdate.scalar_label?.label_info.map((ele, index) => (
<div key={index} className="txt-list lbl-wrap">
<span className="tbe-pre" style={{width: "20%"}}>{ele.label?.replace(/(<([^>]+)>)/ig, "")}</span>
<div className="txt-list txt-list-post">
<input
type="text"
style={{width:"100%"}}
value={autoArray[index]?.recodeCondition}
onChange={(e) => autoValueChange(e, Number(ele.value))}
/>
</div>
</div>
))
}
</Modal.Body>
<Modal.Footer>
<div className='mt-2 mr-1 float-right'>
<Button className='project-save-btn mr-2' variant="primary" onClick={autoSave}>저장</Button>
<Button variant="secondary" onClick={()=>{props.onHide()}}>닫기</Button>
</div>
</Modal.Footer>
</Modal>
:
null
}
</div>
)
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,60 @@
import React, { useEffect, useState } from "react"
import { Modal, Nav } from "react-bootstrap"
import { MoveQuestion } from "@componentsQuestionSetup/MoveQuestion";
import { DeleteQuestion } from "@componentsQuestionSetup/DeleteQuestion";
import { BlockQuestion } from "@componentsQuestionSetup/BlockQuestion";
import { CopyQuestion } from "@componentsQuestionSetup/CopyQuestion";
import { questionInfoType } from "@modules/TypeModule";
import { SetterOrUpdater } from "recoil";
export const QuestionManagement = (props:{
show: boolean,
questionInfo: questionInfoType[],
setDeleteFlag: SetterOrUpdater<boolean>,
setCopyFlag: SetterOrUpdater<boolean>,
setQuestionRefresh: SetterOrUpdater<number | null>,
onHide: () => void
}) => {
type ComponentMap = {
[key: number]: JSX.Element;
}
const [activeNav, setActiveNav] = useState(1);
const componentMap:ComponentMap = {
1: <MoveQuestion onHide={props.onHide} questionInfo={props.questionInfo} setQuestionRefresh={props.setQuestionRefresh}/>,
2: <DeleteQuestion onHide={props.onHide} setDeleteFlag={props.setDeleteFlag} questionInfo={props.questionInfo} setQuestionRefresh={props.setQuestionRefresh}/>,
3: <CopyQuestion onHide={props.onHide} setCopyFlag={props.setCopyFlag} questionInfo={props.questionInfo} setQuestionRefresh={props.setQuestionRefresh}/>,
4: <BlockQuestion onHide={props.onHide} setQuestionRefresh={props.setQuestionRefresh} questionInfo={props.questionInfo} />
};
useEffect(() => {
setActiveNav(1);
},[props.show])
return(
<Modal show={props.show} size="lg" backdrop='static'>
<Modal.Header>
<Modal.Title className="text-center">
문항 관리
</Modal.Title>
</Modal.Header>
<div className="d-inline-flex text-center border-bottom">
<Nav.Item className="w-25" style={{borderBottom: activeNav === 1 ? '2px solid #6C757D' : '0px solid black' }}>
<Nav.Link onClick={() => setActiveNav(1)}>순서 변경</Nav.Link>
</Nav.Item>
<Nav.Item className="w-25" style={{borderBottom: activeNav === 2 ? '2px solid #6C757D' : '0px solid black' }}>
<Nav.Link onClick={() => setActiveNav(2)}>일괄 / 선택 삭제</Nav.Link>
</Nav.Item>
<Nav.Item className="w-25" style={{borderBottom: activeNav === 3 ? '2px solid #6C757D' : '0px solid black' }}>
<Nav.Link onClick={() => setActiveNav(3)}>문항 복사</Nav.Link>
</Nav.Item>
<Nav.Item className="w-25" style={{borderBottom: activeNav === 4 ? '2px solid #6C757D' : '0px solid black' }}>
<Nav.Link onClick={() => setActiveNav(4)}>블록 설정</Nav.Link>
</Nav.Item>
</div>
{
componentMap[activeNav] || null
}
</Modal>
)
}

View File

@@ -0,0 +1,470 @@
import { useEffect, useRef } from "react";
import { SetterOrUpdater } from "recoil";
import { Button, Modal } from "react-bootstrap";
import { changeInequalitySign, changeLTGT } from "@modules/Function";
import type {questionInfoType} from "@modules/TypeModule";
import SunEditor from "suneditor-react";
import SunEditorCore from "suneditor/src/lib/core";
export const QuestionTitleModal = (props:{
titleOpen:boolean,
questionUpdate:questionInfoType,
setQuestionUpdate:SetterOrUpdater<questionInfoType>,
saveBtn: () => void,
closeBtn: () => void,
}) =>{
const editor = useRef<SunEditorCore>();
const getSunEditorInstance = (SunEditor: SunEditorCore) => {
editor.current = SunEditor
}
//테이블 있을 시 border 추가
const applyTableStyle = (htmlContent: string) => {
const parser = new DOMParser();
const doc = parser.parseFromString(htmlContent, 'text/html');
// 모든 테이블 요소 찾기
const tables = doc.querySelectorAll('table');
tables.forEach(table => {
// 테이블에 스타일 추가
(table as HTMLElement).style.border = 'solid 1px black';
// 모든 셀에도 동일한 스타일 적용
const cells = table.querySelectorAll('td, th');
cells.forEach(cell => {
(cell as HTMLElement).style.border = 'solid 1px black';
});
});
return doc.body.innerHTML;
}
return(
<Modal show={props.titleOpen} size="lg" backdrop='static'>
<Modal.Header>
<Modal.Title>
제목 입력
</Modal.Title>
</Modal.Header>
<Modal.Body>
{
props.titleOpen ?
<SunEditor
getSunEditorInstance={getSunEditorInstance}
setOptions={{
buttonList: [
["undo", "redo"],
// ['paragraphStyle', 'blockquote'],
[ "bold", "underline", "italic" ],
["fontColor", "hiliteColor"],
['lineHeight'],
// ['math'] //You must add the 'katex' library at options to use the 'math' plugin.
//['imageGallery'], // You must add the "imageGalleryUrl".
["table"],
["removeFormat"],
["align"],
["fontSize"]
// ['save', 'template'],
// '/', Line break
], // Or Array of button list, eg. [['font', 'align'], ['image']]
fontSize : [
8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 24, 36
],
minHeight: "300px",
showPathLabel: false,
callBackSave: props.saveBtn,
}}
lang={'ko'}
onChange={() => {
let tempQuestionUpdate = {...props.questionUpdate}
const updatedContent = editor.current?.getContents(false) || "";
const cleanContent = updatedContent.replace(/<!--.*?-->/gs, "").replace(/style="[^"]*margin-left:[^"]*"/gi, ""); // 메타데이터 제거
const styledContent = applyTableStyle(cleanContent);
tempQuestionUpdate.question_title = changeLTGT(styledContent);
props.setQuestionUpdate(tempQuestionUpdate)
}}
onKeyUp={() => {
let tempQuestionUpdate = {...props.questionUpdate}
const updatedContent = editor.current?.getContents(false) || "";
const cleanContent = updatedContent.replace(/<!--.*?-->/gs, "").replace(/style="[^"]*margin-left:[^"]*"/gi, ""); // 메타데이터 제거
const styledContent = applyTableStyle(cleanContent);
tempQuestionUpdate.question_title = changeLTGT(styledContent);
props.setQuestionUpdate(tempQuestionUpdate)
}}
setContents={ changeInequalitySign(String(props.questionUpdate.question_title)) }
autoFocus={true}
/>
: null
}
</Modal.Body>
<span className='explain ml-3 mb-1' style={{"marginTop":"-10px"}}>
이미지 태그 예시: {'{IMG|파일명|100px|100px}'}<br/>
PDF 태그 예시: {'{PDF|파일명|하이퍼링크 텍스트}'}<br/>
비디오 태그 예시: {'{VID|파일명 or 링크|100%|100%}'}
</span>
<Modal.Footer>
<Button className='project-save-btn' variant="primary" onClick={ props.saveBtn }>등록</Button>
<Button variant="secondary" onClick={props.closeBtn}>닫기</Button>
</Modal.Footer>
</Modal>
)
}
export const QuestionDescriptionModal = (props:{
descriptionOpen:boolean,
questionUpdate:questionInfoType,
setQuestionUpdate:SetterOrUpdater<questionInfoType>
saveBtn: () => void,
closeBtn: () => void,
})=>{
const editor = useRef<SunEditorCore>();
const getSunEditorInstance = (SunEditor: SunEditorCore) => {
editor.current = SunEditor
}
//테이블 있을 시 border 추가
const applyTableStyle = (htmlContent: string) => {
const parser = new DOMParser();
const doc = parser.parseFromString(htmlContent, 'text/html');
// 모든 테이블 요소 찾기
const tables = doc.querySelectorAll('table');
tables.forEach(table => {
// 테이블에 스타일 추가
(table as HTMLElement).style.border = 'solid 1px black';
// 모든 셀에도 동일한 스타일 적용
const cells = table.querySelectorAll('td, th');
cells.forEach(cell => {
(cell as HTMLElement).style.border = 'solid 1px black';
});
});
return doc.body.innerHTML;
}
return(
<Modal show={props.descriptionOpen} size="lg" backdrop='static'>
<Modal.Header>
<Modal.Title>
안내문 입력
</Modal.Title>
</Modal.Header>
<Modal.Body>
{
props.descriptionOpen ?
<SunEditor
getSunEditorInstance={getSunEditorInstance}
setOptions={{
buttonList: [
["undo", "redo"],
// ['paragraphStyle', 'blockquote'],
[ "bold", "underline", "italic" ],
["fontColor", "hiliteColor"],
// ['math'] //You must add the 'katex' library at options to use the 'math' plugin.
//['imageGallery'], // You must add the "imageGalleryUrl".
["table"],
["removeFormat"],
["align"],
["fontSize"]
// ['save', 'template'],
// '/', Line break
], // Or Array of button list, eg. [['font', 'align'], ['image']]
fontSize : [
8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 24, 36
],
minHeight: "300px",
showPathLabel: false,
callBackSave: props.saveBtn,
}}
lang={'ko'}
onChange={() => {
let tempQuestionUpdate = {...props.questionUpdate}
const updatedContent = editor.current?.getContents(false) || "";
const cleanContent = updatedContent.replace(/<!--.*?-->/gs, "").replace(/style="[^"]*margin-left:[^"]*"/gi, ""); // 메타데이터 제거
const styledContent = applyTableStyle(cleanContent);
tempQuestionUpdate.question_description = changeLTGT(styledContent);
props.setQuestionUpdate(tempQuestionUpdate)
}}
onKeyUp={() => {
let tempQuestionUpdate = {...props.questionUpdate}
const updatedContent = editor.current?.getContents(false) || "";
const cleanContent = updatedContent.replace(/<!--.*?-->/gs, "").replace(/style="[^"]*margin-left:[^"]*"/gi, ""); // 메타데이터 제거
const styledContent = applyTableStyle(cleanContent);
tempQuestionUpdate.question_description = changeLTGT(styledContent);
props.setQuestionUpdate(tempQuestionUpdate)
}}
setContents={ changeInequalitySign(String(props.questionUpdate.question_description)) }
autoFocus={true}
/>
: null
}
</Modal.Body>
<span className='explain ml-3 mb-1' style={{"marginTop":"-10px"}}>
이미지 태그 예시: {'{IMG|파일명|100px|100px}'}<br/>
PDF 태그 예시: {'{PDF|파일명|하이퍼링크 텍스트}'}<br/>
비디오 태그 예시: {'{VID|파일명 or 링크|100%|100%}'}
</span>
<Modal.Footer>
<Button className='project-save-btn' variant="primary" onClick={ props.saveBtn }>등록</Button>
<Button variant="secondary" onClick={props.closeBtn}>닫기</Button>
</Modal.Footer>
</Modal>
)
}
export const SetSurveyIndexModal = (props:{
indexOpen:boolean,
questionUpdate:questionInfoType,
setQuestionUpdate:SetterOrUpdater<questionInfoType>,
originQuestion:questionInfoType,
saveBtn: () => void,
closeBtn: () => void,
}) => {
const editor = useRef<SunEditorCore>();
const getSunEditorInstance = (SunEditor: SunEditorCore) => {
editor.current = SunEditor
}
//테이블 있을 시 border 추가
const applyTableStyle = (htmlContent: string) => {
const parser = new DOMParser();
const doc = parser.parseFromString(htmlContent, 'text/html');
// 모든 테이블 요소 찾기
const tables = doc.querySelectorAll('table');
tables.forEach(table => {
// 테이블에 스타일 추가
(table as HTMLElement).style.border = 'solid 1px black';
// 모든 셀에도 동일한 스타일 적용
const cells = table.querySelectorAll('td, th');
cells.forEach(cell => {
(cell as HTMLElement).style.border = 'solid 1px black';
});
});
return doc.body.innerHTML;
}
return (
<Modal show={props.indexOpen} size="lg" backdrop='static'>
<Modal.Header>
<Modal.Title>
안내문 입력
</Modal.Title>
</Modal.Header>
<Modal.Body>
{
props.indexOpen ?
<SunEditor
getSunEditorInstance={getSunEditorInstance}
setOptions={{
buttonList: [
["undo", "redo"],
// ['paragraphStyle', 'blockquote'],
[ "bold", "underline", "italic" ],
["fontColor", "hiliteColor"],
['lineHeight'],
// ['math'] //You must add the 'katex' library at options to use the 'math' plugin.
//['imageGallery'], // You must add the "imageGalleryUrl".
// ["fullScreen", "showBlocks", "codeView"],
["removeFormat"],
["align"],
["fontSize"],
["table"],
// ['save', 'template'],
// '/', Line break
], // Or Array of button list, eg. [['font', 'align'], ['image']]
fontSize : [
8, 10, 14, 18, 24, 36
],
minHeight: "300px",
showPathLabel: false,
callBackSave: props.saveBtn
}}
lang={'ko'}
onChange={() => {
let tempQuestionUpdate = {...props.questionUpdate}
const updatedContent = editor.current?.getContents(false) || "";
const cleanContent = updatedContent.replace(/<!--.*?-->/gs, "").replace(/style="[^"]*margin-left:[^"]*"/gi, ""); // 메타데이터 제거
const styledContent = applyTableStyle(cleanContent);
tempQuestionUpdate.question_title = changeLTGT(styledContent);
props.setQuestionUpdate(tempQuestionUpdate)
}}
onKeyUp={() => {
let tempQuestionUpdate = {...props.questionUpdate}
const updatedContent = editor.current?.getContents(false) || "";
const cleanContent = updatedContent.replace(/<!--.*?-->/gs, "").replace(/style="[^"]*margin-left:[^"]*"/gi, ""); // 메타데이터 제거
const styledContent = applyTableStyle(cleanContent);
tempQuestionUpdate.question_title = changeLTGT(styledContent);
props.setQuestionUpdate(tempQuestionUpdate)
}}
setContents={ changeInequalitySign(String(props.questionUpdate.question_title)) }
autoFocus={true}
/>
: null
}
</Modal.Body>
<span className='explain ml-3 mb-1' style={{"marginTop":"-10px"}}>
이미지 태그 예시: {'{IMG|파일명|100px|100px}'}<br/>
PDF 태그 예시: {'{PDF|파일명|하이퍼링크 텍스트}'}<br/>
비디오 태그 예시: {'{VID|파일명 or 링크|100%|100%}'}
</span>
<Modal.Footer>
<Button className='project-save-btn' variant="primary" onClick={ props.saveBtn }>등록</Button>
<Button variant="secondary" onClick={ props.closeBtn }>닫기</Button>
</Modal.Footer>
</Modal>
)
}
export const SetSurveyEndTitleModal = (props:{
question_name: string|null
titleOpen:boolean,
questionUpdate:questionInfoType,
setQuestionUpdate:SetterOrUpdater<questionInfoType>,
originQuestion:questionInfoType,
saveBtn: () => void,
closeBtn: () => void,
}) => {
const editor = useRef<SunEditorCore>();
const getSunEditorInstance = (SunEditor: SunEditorCore) => {
editor.current = SunEditor
}
return(
<Modal show={props.titleOpen} size="lg" backdrop='static'>
<Modal.Header>
<Modal.Title>
{props.question_name} 페이지 문구 입력
</Modal.Title>
</Modal.Header>
<Modal.Body>
{
props.titleOpen ?
<SunEditor
getSunEditorInstance={getSunEditorInstance}
setOptions={{
buttonList: [
["undo", "redo"],
["bold","underline","italic"],
["fontColor", "hiliteColor"],
["removeFormat"],
["align"],
["fontSize"]
],
fontSize : [
8, 10, 14, 18, 24, 36
],
minHeight: "300px",
showPathLabel: false,
defaultTag: "p",
callBackSave: props.saveBtn
}}
lang={'ko'}
onChange={(event) => {
let tempQuestionUpdate = {...props.questionUpdate}
const updatedContent = editor.current?.getContents(false) || "";
const cleanContent = updatedContent.replace(/<!--.*?-->/gs, "").replace(/style="[^"]*margin-left:[^"]*"/gi, ""); // 메타데이터 제거
tempQuestionUpdate.question_title = changeLTGT(cleanContent);
props.setQuestionUpdate(tempQuestionUpdate)
}}
onKeyUp={(event) => {
let tempQuestionUpdate = {...props.questionUpdate}
const updatedContent = editor.current?.getContents(false) || "";
const cleanContent = updatedContent.replace(/<!--.*?-->/gs, "").replace(/style="[^"]*margin-left:[^"]*"/gi, ""); // 메타데이터 제거
tempQuestionUpdate.question_title = changeLTGT(cleanContent);
props.setQuestionUpdate(tempQuestionUpdate)
}}
setContents={ changeInequalitySign(String(props.questionUpdate.question_title)) }
autoFocus={true}
/>
: null
}
</Modal.Body>
<span className='explain ml-3 mb-1' style={{"marginTop":"-10px"}}>
이미지 태그 예시: {'{IMG|파일명|100px|100px}'}<br/>
PDF 태그 예시: {'{PDF|파일명|하이퍼링크 텍스트}'}<br/>
비디오 태그 예시: {'{VID|파일명 or 링크|100%|100%}'}
</span>
<Modal.Footer>
<Button className='project-save-btn' variant="primary" onClick={ props.saveBtn }>등록</Button>
<Button variant="secondary" onClick={ props.closeBtn }>닫기</Button>
</Modal.Footer>
</Modal>
)
}
export const SetSurveyEndDescriptionModal = (props:{
descriptionOpen:boolean,
//changeDescription:string|null,
//setChangeDescription:SetterOrUpdater<string|null>,
question_name: string|null,
questionUpdate:questionInfoType,
setQuestionUpdate:SetterOrUpdater<questionInfoType>,
originQuestion:questionInfoType,
saveBtn: () => void,
closeBtn: () => void,
}) => {
const editor = useRef<SunEditorCore>();
const getSunEditorInstance = (SunEditor: SunEditorCore) => {
editor.current = SunEditor
}
return(
<Modal show={props.descriptionOpen} size="lg" backdrop='static'>
<Modal.Header>
<Modal.Title>
{props.question_name} 안내문 입력
</Modal.Title>
</Modal.Header>
<Modal.Body>
{
props.descriptionOpen ?
<SunEditor
getSunEditorInstance={getSunEditorInstance}
setOptions={{
buttonList: [
["undo", "redo"],
["bold","underline","italic"],
["fontColor", "hiliteColor"],
["removeFormat"],
["align"],
["fontSize"]
],
fontSize : [
8, 10, 14, 18, 24, 36
],
minHeight: "300px",
showPathLabel: false,
callBackSave: props.saveBtn
}}
lang={'ko'}
onChange={() => {
let tempQuestionUpdate = {...props.questionUpdate}
const updatedContent = editor.current?.getContents(false) || "";
const cleanContent = updatedContent.replace(/<!--.*?-->/gs, "").replace(/style="[^"]*margin-left:[^"]*"/gi, ""); // 메타데이터 제거
tempQuestionUpdate.question_description = changeLTGT(cleanContent);
props.setQuestionUpdate(tempQuestionUpdate)
}}
onKeyUp={() => {
let tempQuestionUpdate = {...props.questionUpdate}
const updatedContent = editor.current?.getContents(false) || "";
const cleanContent = updatedContent.replace(/<!--.*?-->/gs, "").replace(/style="[^"]*margin-left:[^"]*"/gi, ""); // 메타데이터 제거
tempQuestionUpdate.question_description = changeLTGT(cleanContent);
props.setQuestionUpdate(tempQuestionUpdate)
}}
setContents={ changeInequalitySign(String(props.questionUpdate.question_description)) }
autoFocus={true}
/>
: null
}
</Modal.Body>
<span className='explain ml-3 mb-1' style={{"marginTop":"-10px"}}>
이미지 태그 예시: {'{IMG|파일명|100px|100px}'}<br/>
PDF 태그 예시: {'{PDF|파일명|하이퍼링크 텍스트}'}<br/>
비디오 태그 예시: {'{VID|파일명 or 링크|100%|100%}'}
</span>
<Modal.Footer>
<Button className='project-save-btn' variant="primary" onClick={ props.saveBtn }>등록</Button>
<Button variant="secondary" onClick={ props.closeBtn }>닫기</Button>
</Modal.Footer>
</Modal>
)
}

View File

@@ -0,0 +1,185 @@
import { useState, useEffect, useCallback } from "react";
import { Button, Col, Modal, Row } from "react-bootstrap";
import type { logicType, questionInfoType } from "@modules/TypeModule";
import { DndProvider } from "react-dnd";
import { HTML5Backend } from "react-dnd-html5-backend";
import { LogicChild } from "@componentsQuestionSetup/LogicChild";
import axios from "axios";
import { URL_SEED } from "@modules/AxiosModule";
import { useRecoilState, useRecoilValue } from "recoil";
import { loginToken, projectInfo } from "@token/Token";
export const TotalLogicModal = (props:{
skey: string,
show :boolean,
onHide: () => void,
questionInfo: questionInfoType[],
}) => {
const [filterInfo, setFilterInfo] = useState<questionInfoType[]>([]);
const [deleteQuestionArray, setDeleteQuestionArray] = useState<number[]>([]);
const [allSelected, setAllSelected] = useState(false);
const [totalLogicArray, setTotalLogicArray] = useState<{ uk: number; before: any; after: any; }[]>([]);
const projectState = useRecoilValue(projectInfo);
const [token, setToken] = useRecoilState(loginToken);
const [beforeLogicArray, setBeforeLogicArray] = useState<logicType[]>([]);
const [afterLogicArray, setAfterLogicArray] = useState<logicType[]>([]);
const addTotalLogicBtn = () => {
// setTotalLogicArray([...totalLogicArray, {"logic":"","page":""}]);
}
const deleteQuestionClick = (uk:number) => {
setDeleteQuestionArray(prevUniqueKey => {
if (prevUniqueKey.includes(uk)) {
// 이미 활성화된 row를 클릭한 경우, 해당 ID를 제거
return prevUniqueKey.filter(questionUK => questionUK !== uk);
} else {
// 새로운 row를 활성화하는 경우, 해당 ID를 추가
return [...prevUniqueKey, uk];
}
});
}
//전체 선택
const allCheck = () => {
if (!allSelected) {
const newDeleteQuestionArray = filterInfo.map(ele => ele.question_unique_key);
setDeleteQuestionArray(newDeleteQuestionArray);
} else {
setDeleteQuestionArray([]);
}
setAllSelected(!allSelected);
}
//문항리스트
const infoFilterArray = () => {
const infoFilter = props.questionInfo.filter((ele) => ele.question_order > 0).sort((a, b) => a.question_order - b.question_order);
setFilterInfo(infoFilter);
}
// const renderTotalLogicChild = useCallback((logicData:logicType, logicArray:logicType[], questionInfo:questionInfoType[], eleIndex:number, questionUK:number) => {
// return (
// <LogicChild
// key={eleIndex}
// logicGroup={"total"}
// logicData={logicData}
// questionInfo={questionInfo}
// eleIndex={eleIndex}
// logicArray = {logicArray}
// questionUK={questionUK}
// setLogicArray = {setTotalLogicArray}
// moveLogicChild = {moveBeforeLogicChild}
// />
// )
// }, []);
const logicListShow = () => {
deleteQuestionArray.map((ele, idx) => {
axios.get(URL_SEED + '/question/getQuestionLogic', {
params: {
project_code: projectState.prjcode,
question_unique_key: ele
},
headers: {
'Authorization': `Bearer ${token.access}`,
}
}).then((response) => {
if (response.status === 200) {
const newLogic = {
uk: ele,
before: response.data.before_logic || [],
after: response.data.after_logic || []
};
setTotalLogicArray(prevArray => [...prevArray, newLogic]);
if (response.data.before_logic !== null) {
setBeforeLogicArray(response.data.before_logic);
} else {
setBeforeLogicArray([]);
}
if (response.data.after_logic !== null) {
setAfterLogicArray(response.data.after_logic);
} else {
setAfterLogicArray([]);
}
}
}).catch(error => {
console.log("getQuestionLogic", error);
});
});
};
useEffect(() => {
infoFilterArray();
},[props.questionInfo])
useEffect(() => {
logicListShow();
},[deleteQuestionArray])
return(
<Modal show={props.show} size="lg" backdrop='static'>
<Modal.Header>
<Modal.Title className="text-center">
전체 로직
</Modal.Title>
</Modal.Header>
<Modal.Body className="logicForm" style={{maxHeight:"600px!important", height:"600px", paddingTop:"0px", paddingBottom:"0px"}}>
<Row>
<Col md={3} style={{ overflowY:"auto", height:"600px", background:"#F3F4F5", paddingTop:"10px", borderRight:"1px solid #DEE2E6"}}>
<div className="custom-chk all-chcek mb-3">
<input type="checkbox" id="chk-all" checked={ allSelected } onChange={allCheck}/>
<label htmlFor="chk-all">전체 선택</label>
</div>
{
filterInfo.map((ele, index) => {
return(
<div key={ele.question_unique_key} className='d-flex list-item justify-content-center management'>
<div className="custom-chk">
<input type="checkbox" id={"chkDelete_" + ele.question_unique_key} value={ele.question_unique_key} onChange={() => deleteQuestionClick(ele.question_unique_key)} checked={deleteQuestionArray.includes(ele.question_unique_key)} />
<label htmlFor={"chkDelete_" + ele.question_unique_key} onChange={() => deleteQuestionClick(ele.question_unique_key)} />
</div>
<label className="w-100" htmlFor={"chkDelete_" + ele.question_unique_key} onChange={() => deleteQuestionClick(ele.question_unique_key)}>
<div className="file-li border mb-1" id={"chkDelete_" + ele.question_unique_key}
style={{
cursor: "pointer",
backgroundColor: deleteQuestionArray.includes(ele.question_unique_key) ? "#B1DFBC" : "white"
}}
>
{ele.question_id}
</div>
</label>
</div>
)
})
}
</Col>
<Col style={{paddingTop:"10px"}}>
{/* <div style={{height:"50%", }}>
<div>
<Button onClick={ addTotalLogicBtn }>전체 로직추가</Button>
</div>
<DndProvider backend={HTML5Backend}>
<div style={{overflowY:"auto", maxHeight:"75%", height:"75%"}}>
{
// totalLogicArray?.map((ele, index) => renderTotalLogicChild( ele, totalLogicArray, props.questionInfo, index, props.questionUniqueKey))
}
</div>
</DndProvider>
</div> */}
</Col>
</Row>
</Modal.Body>
<Modal.Footer>
<div className='mt-2 mr-1 float-right'>
<Button className='project-save-btn mr-2' variant="primary" >저장</Button>
<Button variant="secondary" onClick={()=>{props.onHide()}}>닫기</Button>
</div>
</Modal.Footer>
</Modal>
)
}