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

Merge branch 'didam' into 'master'

finally

See merge request !255
parents e1a0b932 6030f5e0
......@@ -340,7 +340,7 @@ export default class AddRole extends Component {
if (indexButtonID === -1) {
button_id.push(index)
console.log(item)
// console.log(item)
if (item.sub_menu.length > 0) {
item.sub_menu.map((items,indexs) => {
let subIndexID = privileges.findIndex((val) => val.menu_id === items.menu_id)
......@@ -352,24 +352,70 @@ export default class AddRole extends Component {
})
} else {
let subIndexButtonID = privileges[subIndexID].button_id.findIndex((val) => val === index)
let subButton_id = []
console.log(subIndexButtonID, subButton_id)
if (subIndexButtonID === -1) {
let subButton_id = privileges[subIndexID].button_id
if(subIndexButtonID === -1) {
subButton_id.push(index)
privileges[subIndexID].button_id = subButton_id
} else {
subButton_id = privileges[subIndexID].button_id
console.log(subButton_id)
subButton_id.splice(subIndexButtonID, 1)
privileges[subIndexID].button_id = subButton_id.sort((a,b) => a-b)
}
// privileges[subIndexID].button_id = subButton_id
// console.log(subButton_id)
}
// let subIndexButtonID = privileges[subIndexID].button_id.findIndex((val) => val === indexs)
// let subButton_id = privileges[indexID].button_id
})
}
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 {
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) {
// console.log('masuk pa eko', subIndexID)
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.sort((a,b) => a-b)
if (button_id.length === 0) {
......
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