Commit 170864fe authored by d.arizona's avatar d.arizona

update

parent 70b55e0b
......@@ -78,6 +78,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
//Menu
const getMenu = () => api.get('menu/get_menu_hierarki')
const getMenuByRole = () => api.get('menu/get_menu_hierarki_by_role')
//UNIT BISNIS
const getUnitBisnis = () => api.get('business_unit/get_all_business_unit')
......@@ -120,6 +121,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
const getReportType = () => api.get('report/get_all_report')
const searchReportItems = (body) => api.post('/item_report/search_item_report', body)
const createReportItems = (body) => api.post('/item_report/create_item_report', body)
const getItemReportHierarki = () => api.get('item_report/get_item_report_hierarki')
//PARAMETER
const getAllParameter = () => api.get('/setting/get_all_setting')
......@@ -200,7 +202,9 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
getPerusahaanActive,
getRoleActive,
checkUploadParameter,
uploadParameter
uploadParameter,
getItemReportHierarki,
getMenuByRole
}
}
......
......@@ -126,13 +126,174 @@ export default function MiniDrawer() {
const [selectedSubIndex, setSelectSub] = React.useState([]);
const [userFullname, setUserFullname] = React.useState("")
const [userEmail, setUserEmail] = React.useState("")
const [data, setData] = React.useState({
array: [
{
img: Images.Home,
label: 'Home',
path: 'beranda',
subItem: null,
collapse: false,
},
{
img: Images.budgetTahunan,
label: 'Master Budget & CAT',
path: 'budget-tahunan',
subItem: null,
collapse: false,
},
{
img: Images.laporanBulanan,
label: 'Monthly Report',
path: 'beranda',
subItem: null,
collapse: false,
},
{
img: Images.rolling,
label: 'Rolling Outlook & CAT Revision',
path: 'beranda',
subItem: null,
collapse: false,
},
{
img: Images.outlookperformance,
label: 'Outlook Performance Appraisal',
path: 'beranda',
subItem: null,
collapse: false,
},
{
img: Images.operatingindicator,
label: 'Operating Indicator',
path: 'beranda',
subItem: null,
collapse: false,
},
{
img: Images.manajemenDokumen,
label: 'Document Management',
path: 'beranda',
subItem: null,
collapse: false,
},
{
img: Images.laporan,
label: 'Reports',
path: '',
subItem: [
{
img: 'beranda',
label: 'CAT Dashboard',
path: 'dashboard-cat',
},
{
img: 'beranda',
label: 'Summary of Triputra Group',
path: 'beranda',
},
{
img: '',
label: 'Sub Holding',
path: 'beranda',
}
],
collapse: false,
},
{
img: '',
label: 'Settings',
path: 'beranda',
subItem: null,
collapse: false,
},
{
img: Images.masterdata,
label: 'Master Data',
path: '',
subItem: [
{
img: '',
label: 'Business Unit',
path: 'unit-bisnis',
},
{
img: '',
label: 'Company',
path: 'perusahaan',
},
{
img: '',
label: 'Report Items',
path: 'report-items',
},
{
img: '',
label: 'Parameters',
path: 'parameter',
},
],
collapse: false,
},
{
img: Images.otorisasi,
label: 'Authorization',
path: '',
subItem: [
{
img: '',
label: 'User Role',
path: 'userrole',
},
{
img: '',
label: 'User',
path: 'user',
}
],
collapse: false,
},
{
img: Images.approvalmatrix,
label: 'Approval Matrix',
path: 'approval-matrix',
subItem: null,
collapse: false,
},
{
img: Images.otorisasi,
label: 'User Management',
path: '',
subItem: [
{
img: '',
label: 'Profile',
path: 'profile',
},
{
img: '',
label: 'Logout',
path: '',
},
],
collapse: false,
}
]
})
React.useEffect(() => {
if(userFullname == "" && userEmail == "") {
getUserData()
getMenuHierarki()
}
})
const getMenuHierarki = () => {
api.create().getMenuByRole().then((response) => {
console.log(response.data.data)
})
}
const getUserData = () => {
let userId = localStorage.getItem(Constant.USER)
api.create().getDetailUser(userId).then((response) => {
......@@ -176,6 +337,13 @@ export default function MiniDrawer() {
const { height, width } = UseWindowDimensions();
function handleCollapse(item){
let arr = data.array
let index = arr.findIndex((val) => val.label === item.label)
arr[index].collapse = !arr[index].collapse
setData({...data, array: arr})
}
return (
<div className={classes.root}>
<CssBaseline />
......@@ -250,15 +418,15 @@ export default function MiniDrawer() {
</div>
}
<List>
{ArraySide.map((item, index) => (
{data.array.map((item, index) => (
<div style={{ marginTop: index === 0 ? null : 5 }} >
{item.subItem != null ?
<div style={{ justifyContent: 'space-between', flexDirection: 'row', display: 'flex', paddingLeft: 5, paddingRight: 10 }} onClick={() => selectedIndexs == null ? setSelectedIndexs(item.label) : setSelectedIndexs(null)}>
<div style={{ justifyContent: 'space-between', flexDirection: 'row', display: 'flex', paddingLeft: 5, paddingRight: 10 }} onClick={() => {handleCollapse(item)}}>
<ListItem key={item.label}>
<ListItemIcon style={{ minWidth: open ? 40 : 56 }}><img src={item.img} /></ListItemIcon>
<Typography style={{ fontFamily: 'nunito', color: '#525355', fontSize: 14 }}>{item.label}</Typography>
</ListItem>
{item.subItem != null ? (item.label === selectedIndex ? <ExpandLess style={{ color: "#525355", marginLeft: 50, alignSelf: 'center' }} /> : <ExpandMore style={{ color: "#525355", marginLeft: 50, alignSelf: 'center' }} />) : null}
{item.subItem != null ? (item.collapse? <ExpandLess style={{ color: "#525355", marginLeft: 50, alignSelf: 'center' }} /> : <ExpandMore style={{ color: "#525355", marginLeft: 50, alignSelf: 'center' }} />) : null}
</div>
:
item.label === 'Settings' ?
......@@ -280,7 +448,7 @@ export default function MiniDrawer() {
}
{item.subItem != null &&
<div>
<Collapse in={item.label === selectedIndexs} timeout="auto" unmountOnExit>
<Collapse in={item.collapse} timeout="auto" unmountOnExit>
<List component="div" disablePadding>
{item.subItem.map((sub, indexs) => {
return (
......
......@@ -5,6 +5,7 @@ import MinimizeIcon from '@material-ui/icons/Minimize';
import AddIcon from '@material-ui/icons/Add';
import RemoveIcon from '@material-ui/icons/Remove';
import Nestable from 'react-nestable';
import api from '../../../api';
const useStyles = makeStyles((theme) => ({
root: {
......@@ -50,24 +51,24 @@ export default class VisualReportItems extends Component {
this.state = {
open: false,
items: [
{ id: 0, text: 'Accumulated Depreciation (negative value)', collapse: false,
{ id: 0, GG: 'Accumulated Depreciation (negative value)', collapse: false,
children: [
{ id: 3, text: 'Beginning Balance', collapse: false },
{ id: 4, text: 'Depreciation expense MTD (please fill in, if any)', collapse: false },
{ id: 5, text: 'Depreciation expense MTD (please fill in, if any)', collapse: false }
{ id: 3, GG: 'Beginning Balance', collapse: false },
{ id: 4, GG: 'Depreciation expense MTD (please fill in, if any)', collapse: false },
{ id: 5, GG: 'Depreciation expense MTD (please fill in, if any)', collapse: false }
]
},{
id: 1, text: 'Control Gain/(Loss) on Fixed Assets', collapse: false
id: 1, GG: 'Control Gain/(Loss) on Fixed Assets', collapse: false
},{
id: 2, text: 'Gain/(Loss) on Fixed Assets', collapse: false,
id: 2, GG: 'Gain/(Loss) on Fixed Assets', collapse: false,
children: [
{ id: 6, text: 'NBV', collapse: false,
{ id: 6, GG: 'NBV', collapse: false,
children : [
{ id: 8, text: 'Cost', collapse: false },
{ id: 9, text: 'Accm. Depreciation', collapse: false },
{ id: 8, GG: 'Cost', collapse: false },
{ id: 9, GG: 'Accm. Depreciation', collapse: false },
]
},
{ id: 7, text: 'Proceed from sale or disposal of Fixed Assets (please fill in, if any)', collapse: false },
{ id: 7, GG: 'Proceed from sale or disposal of Fixed Assets (please fill in, if any)', collapse: false },
]
},
],
......@@ -78,6 +79,15 @@ export default class VisualReportItems extends Component {
componentDidMount() {
console.log(this.props.height)
this.getItemHierarki()
}
getItemHierarki() {
api.create().getItemReportHierarki().then((response) => {
if (response.data.status == 'success') {
this.setState({items : response.data.data})
}
})
}
handleCollapse(item) {
......@@ -114,11 +124,13 @@ export default class VisualReportItems extends Component {
return (
<div>
{collapseIcon ? (this.state.arrayCollapse.includes(item.id)? <AddIcon/> : <RemoveIcon/>) : null}
<button type="button" onClick={() => this.collapse(item.id)}>{item.text}</button>
<button type="button" onClick={() => this.collapse(item.id)}>{item.report_name}</button>
</div>
)
};
render() {
return (
......
......@@ -182,8 +182,15 @@ export default class EditUser extends Component {
getPerusahaan() {
api.create().getPerusahaanHierarki().then((response) => {
if (response.data.status === 'success') {
this.setState({ listCompany: response.data.data })
console.log(response.data.data)
let listCompany = response.data.data.map((item,index) => {
return {
...item,
index,
collapse: false
}
})
this.setState({ listCompany }, () => console.log(listCompany))
// console.log(response.data.data)
}
})
}
......@@ -216,7 +223,7 @@ export default class EditUser extends Component {
{item.child.map((data, index) => {
return (
<li>
{/* <Collapse timeout="auto" unmountOnExit in={data.company_id === this.state.selectedIndex}> */}
<Collapse timeout="auto" unmountOnExit in={item.collapse}>
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start', paddingLeft: R.isNil(data.child) ? (padding + 20) : padding }}>
{!R.isNil(data.child) && <span onClick={() => this.setState({ selectedIndex: data.company_id === this.state.selectedIndex ? 0 : data.company_id })} style={{ marginLeft: 7, marginRight: 2 }}>
{data.company_id === this.state.selectedIndex ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
......@@ -230,7 +237,7 @@ export default class EditUser extends Component {
<Typography style={{ fontSize: 12 }}>{titleCase(data.company_name)}</Typography>
</div>
{!R.isNil(data.child) && this.renderChildren(data, padding + 20)}
{/* </Collapse> */}
</Collapse>
</li>
)
})}
......@@ -262,6 +269,35 @@ export default class EditUser extends Component {
})
)
}
handleCollapse(item, index) {
let result = this.findIndexNested(this.state.listCompany, index);
console.log("Found index " + index + " via these child indexes: " + result);
}
// handleCollapseChildren(item,index) {
// let listCompany = this.state.listCompany[index]
// let index = listCompany.findIndex((val) => val.company_id === item.company_id)
// if (index == -1 ) {
// item.child.map((item,index) => this.handleCollapseChildren(item,index))
// } else {
// listCompany[index].collapse = !listCompany[index].collapse
// }
// }
findIndexNested(data, index) {
if (data.index === index) return [];
let result;
const i = (data.children || []).findIndex(child => {
return result = this.findIndexNested(child, index)
});
if (result) return [i, ...result];
}
findByPath(data, path) {
for (let i of path) data = data.children[i];
return data
}
render() {
return (
<div className="test app-popup-show">
......@@ -451,7 +487,7 @@ export default class EditUser extends Component {
<ul>
<li>
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start' }}>
{item.child.length > 0 && <span onClick={() => this.setState({ selectedIndex: index === this.state.selectedIndex ? 0 : index })} style={{ marginLeft: 7, marginRight: 2 }}>
{item.child.length > 0 && <span onClick={() => this.handleCollapse(item, index)} style={{ marginLeft: 7, marginRight: 2 }}>
{index === this.state.selectedIndex ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
</span>}
<span>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment