Просмотр исходного кода

basic playlist dashboards sort support

nikita-graf 10 лет назад
Родитель
Сommit
3fabd2ea1b

+ 8 - 2
public/app/features/playlist/partials/playlist.html

@@ -86,8 +86,14 @@
           <td style="white-space: nowrap;">
           <td style="white-space: nowrap;">
             {{dashboard.title}}
             {{dashboard.title}}
           </td>
           </td>
-          <td style="text-align: center">
-            <button class="btn btn-inverse btn-mini pull-right" ng-click="removeDashboard(dashboard)">
+          <td style="text-align: right">
+            <button class="btn btn-inverse btn-mini" ng-click="moveDashboardUp(dashboard)">
+              <i class="fa fa-arrow-up"></i>
+            </button>
+            <button class="btn btn-inverse btn-mini" ng-click="moveDashboardDown(dashboard)">
+              <i class="fa fa-arrow-down"></i>
+            </button>
+            <button class="btn btn-inverse btn-mini" ng-click="removeDashboard(dashboard)">
               <i class="fa fa-remove"></i>
               <i class="fa fa-remove"></i>
             </button>
             </button>
           </td>
           </td>

+ 18 - 0
public/app/features/playlist/playlistEditCtrl.js

@@ -107,6 +107,24 @@ function (angular, config, _) {
       return $scope.loading;
       return $scope.loading;
     };
     };
 
 
+    $scope.moveDashboard = function(dashboard, offset) {
+      var currentPosition = dashboards.indexOf(dashboard);
+      var newPosition = currentPosition + offset;
+
+      if (newPosition >= 0 && newPosition < dashboards.length) {
+        dashboards.splice(currentPosition, 1);
+        dashboards.splice(newPosition, 0, dashboard);
+      }
+    };
+
+    $scope.moveDashboardUp = function(dashboard) {
+      $scope.moveDashboard(dashboard, -1);
+    };
+
+    $scope.moveDashboardDown = function(dashboard) {
+      $scope.moveDashboard(dashboard, 1);
+    };
+
     $scope.playlist = playlist;
     $scope.playlist = playlist;
     $scope.dashboards = dashboards;
     $scope.dashboards = dashboards;
     $scope.timespan = config.playlist_timespan;
     $scope.timespan = config.playlist_timespan;