0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Merge pull request #4934 from PaulAdamDavis/fix-nav-order-metadata

Add `order` property when parsing Navigation JSON
This commit is contained in:
Hannah Wolfe 2015-02-23 23:39:06 +00:00
commit 8cf111e767
2 changed files with 13 additions and 4 deletions

View file

@ -403,7 +403,11 @@
// &.last-navigation-item {
&:last-child {
padding-left: 27px; // .navigation-item-drag-handle width + horizontal padding
padding-left: 27px; // simulate .navigation-item-drag-handle width + horizontal padding
.navigation-item-drag-handle {
display: none;
}
}
}

View file

@ -20,7 +20,8 @@ NavigationController = Ember.Controller.extend({
navigationItems: Ember.computed('model.navigation', function () {
var navItems,
lastItem;
lastItem,
order = 0;
try {
navItems = JSON.parse(this.get('model.navigation') || [{}]);
@ -29,6 +30,8 @@ NavigationController = Ember.Controller.extend({
}
navItems = navItems.map(function (item) {
item.order = order;
order = order + 1;
return NavItem.create(item);
});
@ -86,8 +89,10 @@ NavigationController = Ember.Controller.extend({
order = 0;
navItems.forEach(function (item) {
item.set('order', order);
order = order + 1; // Increment order order by one
if (!item.last) { // Make sure we never apply an `order` attr to the last item
item.set('order', order);
order = order + 1; // Increment order order by one
}
});
},