Bläddra i källkod

Merge pull request #2812 from utkarshcmu/master

Duplicate button for template variables
Torkel Ödegaard 10 år sedan
förälder
incheckning
0c7fccdcbe

+ 7 - 0
public/app/features/templating/editorCtrl.js

@@ -96,6 +96,13 @@ function (angular, _) {
       }
       }
     };
     };
 
 
+    $scope.duplicate = function(variable) {
+      $scope.current = angular.copy(variable);
+      $scope.variables.push($scope.current);
+      $scope.current.name = 'copy_of_'+variable.name;
+      $scope.updateSubmenuVisibility();
+    };
+
     $scope.update = function() {
     $scope.update = function() {
       if ($scope.isValid()) {
       if ($scope.isValid()) {
         $scope.runQuery().then(function() {
         $scope.runQuery().then(function() {

+ 5 - 0
public/app/features/templating/partials/editor.html

@@ -59,6 +59,11 @@
 									Edit
 									Edit
 								</a>
 								</a>
 							</td>
 							</td>
+              <td style="width: 1%">
+                <a ng-click="duplicate(variable)" class="btn btn-inverse btn-small">
+                  Duplicate
+                </a>
+              </td>
 							<td style="width: 1%"><i ng-click="_.move(variables,$index,$index-1)" ng-hide="$first" class="pointer fa fa-arrow-up"></i></td>
 							<td style="width: 1%"><i ng-click="_.move(variables,$index,$index-1)" ng-hide="$first" class="pointer fa fa-arrow-up"></i></td>
 							<td style="width: 1%"><i ng-click="_.move(variables,$index,$index+1)" ng-hide="$last" class="pointer fa fa-arrow-down"></i></td>
 							<td style="width: 1%"><i ng-click="_.move(variables,$index,$index+1)" ng-hide="$last" class="pointer fa fa-arrow-down"></i></td>
 							<td style="width: 1%">
 							<td style="width: 1%">