Created
November 21, 2015 00:13
-
-
Save doron2402/9a4a6c0ddf9dfb8071fe to your computer and use it in GitHub Desktop.
Dynamic nav bar
another way is using reduce instead of map
var steps = {
floorplan: {
display: 'ResourceService.FloorPlan',
url: "/floorplan",
icon: "floorplan",
isEnabled: true,
position: 6
},
combinations: {
display: 'ResourceService.TableCombinations',
url: "/combinations",
icon: "combinations",
isEnabled: true,
position: 2
},
'reservation-availability': {
display: "Reservation",
url: "/reservation-availability",
icon: "reservation",
isEnabled: false,
position: 3
},
shift: {
display: 'ResourceService.Schedule',
url: "/shift",
icon: "schedule",
isEnabled: true,
position: 1
},
calendar: {
display: 'ResourceService.SpecialDays',
//TODO: Need to rename URL endpoint to something like SpecialDays
url: "/calendar",
icon: "specialdays",
isEnabled: true,
position: 5
},
publish: {
display: 'ResourceService.Publish',
url: "/publish",
icon: "publish",
isEnabled: true,
position: 4
}
};
var a = Object.keys(steps)
.sort(SortByPosition)
.reduce(function(prev, curr, index, arr){
if (!!steps[curr].isEnabled) {
prev.push(
{
name: curr,
display: steps[curr].display,
url: steps[curr].url,
icon: steps[curr].icon,
prev: arr[index-1] ? arr[index-1] : 'welcome',
next: arr[index+1] ? arr[index+1] : 'welcome',
}
);
}
return prev;
},[]);
console.log(a);
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the order is: