Commit 4a5b3424 authored by Dida Adams Arizona's avatar Dida Adams Arizona

Merge branch 'didam' into 'master'

update again

See merge request !256
parents 65065715 619fd806
...@@ -152,7 +152,7 @@ class UserRole extends Component { ...@@ -152,7 +152,7 @@ class UserRole extends Component {
handleChange(e) { handleChange(e) {
let data = this.state let data = this.state
window.requestIdleCallback((e) => this.setState({ ...data, [e.target.name]: e.target.value }, () => { window.requestIdleCallback((e) => this.setState({ ...data, [e.target.name]: e.target.value }, () => {
alert('asdk') // alert('asdk')
})) }))
} }
......
...@@ -324,23 +324,9 @@ export default class AddRole extends Component { ...@@ -324,23 +324,9 @@ export default class AddRole extends Component {
let indexButtonID = this.state.privileges[indexID].button_id.findIndex((val) => val === index) let indexButtonID = this.state.privileges[indexID].button_id.findIndex((val) => val === index)
let privileges = this.state.privileges let privileges = this.state.privileges
let button_id = privileges[indexID].button_id let button_id = privileges[indexID].button_id
// const handlePushChild = (item) => {
// let indexIDzz = company.findIndex((val) => val === item.id)
// if (indexIDzz === -1) {
// company.push(item.id)
// }
// if (item.children !== null) {
// if (item.children.length > 0) {
// item.children.map((items,indexs) => {
// handlePushChild(items)
// })
// }
// }
// }
if (indexButtonID === -1) { if (indexButtonID === -1) {
button_id.push(index) button_id.push(index)
// console.log(item)
if (item.sub_menu.length > 0) { if (item.sub_menu.length > 0) {
item.sub_menu.map((items,indexs) => { item.sub_menu.map((items,indexs) => {
let subIndexID = privileges.findIndex((val) => val.menu_id === items.menu_id) let subIndexID = privileges.findIndex((val) => val.menu_id === items.menu_id)
...@@ -356,8 +342,6 @@ export default class AddRole extends Component { ...@@ -356,8 +342,6 @@ export default class AddRole extends Component {
if(subIndexButtonID === -1) { if(subIndexButtonID === -1) {
subButton_id.push(index) subButton_id.push(index)
} }
// privileges[subIndexID].button_id = subButton_id
// console.log(subButton_id)
} }
}) })
} }
...@@ -381,7 +365,6 @@ export default class AddRole extends Component { ...@@ -381,7 +365,6 @@ export default class AddRole extends Component {
let subIndexButtonID = privileges[subIndexID].button_id.findIndex((val) => val === index) let subIndexButtonID = privileges[subIndexID].button_id.findIndex((val) => val === index)
let subButton_id = privileges[subIndexID].button_id let subButton_id = privileges[subIndexID].button_id
if (subIndexButtonID !== -1) { if (subIndexButtonID !== -1) {
// console.log('masuk pa eko', subIndexID)
subButton_id.splice(subIndexButtonID, 1) subButton_id.splice(subIndexButtonID, 1)
privileges[subIndexID].button_id = subButton_id privileges[subIndexID].button_id = subButton_id
if (privileges[subIndexID].button_id.length < 1) { if (privileges[subIndexID].button_id.length < 1) {
...@@ -421,9 +404,7 @@ export default class AddRole extends Component { ...@@ -421,9 +404,7 @@ export default class AddRole extends Component {
if (button_id.length === 0) { if (button_id.length === 0) {
privileges.splice(indexID, 1) privileges.splice(indexID, 1)
} }
this.setState({ privileges: privileges.sort((a,b) => a.menu_id-b.menu_id) }, () => { this.setState({ privileges: privileges.sort((a,b) => a.menu_id-b.menu_id) })
console.log(this.state.privileges)
})
} }
handleDate(item) { handleDate(item) {
......
...@@ -299,16 +299,87 @@ export default class EditRole extends Component { ...@@ -299,16 +299,87 @@ export default class EditRole extends Component {
let indexButtonID = this.state.privileges[indexID].button_id.findIndex((val) => val === index) let indexButtonID = this.state.privileges[indexID].button_id.findIndex((val) => val === index)
let privileges = this.state.privileges let privileges = this.state.privileges
let button_id = privileges[indexID].button_id let button_id = privileges[indexID].button_id
if (indexButtonID === -1) { if (indexButtonID === -1) {
button_id.push(index) button_id.push(index)
if (item.sub_menu.length > 0) {
item.sub_menu.map((items,indexs) => {
let subIndexID = privileges.findIndex((val) => val.menu_id === items.menu_id)
if (subIndexID === -1) {
console.log('masuk pa eko', subIndexID)
privileges.push({
menu_id: items.menu_id,
button_id: [index]
})
} else {
let subIndexButtonID = privileges[subIndexID].button_id.findIndex((val) => val === index)
let subButton_id = privileges[subIndexID].button_id
if(subIndexButtonID === -1) {
subButton_id.push(index)
}
}
})
}
if (item.reference !== null && item.reference !== 13 && item.reference !== 1) {
let refIndexID = privileges.findIndex((val) => val.menu_id === item.reference)
if (refIndexID !== -1) {
let refIndexButtonID = privileges[refIndexID].button_id.findIndex((val) => val === index)
let refButton_id = privileges[refIndexID].button_id
if (refIndexButtonID === -1) {
refButton_id.push(index)
}
privileges[refIndexID].button_id = refButton_id
}
}
} else { } else {
button_id.splice(indexButtonID, 1) button_id.splice(indexButtonID, 1)
if (item.sub_menu.length > 0) {
item.sub_menu.map((items,indexs) => {
let subIndexID = privileges.findIndex((val) => val.menu_id === items.menu_id)
if (subIndexID !== -1) {
let subIndexButtonID = privileges[subIndexID].button_id.findIndex((val) => val === index)
let subButton_id = privileges[subIndexID].button_id
if (subIndexButtonID !== -1) {
subButton_id.splice(subIndexButtonID, 1)
privileges[subIndexID].button_id = subButton_id
if (privileges[subIndexID].button_id.length < 1) {
privileges.splice(subIndexID, 1)
}
}
}
})
}
if (item.reference !== null && item.reference !== 13 && item.reference !== 1) {
let refIndexID = privileges.findIndex((val) => val.menu_id === item.reference)
if (refIndexID !== -1) {
let refIndexButtonID = privileges[refIndexID].button_id.findIndex((val) => val === index)
let refButton_id = privileges[refIndexID].button_id
let indexIDapp = this.state.application.findIndex((val) => val.menu_id === item.reference)
let indexIDset = this.state.setting.findIndex((val) => val.menu_id === item.reference)
let indexIDs = indexIDapp == -1? indexIDset : indexIDapp
let array = indexIDapp == -1? this.state.setting : this.state.application
let splicer = 0
array[indexIDs].sub_menu.map((refItem, refIndex) => {
let subIndexID = privileges.findIndex((val) => val.menu_id === refItem.menu_id)
if (subIndexID !== -1) {
let subIndexButtonID = privileges[subIndexID].button_id.findIndex((val) => val === index)
if (subIndexButtonID !== -1) {
splicer += 1
}
}
})
if (refIndexButtonID !== -1 && splicer < 1) {
refButton_id.splice(refIndexButtonID, 1)
}
privileges[refIndexID].button_id = refButton_id
}
}
} }
privileges[indexID].button_id = button_id privileges[indexID].button_id = button_id.sort((a,b) => a-b)
if (button_id.length === 0) { if (button_id.length === 0) {
privileges.splice(indexID, 1) privileges.splice(indexID, 1)
} }
this.setState({ privileges }) this.setState({ privileges: privileges.sort((a,b) => a.menu_id-b.menu_id) })
} }
handleCollapse(item) { handleCollapse(item) {
......
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