Browse Source

update dialogHierarchy

pull/2/head
farhan048 2 years ago
parent
commit
4767cdbdc8
  1. 42
      src/views/SimproV2/CreatedProyek/DIalogHierarchy.js

42
src/views/SimproV2/CreatedProyek/DIalogHierarchy.js

@ -11,6 +11,7 @@ import { NotificationContainer, NotificationManager } from 'react-notifications'
import DialogUserGantt from './DialogUserGantt'; import DialogUserGantt from './DialogUserGantt';
import DialogForm from './DIalogFormHierarchy' import DialogForm from './DIalogFormHierarchy'
import DialogFormGantt from './DialogFormGantt'; import DialogFormGantt from './DialogFormGantt';
import DialogGantt from './DialogGantt';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { async } from '@dabeng/react-orgchart'; import { async } from '@dabeng/react-orgchart';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
@ -29,6 +30,7 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
const [dataGantt, setDataGantt] = useState([]) const [dataGantt, setDataGantt] = useState([])
const [typeDialog, setTypeDialog] = useState("add") const [typeDialog, setTypeDialog] = useState("add")
const [openDialogForm, setOpenDialogForm] = useState(false) const [openDialogForm, setOpenDialogForm] = useState(false)
const [openDialogGantt, setOpenDialogGantt] = useState(false)
const [openDialogFormGantt, setOpenDialogFormGantt] = useState(false) const [openDialogFormGantt, setOpenDialogFormGantt] = useState(false)
const [openDialogUserGantt, setOpenDialogUserGantt] = useState(false) const [openDialogUserGantt, setOpenDialogUserGantt] = useState(false)
const [dataHierarchy, setDataHierarchy] = useState([]) const [dataHierarchy, setDataHierarchy] = useState([])
@ -41,7 +43,7 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
if (idTask > 0) { if (idTask > 0) {
getdataHierarchy(); getdataHierarchy();
} }
}, [idTask, openDialog, closeDialog]) }, [saveHierarchy, idTask, openDialog, closeDialog])
useEffect(() => { useEffect(() => {
getDataHumanResource(); getDataHumanResource();
@ -96,6 +98,11 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
setOpenDialogFormGantt(true) setOpenDialogFormGantt(true)
} }
const handleViewGant = (id) => {
setParentId(id)
setOpenDialogGantt(true)
}
const toggleDialogFormGantt = () => { const toggleDialogFormGantt = () => {
setOpenDialogFormGantt(!openDialogFormGantt) setOpenDialogFormGantt(!openDialogFormGantt)
} }
@ -138,11 +145,6 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
const getdataHierarchy = async () => { const getdataHierarchy = async () => {
const payload = {
"columns": [{ "name": "project_id", "logic_operator": "=", "value": idTask, "operator": "AND" }],
"joins": [{ "name": "m_version_gantt", "column_join": "hierarchy_ftth_id", "column_results": "progress" }],
}
const url = HIERARCHY_FTTH_TREE(idTask) const url = HIERARCHY_FTTH_TREE(idTask)
const result = await axios const result = await axios
.get(url, HEADER) .get(url, HEADER)
@ -186,9 +188,12 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
<Tooltip title="Tambah Data"> <Tooltip title="Tambah Data">
<Button size={"sm"} color='success' onClick={() => handleAddWithParent(text.id)}><i className="fa fa-plus"></i></Button> <Button size={"sm"} color='success' onClick={() => handleAddWithParent(text.id)}><i className="fa fa-plus"></i></Button>
</Tooltip>{" "} </Tooltip>{" "}
<Tooltip title="Gantt"> <Tooltip title="Tambah Gantt">
<Button size={"sm"} color='primary' onClick={() => handleAddGant(text.id)}><i className="fa fa-gears"></i></Button> <Button size={"sm"} color='primary' onClick={() => handleAddGant(text.id)}><i className="fa fa-gears"></i></Button>
</Tooltip> </Tooltip>{" "}
{text.dataGantt && (<Tooltip title="Detail Gantt">
<Button size={"sm"} color='info' onClick={() => handleViewGant(text.id)}><i className="fa fa-info"></i></Button>
</Tooltip>)}
</> </>
, ,
}, },
@ -204,21 +209,6 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
<Table <Table
size="small" size="small"
columns={[Table.EXPAND_COLUMN, ...columns]} columns={[Table.EXPAND_COLUMN, ...columns]}
expandable={{
expandedRowRender: (record) => {
if (Array.isArray(record.dataGantt)) {
return record.dataGantt.map((data) => (
<Link to={`/projects/${data.id}/${idTask}/gantt`}>
<Space align="center">
<p style={{ marginLeft: 15, width: "100%" }}>{data.name_version}</p>
</Space>
</Link>
));
} else {
return null; // or some default content if dataGantt is not an array
}
},
}}
rowKey="id" rowKey="id"
dataSource={dataHierarchy} dataSource={dataHierarchy}
pagination={{ position: ["bottomLeft"] }} pagination={{ position: ["bottomLeft"] }}
@ -312,7 +302,11 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
> >
Delete this data Delete this data
</SweetAlert> </SweetAlert>
<DialogGantt
openDialog={openDialogGantt}
hierarchyId={parentId}
idTask={idTask}
/>
<DialogFormGantt <DialogFormGantt
idTask={idTask} idTask={idTask}
openDialog={openDialogFormGantt} openDialog={openDialogFormGantt}

Loading…
Cancel
Save