From 3563427921fdc37e0ca048e879e1ab81eedd3ccf Mon Sep 17 00:00:00 2001 From: Paul Adam Davis Date: Wed, 18 Feb 2015 13:10:43 +0000 Subject: [PATCH] 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 --- assets/sass/layouts/settings.scss | 6 +++++- controllers/settings/navigation.js | 11 ++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/assets/sass/layouts/settings.scss b/assets/sass/layouts/settings.scss index 6c57b0f86..7201e6153 100644 --- a/assets/sass/layouts/settings.scss +++ b/assets/sass/layouts/settings.scss @@ -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; + } } } diff --git a/controllers/settings/navigation.js b/controllers/settings/navigation.js index 53f971c8d..cda439691 100644 --- a/controllers/settings/navigation.js +++ b/controllers/settings/navigation.js @@ -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 + } }); },