$.get('/api/v2/staff/role/' + this.roleData.id)
{
"id": "1",
"status": "1",
"name": "Администратор",
"rights": {
"orders.view": "1",
"orders.create": "1",
"orders.changeClosed": "0",
"main.managerList": "1",
"main.workerList": "1",
"finance.reports": "1",
"compendiums.counteragents": "1",
"compendiums.works": "1"
},
"error": {
"error_code": 0
}
}
data:{
test: null,
modalAdd: false,
roleData:{
id:null,
name: null,
checkRights: []
}
}
const response = {
"id": "1",
"status": "1",
"name": "Администратор",
"rights": {
"orders.view": "1",
"orders.create": "1",
"orders.changeClosed": "0",
"main.managerList": "1",
"main.workerList": "1",
"finance.reports": "1",
"compendiums.counteragents": "1",
"compendiums.works": "1"
},
"error": {
"error_code": 0
}
};
const roleData = {
checkRights: []
};
const rights = Object.keys(response.rights).filter((key) => +response.rights[key] === 1);
roleData.checkRights = roleData.checkRights.concat(rights);
console.log(roleData);