1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00

Add order property when parsing Navigation JSON

Closes #4927

- Add `order` property when parsing Navigation JSON
- Fixes CSS issue where the placeholder nav item drag handle was still visible
This commit is contained in:
Paul Adam Davis 2015-02-18 13:10:43 +00:00
parent a164488d65
commit 3563427921
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
}
});
},