Commit 84d3c8e0 authored by Deni Rinaldi's avatar Deni Rinaldi

role

parent 9e4540ec
......@@ -132,6 +132,10 @@
/* display: ''; */
justify-content: 'center';
align-items: 'center' }
.popup-content-middle {
position: relative;
margin: auto;
width: 800px; }
.popup-content {
position: relative;
margin: auto;
......@@ -3,7 +3,7 @@ import { TextField, Divider, Typography, Checkbox, withStyles, Collapse } from '
import api from '../../../api';
import AddIcon from '@material-ui/icons/Add';
import RemoveIcon from '@material-ui/icons/Remove';
import {DatePicker} from "@material-ui/pickers";
import { DatePicker } from "@material-ui/pickers";
import format from "date-fns/format";
import localeID from "date-fns/locale/id"
import * as R from 'ramda'
......@@ -18,7 +18,7 @@ const CustomCheckbox = withStyles({
padding: 5
},
checked: {},
})((props) => <Checkbox color="default" {...props} />);
})((props) => <Checkbox color="default" {...props} />);
export default class AddRole extends Component {
......@@ -41,11 +41,13 @@ export default class AddRole extends Component {
msgErrorRN: '',
msgErrorSD: '',
msgErrorED: '',
application: [],
setting: [],
}
}
handleChecked() {
this.setState({checked: !this.state.checked})
this.setState({ checked: !this.state.checked })
}
componentDidMount() {
......@@ -54,9 +56,10 @@ export default class AddRole extends Component {
handleChange(e, type) {
let data = this.state
let isDate = type !== ''? true : false
let isDate = type !== '' ? true : false
if (isDate && type === 'start_date') {
this.setState({...data, startDate: format(e, 'yyyy-MM-dd'), endDate: null,
this.setState({
...data, startDate: format(e, 'yyyy-MM-dd'), endDate: null,
errorRoleName: false,
errorStartDate: false,
errorEndDate: false,
......@@ -65,7 +68,8 @@ export default class AddRole extends Component {
msgErrorED: '',
})
} else if (isDate && type === 'end_date') {
this.setState({...data, endDate : format(e, 'yyyy-MM-dd'),
this.setState({
...data, endDate: format(e, 'yyyy-MM-dd'),
errorRoleName: false,
errorStartDate: false,
errorEndDate: false,
......@@ -74,7 +78,8 @@ export default class AddRole extends Component {
msgErrorED: '',
})
} else {
this.setState({...data, [e.target.name]: e.target.value,
this.setState({
...data, [e.target.name]: e.target.value,
errorRoleName: false,
errorStartDate: false,
errorEndDate: false,
......@@ -88,11 +93,11 @@ export default class AddRole extends Component {
validasi() {
if (R.isEmpty(this.state.roleName)) {
this.setState({errorRoleName: true, msgErrorRN: 'Role Name tidak boleh kosong'})
this.setState({ errorRoleName: true, msgErrorRN: 'Role Name tidak boleh kosong' })
} else if (R.isNil(this.state.startDate)) {
this.setState({errorStartDate: true, msgErrorSD: 'Start Date tidak boleh kosong'})
this.setState({ errorStartDate: true, msgErrorSD: 'Start Date tidak boleh kosong' })
} else if (R.isNil(this.state.endDate)) {
this.setState({errorEndDate: true, msgErrorED: 'End Date tidak boleh kosong'})
this.setState({ errorEndDate: true, msgErrorED: 'End Date tidak boleh kosong' })
} else if (this.state.privileges.length < 1) {
alert('Hak Akses belum di pilih !!')
} else {
......@@ -121,10 +126,36 @@ export default class AddRole extends Component {
})
}
parseChildren(val) {
let data = Object.assign([], val)
data = data.sort((a, b) => a.menu_id - b.menu_id).map((i) => {
return {
menu_id: i.menu_id,
label: i.menu_name,
sub_menu: this.parseChildren(i.sub_menu),
collapse: false
}
})
return data
}
getMenu() {
api.create().getMenu().then((response) => {
if (response.data.status === 'success') {
this.setState({menuData: response.data.data})
let app = null
let set = null
response.data.data.map((item) => {
if (item.menu_name === "Application") {
app = this.parseChildren(item.sub_menu)
return app
} else {
set = this.parseChildren(item.sub_menu)
return set
}
})
console.log(app)
this.setState({ application: app, setting: set, isLoad: true }, () => console.log(this.state.application))
// this.setState({ menuData: response.data.data })
} else {
alert(response.data.message)
}
......@@ -133,7 +164,7 @@ export default class AddRole extends Component {
handleItemChecked(item) {
let indexID = this.state.privileges.findIndex((val) => val.menu_id === item.menu_id)
return indexID === -1? false : true
return indexID === -1 ? false : true
}
handleItemClick(item) {
......@@ -142,12 +173,12 @@ export default class AddRole extends Component {
if (indexID === -1) {
privileges.push({
menu_id: item.menu_id,
button_id: [1,2,3]
button_id: [1, 2, 3]
})
} else {
privileges.splice(indexID,1)
privileges.splice(indexID, 1)
}
this.setState({privileges})
this.setState({ privileges })
}
handleSubItemChecked(item, index) {
......@@ -163,7 +194,7 @@ export default class AddRole extends Component {
value = true
}
}
return indexID === -1? value : value
return indexID === -1 ? value : value
}
handleSubItemClick(item, index) {
......@@ -174,13 +205,13 @@ export default class AddRole extends Component {
if (indexButtonID === -1) {
button_id.push(index)
} else {
button_id.splice(indexButtonID,1)
button_id.splice(indexButtonID, 1)
}
privileges[indexID].button_id = button_id
if (button_id.length === 0) {
privileges.splice(indexID,1)
privileges.splice(indexID, 1)
}
this.setState({privileges})
this.setState({ privileges })
}
handleDate(item) {
......@@ -188,11 +219,25 @@ export default class AddRole extends Component {
return value
}
handleCollapse(item) {
let arr = this.state.application
let index = arr.findIndex((val) => val.label === item.label)
arr[index].collapse = !arr[index].collapse
this.setState({ ...this.state.application, application: arr })
}
handleCollapseSetting(item) {
let arr = this.state.setting
let index = arr.findIndex((val) => val.label === item.label)
arr[index].collapse = !arr[index].collapse
this.setState({ ...this.state.setting, setting: arr })
}
render() {
return (
<div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x" style={{ backgroundColor: '#51c6ea', height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="popup-content-middle background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
<div className="popup-title">
<span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Tambah Data</span>
......@@ -204,7 +249,7 @@ export default class AddRole extends Component {
className="btn btn-circle btn-white"
onClick={() => this.props.onClickClose()}
>
<img src={Images.close}/>
<img src={Images.close} />
</button>
</div>
</div>
......@@ -234,7 +279,7 @@ export default class AddRole extends Component {
<div className="column-2">
<div className="margin-bottom-20px">
<TextField
style={{ width: '100%' , marginTop: 7}}
style={{ width: '100%', marginTop: 7 }}
id="userRole"
name="roleName"
label="User Role"
......@@ -265,7 +310,7 @@ export default class AddRole extends Component {
'aria-label': 'change date',
}}
style={{padding: 0, margin: 0, width: '100%'}}
style={{ padding: 0, margin: 0, width: '100%' }}
/>
</div>
</div>
......@@ -286,7 +331,7 @@ export default class AddRole extends Component {
'aria-label': 'change date',
}}
style={{padding: 0, margin: 0, width: '100%'}}
style={{ padding: 0, margin: 0, width: '100%' }}
/>
</div>
</div>
......@@ -313,38 +358,38 @@ export default class AddRole extends Component {
</div>
</div>
</div>
<div style={{flexDirection:'column', display: 'flex', paddingLeft: 20, paddingRight: 20 }}>
<Typography style={{fontSize: 12}}>{`Dibuat : ${format(this.state.date, 'dd MMMM yyyy', {locale: localeID})}`}</Typography>
<div style={{ flexDirection: 'column', display: 'flex', paddingLeft: 20, paddingRight: 20 }}>
<Typography style={{ fontSize: 12 }}>{`Dibuat : ${format(this.state.date, 'dd MMMM yyyy', { locale: localeID })}`}</Typography>
{/* <Typography style={{fontSize: 12}}>{`Diubah: ${this.state.tempData === null? '' : this.state.tempData.updated}`}</Typography> */}
</div>
<Divider style={{margin: 20}}/>
<div style={{paddingLeft: 20, paddingRight: 20}}>
<Divider style={{ margin: 20 }} />
<div style={{ paddingLeft: 20, paddingRight: 20 }}>
<h5>Hak Akses</h5>
<div className="grid grid-2x grid-mobile-none gap-15px padding-top-5px padding-bottom-5px padding-left-10px padding-right-10px " style={{backgroundColor: '#4b4b4b'}}>
<div className="grid grid-2x grid-mobile-none gap-15px padding-top-5px padding-bottom-5px padding-left-10px padding-right-10px " style={{ backgroundColor: '#4b4b4b' }}>
<div className="column-1">
<Typography style={{fontSize: 12, color: 'white'}}>Otorisasi Modul</Typography>
<Typography style={{ fontSize: 12, color: 'white' }}>Otorisasi Modul</Typography>
</div>
<div className="column-2 grid grid-3x content-center grid-mobile-none gap-15px">
<div className="column-1">
<Typography style={{fontSize: 12, color: 'white'}}>Lihat</Typography>
<Typography style={{ fontSize: 12, color: 'white' }}>Lihat</Typography>
</div>
<div className="column-2">
<Typography style={{fontSize: 12, color: 'white'}}>Tambah</Typography>
<Typography style={{ fontSize: 12, color: 'white' }}>Tambah</Typography>
</div>
<div className="column 3">
<Typography style={{fontSize: 12, color: 'white'}}>Ubah</Typography>
<Typography style={{ fontSize: 12, color: 'white' }}>Ubah</Typography>
</div>
</div>
</div>
<div style={{height: '25vh', overflow: 'scroll'}}>
{this.state.menuData !== null && this.state.menuData.map((item,index) => {
<div style={{ height: '25vh', overflow: 'scroll' }}>
{this.state.application.map((item, index) => {
return (
<div>
<div className="grid grid-2x grid-mobile-none gap-15px padding-left-10px padding-right-10px">
<div className="column-1" style={{display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start'}}>
{item.sub_menu.length > 0 && <span onClick={() => this.setState({selectedIndex: index === this.state.selectedIndex? 0 : index})} style={{marginLeft: 7, marginRight: 2}}>
{index === this.state.selectedIndex? <RemoveIcon color={'action'} fontSize={'small'}/> : <AddIcon color={'action'} fontSize={'small'}/>}
<div className="column-1" style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start', paddingLeft: 8 }}>
{item.sub_menu.length > 0 && <span onClick={() => this.handleCollapse(item)} style={{ marginRight: 2, marginLeft: -22 }}>
{item.collapse ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
</span>}
<span>
<CustomCheckbox
......@@ -352,14 +397,14 @@ export default class AddRole extends Component {
onChange={() => this.handleItemClick(item)}
/>
</span>
<Typography style={{fontSize: 12, marginLeft: 5}}>{item.menu_name}</Typography>
<Typography style={{ fontSize: 12, marginLeft: 5 }}>{item.label}</Typography>
</div>
<div className="column-2 grid grid-3x content-center grid-mobile-none gap-15px">
<div className="column-2 grid grid-3x content-center grid-mobile-none gap-15px margin-left-10px">
<div className="column-1">
<CustomCheckbox
disabled={!this.handleItemChecked(item)}
checked={this.handleSubItemChecked(item, 1)}
onChange={() => this.handleSubItemClick(item,1)}
onChange={() => this.handleSubItemClick(item, 1)}
/>
</div>
<div className="column-2">
......@@ -367,7 +412,7 @@ export default class AddRole extends Component {
// disabled
disabled={!this.handleItemChecked(item)}
checked={this.handleSubItemChecked(item, 2)}
onChange={() => this.handleSubItemClick(item,2)}
onChange={() => this.handleSubItemClick(item, 2)}
/>
</div>
<div className="column 3">
......@@ -375,42 +420,125 @@ export default class AddRole extends Component {
// disabled
disabled={!this.handleItemChecked(item)}
checked={this.handleSubItemChecked(item, 3)}
onChange={() => this.handleSubItemClick(item,3)}
onChange={() => this.handleSubItemClick(item, 3)}
/>
</div>
</div>
</div>
{item.sub_menu.length > 0 && item.sub_menu.map((items,indexs) => {
return(
<Collapse in={index === this.state.selectedIndex} timeout="auto" unmountOnExit>
{item.sub_menu.length > 0 && item.sub_menu.map((items, indexs) => {
return (
<Collapse in={item.collapse} timeout="auto" unmountOnExit>
<div className="grid grid-2x grid-mobile-none gap-15px padding-left-10px padding-right-10px">
<div className="column-1" style={{display: 'flex', flexDirection: 'row', alignItems: 'center', paddingLeft: 50}}>
<div className="column-1" style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', paddingLeft: 30 }}>
<CustomCheckbox
checked={this.handleItemChecked(items)}
onChange={() => this.handleItemClick(items)}
/>
<Typography style={{fontSize: 12, maxWidth: '100%', marginLeft: 5}}>{items.menu_name}</Typography>
<Typography style={{ fontSize: 12, maxWidth: '100%', marginLeft: 5 }}>{items.label}</Typography>
</div>
<div className="column-2 grid grid-3x content-center grid-mobile-none gap-15px">
<div className="column-2 grid grid-3x content-center grid-mobile-none gap-15px margin-left-10px">
<div className="column-1">
<CustomCheckbox
disabled={!this.handleItemChecked(items)}
checked={this.handleSubItemChecked(items, 1)}
onChange={() => this.handleSubItemClick(items, 1)}
/>
</div>
<div className="column-2">
<CustomCheckbox
disabled={!this.handleItemChecked(items)}
checked={this.handleSubItemChecked(items, 2)}
onChange={() => this.handleSubItemClick(items, 2)}
/>
</div>
<div className="column 3">
<CustomCheckbox
disabled={!this.handleItemChecked(items)}
checked={this.handleSubItemChecked(items, 3)}
onChange={() => this.handleSubItemClick(items, 3)}
/>
</div>
</div>
</div>
</Collapse>
)
})}
</div>
)
})}
{this.state.setting.map((item, index) => {
return (
<div>
<div className="grid grid-2x grid-mobile-none gap-15px padding-left-10px padding-right-10px">
<div className="column-1" style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start', paddingLeft: 8 }}>
{item.sub_menu.length > 0 && <span onClick={() => this.handleCollapseSetting(item)} style={{ marginRight: 2, marginLeft: -22 }}>
{item.collapse ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
</span>}
<span>
<CustomCheckbox
checked={this.handleItemChecked(item)}
onChange={() => this.handleItemClick(item)}
/>
</span>
<Typography style={{ fontSize: 12, marginLeft: 5 }}>{item.label}</Typography>
</div>
<div className="column-2 grid grid-3x content-center grid-mobile-none gap-15px margin-left-10px">
<div className="column-1">
<CustomCheckbox
disabled={!this.handleItemChecked(item)}
checked={this.handleSubItemChecked(item, 1)}
onChange={() => this.handleSubItemClick(item, 1)}
/>
</div>
<div className="column-2">
<CustomCheckbox
// disabled
disabled={!this.handleItemChecked(item)}
checked={this.handleSubItemChecked(item, 2)}
onChange={() => this.handleSubItemClick(item, 2)}
/>
</div>
<div className="column 3">
<CustomCheckbox
// disabled
disabled={!this.handleItemChecked(item)}
checked={this.handleSubItemChecked(item, 3)}
onChange={() => this.handleSubItemClick(item, 3)}
/>
</div>
</div>
</div>
{item.sub_menu.length > 0 && item.sub_menu.map((items, indexs) => {
return (
<Collapse in={item.collapse} timeout="auto" unmountOnExit>
<div className="grid grid-2x grid-mobile-none gap-15px padding-left-10px padding-right-10px">
<div className="column-1" style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', paddingLeft: 30 }}>
<CustomCheckbox
checked={this.handleItemChecked(items)}
onChange={() => this.handleItemClick(items)}
/>
<Typography style={{ fontSize: 12, maxWidth: '100%', marginLeft: 5 }}>{items.label}</Typography>
</div>
<div className="column-2 grid grid-3x content-center grid-mobile-none gap-15px margin-left-10px">
<div className="column-1">
<CustomCheckbox
disabled={!this.handleItemChecked(items)}
checked={this.handleSubItemChecked(items, 1)}
onChange={() => this.handleSubItemClick(items,1)}
onChange={() => this.handleSubItemClick(items, 1)}
/>
</div>
<div className="column-2">
<CustomCheckbox
disabled={!this.handleItemChecked(items)}
checked={this.handleSubItemChecked(items, 2)}
onChange={() => this.handleSubItemClick(items,2)}
onChange={() => this.handleSubItemClick(items, 2)}
/>
</div>
<div className="column 3">
<CustomCheckbox
disabled={!this.handleItemChecked(items)}
checked={this.handleSubItemChecked(items, 3)}
onChange={() => this.handleSubItemClick(items,3)}
onChange={() => this.handleSubItemClick(items, 3)}
/>
</div>
</div>
......@@ -436,7 +564,7 @@ export default class AddRole extends Component {
</button>
</div>
<div className="column-2" style={{display: 'flex', justifyContent: 'flex-end', alignItems: 'center'}}>
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<button
type="button"
onClick={() => this.validasi()}
......
......@@ -36,6 +36,8 @@ export default class EditRole extends Component {
msgErrorRN: '',
msgErrorSD: '',
msgErrorED: '',
application: [],
setting: [],
}
}
......@@ -52,7 +54,8 @@ export default class EditRole extends Component {
let data = this.state
let isDate = type !== '' ? true : false
if (isDate && type === 'start_date') {
this.setState({ ...data, tempData: { ...this.state.tempData, start_date: format(e, 'yyyy-MM-dd'), end_date: null },
this.setState({
...data, tempData: { ...this.state.tempData, start_date: format(e, 'yyyy-MM-dd'), end_date: null },
errorRoleName: false,
errorStartDate: false,
errorEndDate: false,
......@@ -61,7 +64,8 @@ export default class EditRole extends Component {
msgErrorED: '',
})
} else if (isDate && type === 'end_date') {
this.setState({ ...data, tempData: { ...this.state.tempData, end_date: format(e, 'yyyy-MM-dd') },
this.setState({
...data, tempData: { ...this.state.tempData, end_date: format(e, 'yyyy-MM-dd') },
errorRoleName: false,
errorStartDate: false,
errorEndDate: false,
......@@ -70,7 +74,8 @@ export default class EditRole extends Component {
msgErrorED: '',
})
} else {
this.setState({ ...data, tempData: { ...this.state.tempData, [e.target.name]: e.target.value },
this.setState({
...data, tempData: { ...this.state.tempData, [e.target.name]: e.target.value },
errorRoleName: false,
errorStartDate: false,
errorEndDate: false,
......@@ -95,11 +100,11 @@ export default class EditRole extends Component {
validasi() {
if (R.isEmpty(this.state.tempData.role_name)) {
this.setState({errorRoleName: true, msgErrorRN: 'Role Name tidak boleh kosong'})
this.setState({ errorRoleName: true, msgErrorRN: 'Role Name tidak boleh kosong' })
} else if (R.isNil(this.state.tempData.start_date)) {
this.setState({errorStartDate: true, msgErrorSD: 'Start Date tidak boleh kosong'})
this.setState({ errorStartDate: true, msgErrorSD: 'Start Date tidak boleh kosong' })
} else if (R.isNil(this.state.tempData.end_date)) {
this.setState({errorEndDate: true, msgErrorED: 'End Date tidak boleh kosong'})
this.setState({ errorEndDate: true, msgErrorED: 'End Date tidak boleh kosong' })
} else if (this.state.privileges.length < 1) {
alert('Hak Akses belum di pilih !!')
} else {
......@@ -129,11 +134,36 @@ export default class EditRole extends Component {
})
}
parseChildren(val) {
let data = Object.assign([], val)
data = data.sort((a, b) => a.menu_id - b.menu_id).map((i) => {
return {
menu_id: i.menu_id,
label: i.menu_name,
sub_menu: this.parseChildren(i.sub_menu),
collapse: false
}
})
return data
}
getMenu() {
api.create().getMenu().then((response) => {
if (response.data.status === 'success') {
console.log(response.data.data)
this.setState({ menuData: response.data.data })
let app = null
let set = null
response.data.data.map((item) => {
if (item.menu_name === "Application") {
app = this.parseChildren(item.sub_menu)
return app
} else {
set = this.parseChildren(item.sub_menu)
return set
}
})
console.log(app)
this.setState({ application: app, setting: set, isLoad: true }, () => console.log(this.state.application))
// this.setState({ menuData: response.data.data })
} else {
alert(response.data.message)
}
......@@ -192,6 +222,20 @@ export default class EditRole extends Component {
this.setState({ privileges })
}
handleCollapse(item) {
let arr = this.state.application
let index = arr.findIndex((val) => val.label === item.label)
arr[index].collapse = !arr[index].collapse
this.setState({ ...this.state.application, application: arr })
}
handleCollapseSetting(item) {
let arr = this.state.setting
let index = arr.findIndex((val) => val.label === item.label)
arr[index].collapse = !arr[index].collapse
this.setState({ ...this.state.setting, setting: arr })
}
handleDate(item) {
let value = format(item, 'dd MMMM yyyy')
return value
......@@ -200,8 +244,8 @@ export default class EditRole extends Component {
render() {
return (
<div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x" style={{ backgroundColor: '#51c6ea', height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="popup-content-middle background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
<div className="popup-title">
<span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Ubah Data</span>
......@@ -213,7 +257,7 @@ export default class EditRole extends Component {
className="btn btn-circle btn-white"
onClick={() => this.props.onClickClose()}
>
<img src={Images.close}/>
<img src={Images.close} />
</button>
</div>
</div>
......@@ -347,13 +391,13 @@ export default class EditRole extends Component {
</div>
<div style={{ height: '25vh', overflow: 'scroll' }}>
{this.state.menuData !== null && this.state.menuData.map((item, index) => {
{this.state.application.map((item, index) => {
return (
<div>
<div className="grid grid-2x grid-mobile-none gap-15px padding-left-10px padding-right-10px">
<div className="column-1" style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start' }}>
{item.sub_menu.length > 0 && <span onClick={() => this.setState({ selectedIndex: index === this.state.selectedIndex ? 0 : index })} style={{ marginLeft: 7, marginRight: 2 }}>
{index === this.state.selectedIndex ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
<div className="column-1" style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start', paddingLeft: 8 }}>
{item.sub_menu.length > 0 && <span onClick={() => this.handleCollapse(item)} style={{ marginRight: 2, marginLeft: -22 }}>
{item.collapse ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
</span>}
<span>
<CustomCheckbox
......@@ -361,9 +405,9 @@ export default class EditRole extends Component {
onChange={() => this.handleItemClick(item)}
/>
</span>
<Typography style={{ fontSize: 12, marginLeft: 5 }}>{item.menu_name}</Typography>
<Typography style={{ fontSize: 12, marginLeft: 5 }}>{item.label}</Typography>
</div>
<div className="column-2 grid grid-3x content-center grid-mobile-none gap-15px">
<div className="column-2 grid grid-3x content-center grid-mobile-none gap-15px margin-left-10px">
<div className="column-1">
<CustomCheckbox
disabled={!this.handleItemChecked(item)}
......@@ -391,16 +435,99 @@ export default class EditRole extends Component {
</div>
{item.sub_menu.length > 0 && item.sub_menu.map((items, indexs) => {
return (
<Collapse in={index === this.state.selectedIndex} timeout="auto" unmountOnExit>
<Collapse in={item.collapse} timeout="auto" unmountOnExit>
<div className="grid grid-2x grid-mobile-none gap-15px padding-left-10px padding-right-10px">
<div className="column-1" style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', paddingLeft: 50 }}>
<div className="column-1" style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', paddingLeft: 30 }}>
<CustomCheckbox
checked={this.handleItemChecked(items)}
onChange={() => this.handleItemClick(items)}
/>
<Typography style={{ fontSize: 12, maxWidth: '100%', marginLeft: 5 }}>{items.menu_name}</Typography>
<Typography style={{ fontSize: 12, maxWidth: '100%', marginLeft: 5 }}>{items.label}</Typography>
</div>
<div className="column-2 grid grid-3x content-center grid-mobile-none gap-15px">
<div className="column-2 grid grid-3x content-center grid-mobile-none gap-15px margin-left-10px">
<div className="column-1">
<CustomCheckbox
disabled={!this.handleItemChecked(items)}
checked={this.handleSubItemChecked(items, 1)}
onChange={() => this.handleSubItemClick(items, 1)}
/>
</div>
<div className="column-2">
<CustomCheckbox
disabled={!this.handleItemChecked(items)}
checked={this.handleSubItemChecked(items, 2)}
onChange={() => this.handleSubItemClick(items, 2)}
/>
</div>
<div className="column 3">
<CustomCheckbox
disabled={!this.handleItemChecked(items)}
checked={this.handleSubItemChecked(items, 3)}
onChange={() => this.handleSubItemClick(items, 3)}
/>
</div>
</div>
</div>
</Collapse>
)
})}
</div>
)
})}
{this.state.setting.map((item, index) => {
return (
<div>
<div className="grid grid-2x grid-mobile-none gap-15px padding-left-10px padding-right-10px">
<div className="column-1" style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start', paddingLeft: 8 }}>
{item.sub_menu.length > 0 && <span onClick={() => this.handleCollapseSetting(item)} style={{ marginRight: 2, marginLeft: -22 }}>
{item.collapse ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
</span>}
<span>
<CustomCheckbox
checked={this.handleItemChecked(item)}
onChange={() => this.handleItemClick(item)}
/>
</span>
<Typography style={{ fontSize: 12, marginLeft: 5 }}>{item.label}</Typography>
</div>
<div className="column-2 grid grid-3x content-center grid-mobile-none gap-15px margin-left-10px">
<div className="column-1">
<CustomCheckbox
disabled={!this.handleItemChecked(item)}
checked={this.handleSubItemChecked(item, 1)}
onChange={() => this.handleSubItemClick(item, 1)}
/>
</div>
<div className="column-2">
<CustomCheckbox
// disabled
disabled={!this.handleItemChecked(item)}
checked={this.handleSubItemChecked(item, 2)}
onChange={() => this.handleSubItemClick(item, 2)}
/>
</div>
<div className="column 3">
<CustomCheckbox
// disabled
disabled={!this.handleItemChecked(item)}
checked={this.handleSubItemChecked(item, 3)}
onChange={() => this.handleSubItemClick(item, 3)}
/>
</div>
</div>
</div>
{item.sub_menu.length > 0 && item.sub_menu.map((items, indexs) => {
return (
<Collapse in={item.collapse} timeout="auto" unmountOnExit>
<div className="grid grid-2x grid-mobile-none gap-15px padding-left-10px padding-right-10px">
<div className="column-1" style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', paddingLeft: 30 }}>
<CustomCheckbox
checked={this.handleItemChecked(items)}
onChange={() => this.handleItemClick(items)}
/>
<Typography style={{ fontSize: 12, maxWidth: '100%', marginLeft: 5 }}>{items.label}</Typography>
</div>
<div className="column-2 grid grid-3x content-center grid-mobile-none gap-15px margin-left-10px">
<div className="column-1">
<CustomCheckbox
disabled={!this.handleItemChecked(items)}
......
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