Up/down buttons for changing the order of related links

This commit is contained in:
AndyButland
2014-01-03 17:08:33 +01:00
parent 6a5a320a22
commit 07229c4bd2
2 changed files with 8 additions and 0 deletions

View File

@@ -92,6 +92,12 @@
link.isInternal = !link.isInternal;
$event.preventDefault();
};
$scope.move = function (index, direction) {
var temp = $scope.model.value[index];
$scope.model.value[index] = $scope.model.value[index + direction];
$scope.model.value[index + direction] = temp;
};
function select(data) {
if ($scope.currentEditLink != null) {

View File

@@ -40,6 +40,8 @@
<td>
<div class="btn-group" ng-show="!link.edit">
<button type="button" class="btn btn-default" ng-click="move($index, -1)" ng-disabled="$first">Up</button>
<button type="button" class="btn btn-default" ng-click="move($index, 1)" ng-disabled="$last">Down</button>
<button type="button" class="btn btn-default" ng-click="edit($index)">Edit</button>
<button type="button" class="btn btn-default" ng-click="delete($index)">Delete</button>
</div>