-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #669 from culturecreates/develop
Develop
- Loading branch information
Showing
62 changed files
with
2,799 additions
and
565 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { LeftOutlined } from '@ant-design/icons'; | ||
import { Button } from 'antd'; | ||
import { useTranslation } from 'react-i18next'; | ||
import './breadCrumbButton.css'; | ||
|
||
const BreadCrumbButton = () => { | ||
const navigate = useNavigate(); | ||
const { t } = useTranslation(); | ||
return ( | ||
<div className="breadcrumb-btn-container"> | ||
<Button type="link" onClick={() => navigate(-1)} icon={<LeftOutlined style={{ marginRight: '17px' }} />}> | ||
{t('dashboard.organization.createNew.search.breadcrumb')} | ||
</Button> | ||
</div> | ||
); | ||
}; | ||
|
||
export default BreadCrumbButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.breadcrumb-btn-container .ant-btn { | ||
color: #0f0e98; | ||
border: none; | ||
box-shadow: none; | ||
background: transparent; | ||
padding: 0; | ||
font-weight: 600; | ||
width: fit-content; | ||
cursor: pointer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './BreadCrumbButton'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import { Form, Tree, Modal } from 'antd'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
const formatTreeData = (data, language) => { | ||
const formattedData = []; | ||
|
||
const traverse = (node, parentKey) => { | ||
const key = parentKey ? `${parentKey}-${node.id}` : `${node.id}`; | ||
|
||
const formattedNode = { | ||
key, | ||
title: node.name[language], | ||
}; | ||
|
||
if (node.children && node.children.length > 0) { | ||
formattedNode.children = node.children.map((child) => traverse(child, key)); | ||
} | ||
|
||
return formattedNode; | ||
}; | ||
|
||
data?.concepts?.forEach((node) => { | ||
formattedData.push(traverse(node)); | ||
}); | ||
|
||
return formattedData; | ||
}; | ||
|
||
const DraggableTree = ({ data }) => { | ||
const [engGData, setEngGData] = useState(formatTreeData(data, 'en')); | ||
const [frenchGData, setFrenchGData] = useState(formatTreeData(data, 'fr')); | ||
const [expandedKeys] = useState(['0-0', '0-0-0', '0-0-0-0']); | ||
const [modalVisible, setModalVisible] = useState(false); | ||
const [selectedNode, setSelectedNode] = useState(null); | ||
const { t } = useTranslation(); | ||
|
||
const updateTreeData = (dragKey, dropKey, dropPos, language) => { | ||
const updateData = (treeData) => { | ||
const dragIndex = treeData.findIndex((item) => item.key === dragKey); | ||
const dropIndex = treeData.findIndex((item) => item.key === dropKey); | ||
|
||
if (dragIndex !== -1 && dropIndex !== -1) { | ||
const [draggedItem] = treeData.splice(dragIndex, 1); | ||
treeData.splice(dropPos === -1 ? dropIndex : dropIndex + 1, 0, draggedItem); | ||
} | ||
|
||
return treeData; | ||
}; | ||
|
||
if (language === 'en') { | ||
setEngGData((prevData) => updateData([...prevData])); | ||
} else if (language === 'fr') { | ||
setFrenchGData((prevData) => updateData([...prevData])); | ||
} | ||
}; | ||
|
||
const onDragEnter = (info) => { | ||
console.log(info); | ||
}; | ||
|
||
const onDrop = (info) => { | ||
const dropKey = info.node.key; | ||
const dragKey = info.dragNode.key; | ||
const dropPos = info.dropPosition; | ||
|
||
if (dragKey.split('-').slice(0, -1).join('-') !== dropKey.split('-').slice(0, -1).join('-')) { | ||
const parentKey = dropKey.split('-').slice(0, -1).join('-'); | ||
updateTreeData(dragKey, parentKey, 1, 'en'); | ||
updateTreeData(dragKey, parentKey, 1, 'fr'); | ||
return; | ||
} | ||
|
||
updateTreeData(dragKey, dropKey, dropPos, 'en'); | ||
updateTreeData(dragKey, dropKey, dropPos, 'fr'); | ||
}; | ||
|
||
const handleClick = (node) => { | ||
setSelectedNode(node); | ||
setModalVisible(true); | ||
}; | ||
|
||
const handleModalClose = () => { | ||
setModalVisible(false); | ||
}; | ||
|
||
useEffect(() => { | ||
setEngGData(formatTreeData(data, 'en')); | ||
setFrenchGData(formatTreeData(data, 'fr')); | ||
}, [data]); | ||
|
||
return ( | ||
<> | ||
<Form.Item style={{ width: '50%' }}> | ||
<span className="tag-header">{t('dashboard.taxonomy.addNew.concepts.english')}</span> | ||
<Tree | ||
className="draggable-tree" | ||
defaultExpandedKeys={expandedKeys} | ||
draggable | ||
blockNode | ||
onDragEnter={onDragEnter} | ||
onDrop={onDrop} | ||
treeData={engGData} | ||
onSelect={(selectedKeys, { node }) => handleClick(node)} | ||
/> | ||
</Form.Item> | ||
<Form.Item style={{ width: '50%' }}> | ||
<span className="tag-header">{t('dashboard.taxonomy.addNew.concepts.french')}</span> | ||
<Tree | ||
className="draggable-tree" | ||
defaultExpandedKeys={expandedKeys} | ||
draggable | ||
blockNode | ||
onDragEnter={onDragEnter} | ||
onDrop={onDrop} | ||
treeData={frenchGData} | ||
onSelect={(selectedKeys, { node }) => handleClick(node)} | ||
/> | ||
</Form.Item> | ||
<Modal title="Node Details" open={modalVisible} onCancel={handleModalClose} footer={null}> | ||
{selectedNode && ( | ||
<> | ||
<p>{`Key: ${selectedNode.key}`}</p> | ||
<p>{`Title: ${selectedNode.title}`}</p> | ||
</> | ||
)} | ||
</Modal> | ||
</> | ||
); | ||
}; | ||
|
||
export default DraggableTree; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './DraggableTree'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.