accountSrv getAccount then function account staffUnitRes query account

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
accountSrv.getAccount().then(function (account) {
staffUnitRes.query({'account._id': account._id}, function (staffUnit) {
if (staffUnit.length > 0) {
ticketBoxRouteRes.query({'staffUnits._id': staffUnit[0]._id}, function (tbRoutes) {
var allBoxes = _.pluck(tbRoutes, 'sourceTicketBox');
var officeWorkMenuIndex = _.findIndex($scope.menu, {name: 'officeWork'});
_.forEach(allBoxes, function (box) {
$scope.menu[officeWorkMenuIndex].subElems.push({
icon: 'fa fa-inbox',
title: box.title,
name: 'officeWork.' + box._id,
accessName: 'officeWork.' + box._id + '.list',
url: '#!/officeWork',
isHidden: true
});
});
filterMenuByAccess($scope.menu);
})
} else {
filterMenuByAccess($scope.menu);
}
})
});