From 14f3a6821552e4a874deb5df05fc592704856f97 Mon Sep 17 00:00:00 2001 From: ubhatnagar Date: Fri, 9 Oct 2015 03:06:52 +0530 Subject: [PATCH] Added move row to top and bottom. --- public/app/features/dashboard/rowCtrl.js | 25 ++++++++++++++++++++++-- public/app/partials/dashboard.html | 6 ++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/public/app/features/dashboard/rowCtrl.js b/public/app/features/dashboard/rowCtrl.js index 27365f7bd1c..02cb59721a3 100644 --- a/public/app/features/dashboard/rowCtrl.js +++ b/public/app/features/dashboard/rowCtrl.js @@ -55,9 +55,30 @@ function (angular, _, config) { $scope.move_row = function(direction) { var rowsList = $scope.dashboard.rows; var rowIndex = _.indexOf(rowsList, $scope.row); - var newIndex = rowIndex + direction; + var newIndex = rowIndex; + switch(direction) { + case 'up': { + newIndex = rowIndex - 1; + break; + } + case 'down': { + newIndex = rowIndex + 1; + break; + } + case 'top': { + newIndex = 0; + break; + } + case 'bottom': { + newIndex = rowsList.length - 1; + break; + } + default: { + newIndex = rowIndex; + } + } if (newIndex >= 0 && newIndex <= (rowsList.length - 1)) { - _.move(rowsList, rowIndex, rowIndex + direction); + _.move(rowsList, rowIndex, newIndex); } }; diff --git a/public/app/partials/dashboard.html b/public/app/partials/dashboard.html index 156da97e50a..4edbb816eeb 100644 --- a/public/app/partials/dashboard.html +++ b/public/app/partials/dashboard.html @@ -60,8 +60,10 @@