Commit 288c02dc authored by d.arizona's avatar d.arizona

update

parent d1f8736f
......@@ -126,6 +126,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
const checkUploadReportItems = (body) => api.post('/item_report/check_import', body)
const uploadReportItems = (body) => api.post('/item_report/import_item_report', body)
const getItemReportHierarki = () => api.get('item_report/get_item_report_hierarki')
const saveVisualisasiReport = (body) => api.post('item_report/save_visualization', body)
//PARAMETER
const getAllParameter = () => api.get('/setting/get_all_setting')
......@@ -212,7 +213,8 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
checkUploadParameter,
uploadParameter,
getItemReportHierarki,
getMenuByRole
getMenuByRole,
saveVisualisasiReport
}
}
......
......@@ -8,6 +8,7 @@ import TreeView from '@material-ui/lab/TreeView';
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
import ChevronRightIcon from '@material-ui/icons/ChevronRight';
import TreeItem from '@material-ui/lab/TreeItem';
import Nestable from 'react-nestable/dist/Nestable';
......@@ -34,7 +35,15 @@ export default class VisualPerusahaan extends Component {
</div>
<div style={{ padding: 25, width: '100%' }}>
<div style={{ width: '100%', padding: 25, backgroundColor: 'white', borderRadius: 6, border: 'solid 1px #c4c4c4'}}>
<TreeView
<Nestable
items={this.state.items}
collapsed={this.state.defaultCollapsed}
renderItem={this.renderItem}
ref={el => this.refNestable = el}
onChange={(e) => this.setState({items: e}, () => console.log(JSON.stringify(e)))}
/>
{/* <TreeView
defaultCollapseIcon={<ExpandMoreIcon />}
defaultExpandIcon={<ChevronRightIcon />}
>
......@@ -68,7 +77,7 @@ export default class VisualPerusahaan extends Component {
</TreeItem>
</TreeItem>
</TreeItem>
</TreeView>
</TreeView> */}
</div>
</div>
<div className="row" style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 15, paddingLeft: 15, paddingBottom: 25 }}>
......
......@@ -177,7 +177,7 @@ export default class EditReportItems extends Component {
};
let index = inputData.findIndex((val) => val.type_report_id === this.state.tempData.type_report_id)
this.setState({listInputType: defaultProps, InputType: index === -1 ? inputData[0] : inputData[index]})
this.setState({listInputType: defaultProps, InputType: index === -1 ? null : inputData[index]})
} else {
alert(response.data.message)
}
......@@ -201,7 +201,7 @@ export default class EditReportItems extends Component {
};
let index = companyData.findIndex((val) => val.company_id === this.state.tempData.company_id)
this.setState({listCompany: defaultProps, company: index === -1 ? companyData[0] : companyData[index]})
this.setState({listCompany: defaultProps, company: index === -1 ? null : companyData[index]})
} else {
alert(response.data.message)
}
......@@ -225,7 +225,7 @@ export default class EditReportItems extends Component {
};
let index = reportTypeData.findIndex((val) => val.report_id === this.state.tempData.report_id)
this.setState({listReportType: defaultProps, reportType: index === -1 ? reportTypeData[0] : reportTypeData[index]})
this.setState({listReportType: defaultProps, reportType: index === -1 ? null: reportTypeData[index]})
} else {
alert(response.data.message)
}
......@@ -249,7 +249,7 @@ export default class EditReportItems extends Component {
};
let index = parentData.findIndex((val) => val.item_report_id === this.state.tempData.item_report_id)
this.setState({listParent: defaultProps, parent: index === -1 ? parentData[0] : parentData[index]})
this.setState({listParent: defaultProps, parent: index === -1 ? null : parentData[index]})
} else {
alert(response.data.message)
}
......@@ -335,7 +335,8 @@ export default class EditReportItems extends Component {
style={{ width: '100%' }}
id="description"
label="Deskripsi"
onChange={(e) => null}
name="description"
onChange={(e) => this.handleChange(e, '')}
value={this.state.tempData === null ? '' : this.state.tempData.description}
inputProps={{
style: {
......@@ -360,7 +361,8 @@ export default class EditReportItems extends Component {
style={{ width: '100%' }}
id="uom"
label="UOM"
onChange={(e) => null}
name="uom"
onChange={(e) => this.handleChange(e, '')}
value={this.state.tempData === null ? '' : this.state.tempData.uom}
inputProps={{
style: {
......@@ -384,12 +386,7 @@ export default class EditReportItems extends Component {
<Autocomplete
{...this.state.listInputType}
id="inputType"
onChange={(event, newInputValue) => this.setState({InputType: newInputValue},
() => newInputValue === null ? this.setState({disabledFormula: true, disabledCondt: true, disabledValue: true, formula: '', condition: '', realVal: ''})
: newInputValue.type_report_name === 'FORMULA' ? this.setState({disabledFormula: false, disabledCondt: true, disabledValue: true, formula: '', condition: '', realVal: ''})
: newInputValue.type_report_name === 'VALIDATION' ? this.setState({disabledFormula: false, disabledCondt: false, disabledValue: false, formula: '', condition: '', realVal: ''})
: this.setState({disabledFormula: true, disabledCondt: true, disabledValue: true, formula: '', condition: '', realVal: ''})
)}
onChange={(event, newInputValue) => this.setState({InputType: newInputValue}, () => console.log(this.state.InputType))}
debug
renderInput={(params) =>
<TextField {...params}
......@@ -411,9 +408,11 @@ export default class EditReportItems extends Component {
<div className="margin-top-10px" style={{ padding: 10 }}>
<TextField
style={{ width: '100%' }}
id="realValue"
id="condition_it_should_be"
label="Nilai Seharusnya"
disabled={this.state.disabledValue}
disabled={this.state.InputType == null? true : (this.state.InputType.type_report_name === 'Validation'? false : true)}
name="condition_it_should_be"
onChange={(e) => this.handleChange(e, '')}
value={this.state.tempData === null ? '' : this.state.tempData.condition_it_should_be}
inputProps={{
style: {
......@@ -435,7 +434,8 @@ export default class EditReportItems extends Component {
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<DatePicker
margin="normal"
id="startDate"
id="start_date"
name="start_date"
label="Berlaku Mulai"
format="dd MMMM yyyy"
value={this.state.tempData === null ? null : this.state.tempData.start_date}
......@@ -529,6 +529,8 @@ export default class EditReportItems extends Component {
style={{ width: '100%' }}
id="order"
label="Order"
name="order"
onChange={(e) => this.handleChange(e, '')}
value={this.state.tempData === null ? '' : this.state.tempData.order}
inputProps={{
style: {
......@@ -577,6 +579,8 @@ export default class EditReportItems extends Component {
style={{ width: '100%' }}
id="weight"
label="Weight"
name="weight"
onChange={(e) => this.handleChange(e, '')}
value={this.state.tempData === null ? '' : this.state.tempData.weight}
inputProps={{
style: {
......@@ -601,7 +605,9 @@ export default class EditReportItems extends Component {
style={{ width: '100%' }}
id="formula"
label="Formula"
disabled={this.state.disabledFormula}
disabled={this.state.InputType == null? true : (this.state.InputType.type_report_name === 'Formula' || this.state.InputType.type_report_name === 'Validation'? false : true)}
name="formula"
onChange={(e) => this.handleChange(e, '')}
value={this.state.tempData === null ? '' : this.state.tempData.formula}
inputProps={{
style: {
......@@ -625,7 +631,7 @@ export default class EditReportItems extends Component {
<Autocomplete
value={this.state.tempData === null ? '' : this.state.tempData.condition}
id="isWrongCondition"
disabled={this.state.disabledCondt}
disabled={this.state.InputType == null? true : (this.state.InputType.type_report_name === 'Validation'? false : true)}
onChange={(event, newValue) => {
this.setState({condition: newValue});
}}
......@@ -648,7 +654,8 @@ export default class EditReportItems extends Component {
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<DatePicker
margin="normal"
id="endDate"
id="end_date"
name="end_date"
label="Berlaku Hingga"
format="dd MMMM yyyy"
value={this.state.tempData === null ? '' : this.state.tempData.end_date}
......
......@@ -120,6 +120,19 @@ export default class VisualReportItems extends Component {
}
};
handleSave() {
let payload = {
"item_report": this.state.items
}
api.create().saveVisualisasiReport(payload).then((response) => {
// if (response.data.status == 'ucces') {
this.props.onClickClose()
// } else {
// alert(response.data.message)
// }
})
}
renderItem = ({ item, collapseIcon }) => {
return (
<div>
......@@ -129,8 +142,6 @@ export default class VisualReportItems extends Component {
)
};
render() {
return (
......@@ -220,7 +231,7 @@ export default class VisualReportItems extends Component {
collapsed={this.state.defaultCollapsed}
renderItem={this.renderItem}
ref={el => this.refNestable = el}
onChange={(e) => this.setState({items: e})}
onChange={(e) => this.setState({items: e}, () => console.log(JSON.stringify(e)))}
/>
</div>
</div>
......@@ -233,9 +244,11 @@ export default class VisualReportItems extends Component {
<div onClick={() => this.props.onClickClose()} style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center', cursor:"pointer" }}>
<span style={{ color: '#354960', fontSize: 11 }} >Batal</span>
</div>
<div style={{ width: 102, height: 30, marginLeft: 25, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center', cursor:"pointer" }}>
<span style={{ color: '#fff', fontSize: 11 }}>Simpan</span>
</div>
<button onClick={() => this.handleSave()}>
<div style={{ width: 102, height: 30, marginLeft: 25, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center', cursor:"pointer" }}>
<span style={{ color: '#fff', fontSize: 11 }}>Simpan</span>
</div>
</button>
</div>
</div>
</div>
......
......@@ -152,15 +152,15 @@ export default class AddUser extends Component {
}
handleItemChecked(item) {
let indexID = this.state.company.findIndex((val) => val === item.company_id)
let indexID = this.state.company.findIndex((val) => val === item.id)
return indexID === -1 ? false : true
}
handleItemClick(item) {
let indexID = this.state.company.findIndex((val) => val === item.company_id)
let indexID = this.state.company.findIndex((val) => val === item.id)
let company = this.state.company
if (indexID === -1) {
company.push(item.company_id)
company.push(item.id)
} else {
company.splice(indexID, 1)
}
......@@ -176,15 +176,15 @@ export default class AddUser extends Component {
}
return (
<ul>
{item.child.map((data, index) => {
{item.children.map((data, index) => {
return (
// <li>
<Collapse key={index} 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)?
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start', paddingLeft: R.isNil(data.children) ? (padding + 20) : padding }}>
{R.isNil(data.children)?
null
:
data.child.length < 1?
data.children.length < 1?
null
:
<span onClick={() => this.handleCollapse(data)} style={{ marginLeft: 7, marginRight: 2 }}>
......@@ -199,7 +199,7 @@ export default class AddUser extends Component {
</span>
<Typography style={{ fontSize: 12 }}>{titleCase(data.company_name)}</Typography>
</div>
{!R.isNil(data.child) && this.renderChildren(data, padding + 20)}
{!R.isNil(data.children) && this.renderChildren(data, padding + 20)}
</Collapse>
// </li>
)
......@@ -209,7 +209,7 @@ export default class AddUser extends Component {
}
handleCollapse(item) {
let path = this.searchIt({child: this.state.listCompany}, item.company_id)
let path = this.searchIt({children: this.state.listCompany}, item.id)
let listCompany = this.state.listCompany
let arrayPath = []
......@@ -224,17 +224,17 @@ export default class AddUser extends Component {
if (arrayPath.length == 1) {
pathSelect= listCompany[arrayPath[0]]
} else if (arrayPath.length == 2) {
pathSelect= listCompany[arrayPath[0]].child[arrayPath[1]]
pathSelect= listCompany[arrayPath[0]].children[arrayPath[1]]
} else if (arrayPath.length == 3) {
pathSelect= listCompany[arrayPath[0]].child[arrayPath[1]].child[arrayPath[2]]
pathSelect= listCompany[arrayPath[0]].children[arrayPath[1]].children[arrayPath[2]]
} else if (arrayPath.length == 4) {
pathSelect= listCompany[arrayPath[0]].child[arrayPath[1]].child[arrayPath[2]].child[arrayPath[3]]
pathSelect= listCompany[arrayPath[0]].children[arrayPath[1]].children[arrayPath[2]].children[arrayPath[3]]
} else if (arrayPath.length == 5) {
pathSelect= listCompany[arrayPath[0]].child[arrayPath[1]].child[arrayPath[2]].child[arrayPath[3]].child[arrayPath[4]]
pathSelect= listCompany[arrayPath[0]].children[arrayPath[1]].children[arrayPath[2]].children[arrayPath[3]].children[arrayPath[4]]
} else if (arrayPath.length == 6) {
pathSelect= listCompany[arrayPath[0]].child[arrayPath[1]].child[arrayPath[2]].child[arrayPath[3]].child[arrayPath[4]].child[arrayPath[5]]
pathSelect= listCompany[arrayPath[0]].children[arrayPath[1]].children[arrayPath[2]].children[arrayPath[3]].children[arrayPath[4]].children[arrayPath[5]]
} else if (arrayPath.length == 7) {
pathSelect= listCompany[arrayPath[0]].child[arrayPath[1]].child[arrayPath[2]].child[arrayPath[3]].child[arrayPath[4]].child[arrayPath[5]].child[arrayPath[6]]
pathSelect= listCompany[arrayPath[0]].children[arrayPath[1]].children[arrayPath[2]].children[arrayPath[3]].children[arrayPath[4]].children[arrayPath[5]].children[arrayPath[6]]
}
pathSelect.collapse = !pathSelect.collapse
......@@ -243,14 +243,14 @@ export default class AddUser extends Component {
}
searchIt = (node, search, path = '', position = 0) => {
if (node.company_id && node.company_id === search) {return path !== '' ? `${path}-${position}` : position;}
if (!node.child) {return false}
const index = node.child.findIndex((x) => x.company_id && x.company_id === search);
if (node.id && node.id === search) {return path !== '' ? `${path}-${position}` : position;}
if (!node.children) {return false}
const index = node.children.findIndex((x) => x.id && x.id === search);
if (index >= 0) {
return path !== '' ? `${path}-${index}` : index;
}
for (let i = 0; i < node.child.length; i++) {
const result = this.searchIt(node.child[i], search, path !== '' ? `${path}-${i}` : i , i);
for (let i = 0; i < node.children.length; i++) {
const result = this.searchIt(node.children[i], search, path !== '' ? `${path}-${i}` : i , i);
if (result){
return result;
}
......@@ -446,7 +446,7 @@ export default class AddUser extends Component {
{/* <ul>
<li> */}
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start' }}>
{item.child.length > 0 && <span onClick={() => this.handleCollapse(item)} style={{ marginLeft: 7, marginRight: 2 }}>
{item.children.length > 0 && <span onClick={() => this.handleCollapse(item)} style={{ marginLeft: 7, marginRight: 2 }}>
{item.collapse ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
</span>}
<span>
......@@ -457,7 +457,7 @@ export default class AddUser extends Component {
</span>
<Typography style={{ fontSize: 12 }}>{titleCase(item.company_name)}</Typography>
</div>
{!R.isNil(item.child) && this.renderChildren(item)}
{!R.isNil(item.children) && this.renderChildren(item)}
{/* </li>
</ul> */}
</div>
......
......@@ -188,15 +188,15 @@ export default class EditUser extends Component {
}
handleItemChecked(item) {
let indexID = this.state.company.findIndex((val) => val === item.company_id)
let indexID = this.state.company.findIndex((val) => val === item.id)
return indexID === -1 ? false : true
}
handleItemClick(item) {
let indexID = this.state.company.findIndex((val) => val === item.company_id)
let indexID = this.state.company.findIndex((val) => val === item.id)
let company = this.state.company
if (indexID === -1) {
company.push(item.company_id)
company.push(item.id)
} else {
company.splice(indexID, 1)
}
......@@ -212,15 +212,15 @@ export default class EditUser extends Component {
}
return (
<ul>
{item.child.map((data, index) => {
{item.children.map((data, index) => {
return (
// <li>
<Collapse key={index} 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)?
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start', paddingLeft: R.isNil(data.children) ? (padding + 20) : padding }}>
{R.isNil(data.children)?
null
:
data.child.length < 1?
data.children.length < 1?
null
:
<span onClick={() => this.handleCollapse(data)} style={{ marginLeft: 7, marginRight: 2 }}>
......@@ -235,7 +235,7 @@ export default class EditUser extends Component {
</span>
<Typography style={{ fontSize: 12 }}>{titleCase(data.company_name)}</Typography>
</div>
{!R.isNil(data.child) && this.renderChildren(data, padding + 20)}
{!R.isNil(data.children) && this.renderChildren(data, padding + 20)}
</Collapse>
// </li>
)
......@@ -245,7 +245,7 @@ export default class EditUser extends Component {
}
handleCollapse(item) {
let path = this.searchIt({child: this.state.listCompany}, item.company_id)
let path = this.searchIt({children: this.state.listCompany}, item.id)
let listCompany = this.state.listCompany
let arrayPath = []
......@@ -260,17 +260,17 @@ export default class EditUser extends Component {
if (arrayPath.length == 1) {
pathSelect= listCompany[arrayPath[0]]
} else if (arrayPath.length == 2) {
pathSelect= listCompany[arrayPath[0]].child[arrayPath[1]]
pathSelect= listCompany[arrayPath[0]].children[arrayPath[1]]
} else if (arrayPath.length == 3) {
pathSelect= listCompany[arrayPath[0]].child[arrayPath[1]].child[arrayPath[2]]
pathSelect= listCompany[arrayPath[0]].children[arrayPath[1]].children[arrayPath[2]]
} else if (arrayPath.length == 4) {
pathSelect= listCompany[arrayPath[0]].child[arrayPath[1]].child[arrayPath[2]].child[arrayPath[3]]
pathSelect= listCompany[arrayPath[0]].children[arrayPath[1]].children[arrayPath[2]].children[arrayPath[3]]
} else if (arrayPath.length == 5) {
pathSelect= listCompany[arrayPath[0]].child[arrayPath[1]].child[arrayPath[2]].child[arrayPath[3]].child[arrayPath[4]]
pathSelect= listCompany[arrayPath[0]].children[arrayPath[1]].children[arrayPath[2]].children[arrayPath[3]].children[arrayPath[4]]
} else if (arrayPath.length == 6) {
pathSelect= listCompany[arrayPath[0]].child[arrayPath[1]].child[arrayPath[2]].child[arrayPath[3]].child[arrayPath[4]].child[arrayPath[5]]
pathSelect= listCompany[arrayPath[0]].children[arrayPath[1]].children[arrayPath[2]].children[arrayPath[3]].children[arrayPath[4]].children[arrayPath[5]]
} else if (arrayPath.length == 7) {
pathSelect= listCompany[arrayPath[0]].child[arrayPath[1]].child[arrayPath[2]].child[arrayPath[3]].child[arrayPath[4]].child[arrayPath[5]].child[arrayPath[6]]
pathSelect= listCompany[arrayPath[0]].children[arrayPath[1]].children[arrayPath[2]].children[arrayPath[3]].children[arrayPath[4]].children[arrayPath[5]].children[arrayPath[6]]
}
pathSelect.collapse = !pathSelect.collapse
......@@ -279,14 +279,14 @@ export default class EditUser extends Component {
}
searchIt = (node, search, path = '', position = 0) => {
if (node.company_id && node.company_id === search) {return path !== '' ? `${path}-${position}` : position;}
if (!node.child) {return false}
const index = node.child.findIndex((x) => x.company_id && x.company_id === search);
if (node.id && node.id === search) {return path !== '' ? `${path}-${position}` : position;}
if (!node.children) {return false}
const index = node.children.findIndex((x) => x.id && x.id === search);
if (index >= 0) {
return path !== '' ? `${path}-${index}` : index;
}
for (let i = 0; i < node.child.length; i++) {
const result = this.searchIt(node.child[i], search, path !== '' ? `${path}-${i}` : i , i);
for (let i = 0; i < node.children.length; i++) {
const result = this.searchIt(node.children[i], search, path !== '' ? `${path}-${i}` : i , i);
if (result){
return result;
}
......@@ -483,7 +483,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.handleCollapse(item)} style={{ marginLeft: 7, marginRight: 2 }}>
{item.children.length > 0 && <span onClick={() => this.handleCollapse(item)} style={{ marginLeft: 7, marginRight: 2 }}>
{item.collapse ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
</span>}
<span>
......@@ -494,7 +494,7 @@ export default class EditUser extends Component {
</span>
<Typography style={{ fontSize: 12 }}>{titleCase(item.company_name)}</Typography>
</div>
{!R.isNil(item.child) && this.renderChildren(item)}
{!R.isNil(item.children) && this.renderChildren(item)}
{/* </li>
</ul> */}
</div>
......
......@@ -142,7 +142,7 @@ export default class Profile extends Component {
}
handleItemChecked(item) {
let indexID = this.state.company.findIndex((val) => val == item.company_id)
let indexID = this.state.company.findIndex((val) => val == item.id)
return indexID == -1 ? false : true
}
......@@ -155,15 +155,15 @@ export default class Profile extends Component {
}
return (
<ul>
{item.child.map((data, index) => {
{item.children.map((data, index) => {
return (
// <li>
<Collapse key={index} 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)?
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start', paddingLeft: R.isNil(data.children) ? (padding + 20) : padding }}>
{R.isNil(data.children)?
null
:
data.child.length < 1?
data.children.length < 1?
null
:
<span onClick={() => this.handleCollapse(data)} style={{ marginLeft: 7, marginRight: 2 }}>
......@@ -178,7 +178,7 @@ export default class Profile extends Component {
</span>
<Typography style={{ fontSize: 12 }}>{titleCase(data.company_name)}</Typography>
</div>
{!R.isNil(data.child) && this.renderChildren(data, padding + 20)}
{!R.isNil(data.children) && this.renderChildren(data, padding + 20)}
</Collapse>
// </li>
)
......@@ -188,7 +188,7 @@ export default class Profile extends Component {
}
handleCollapse(item) {
let path = this.searchIt({child: this.state.listCompany}, item.company_id)
let path = this.searchIt({children: this.state.listCompany}, item.id)
let listCompany = this.state.listCompany
let arrayPath = []
......@@ -203,17 +203,17 @@ export default class Profile extends Component {
if (arrayPath.length == 1) {
pathSelect= listCompany[arrayPath[0]]
} else if (arrayPath.length == 2) {
pathSelect= listCompany[arrayPath[0]].child[arrayPath[1]]
pathSelect= listCompany[arrayPath[0]].children[arrayPath[1]]
} else if (arrayPath.length == 3) {
pathSelect= listCompany[arrayPath[0]].child[arrayPath[1]].child[arrayPath[2]]
pathSelect= listCompany[arrayPath[0]].children[arrayPath[1]].children[arrayPath[2]]
} else if (arrayPath.length == 4) {
pathSelect= listCompany[arrayPath[0]].child[arrayPath[1]].child[arrayPath[2]].child[arrayPath[3]]
pathSelect= listCompany[arrayPath[0]].children[arrayPath[1]].children[arrayPath[2]].children[arrayPath[3]]
} else if (arrayPath.length == 5) {
pathSelect= listCompany[arrayPath[0]].child[arrayPath[1]].child[arrayPath[2]].child[arrayPath[3]].child[arrayPath[4]]
pathSelect= listCompany[arrayPath[0]].children[arrayPath[1]].children[arrayPath[2]].children[arrayPath[3]].children[arrayPath[4]]
} else if (arrayPath.length == 6) {
pathSelect= listCompany[arrayPath[0]].child[arrayPath[1]].child[arrayPath[2]].child[arrayPath[3]].child[arrayPath[4]].child[arrayPath[5]]
pathSelect= listCompany[arrayPath[0]].children[arrayPath[1]].children[arrayPath[2]].children[arrayPath[3]].children[arrayPath[4]].children[arrayPath[5]]
} else if (arrayPath.length == 7) {
pathSelect= listCompany[arrayPath[0]].child[arrayPath[1]].child[arrayPath[2]].child[arrayPath[3]].child[arrayPath[4]].child[arrayPath[5]].child[arrayPath[6]]
pathSelect= listCompany[arrayPath[0]].children[arrayPath[1]].children[arrayPath[2]].children[arrayPath[3]].children[arrayPath[4]].children[arrayPath[5]].children[arrayPath[6]]
}
pathSelect.collapse = !pathSelect.collapse
......@@ -222,14 +222,14 @@ export default class Profile extends Component {
}
searchIt = (node, search, path = '', position = 0) => {
if (node.company_id && node.company_id === search) {return path !== '' ? `${path}-${position}` : position;}
if (!node.child) {return false}
const index = node.child.findIndex((x) => x.company_id && x.company_id === search);
if (node.id && node.id === search) {return path !== '' ? `${path}-${position}` : position;}
if (!node.children) {return false}
const index = node.children.findIndex((x) => x.id && x.id === search);
if (index >= 0) {
return path !== '' ? `${path}-${index}` : index;
}
for (let i = 0; i < node.child.length; i++) {
const result = this.searchIt(node.child[i], search, path !== '' ? `${path}-${i}` : i , i);
for (let i = 0; i < node.children.length; i++) {
const result = this.searchIt(node.children[i], search, path !== '' ? `${path}-${i}` : i , i);
if (result){
return result;
}
......@@ -344,7 +344,7 @@ export default class Profile extends Component {
{/* <ul>
<li> */}
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start' }}>
{item.child.length > 0 && <span onClick={() => this.handleCollapse(item)} style={{ marginLeft: 7, marginRight: 2 }}>
{item.children.length > 0 && <span onClick={() => this.handleCollapse(item)} style={{ marginLeft: 7, marginRight: 2 }}>
{item.collapse ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
</span>}
<span>
......@@ -355,7 +355,7 @@ export default class Profile extends Component {
</span>
<Typography style={{ fontSize: 12 }}>{titleCase(item.company_name)}</Typography>
</div>
{!R.isNil(item.child) && this.renderChildren(item)}
{!R.isNil(item.children) && this.renderChildren(item)}
{/* </li>
</ul> */}
</div>
......
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