Commit ced8b1c2 authored by Dida Adams Arizona's avatar Dida Adams Arizona

Merge branch 'didam' into 'master'

update

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