Fix create token form in the repo-admin view. We had to add type="button" to the delete-ui button so that clicking it doesn't submit the form (and keep the focus there)

This commit is contained in:
Joseph Schorr 2014-07-29 18:53:23 -04:00
parent a661ef4fa8
commit af32b53a4e
3 changed files with 8 additions and 6 deletions

View file

@ -1,4 +1,4 @@
<span class="delete-ui-element" ng-click="focus()">
<span class="delete-ui-button" ng-click="performDelete()"><button class="btn btn-danger">{{ buttonTitleInternal }}</button></span>
<span class="delete-ui-button" ng-click="performDelete()"><button class="btn btn-danger" type="button">{{ buttonTitleInternal }}</button></span>
<i class="fa fa-times" bs-tooltip="tooltip.title" data-placement="left" data-title="{{ deleteTitle }}"></i>
</span>

View file

@ -1387,14 +1387,16 @@ function RepoAdminCtrl($scope, Restangular, ApiService, KeyService, $routeParams
});
};
$scope.newTokenName = null;
$scope.createToken = function() {
var friendlyName = {
'friendlyName': $scope.newToken.friendlyName
var data = {
'friendlyName': $scope.newTokenName
};
var params = {'repository': namespace + '/' + name};
ApiService.createToken(friendlyName, params).then(function(newToken) {
$scope.newToken.friendlyName = '';
ApiService.createToken(data, params).then(function(newToken) {
$scope.newTokenName = null;
$scope.createTokenForm.$setPristine();
$scope.tokens[newToken.code] = newToken;
});

View file

@ -180,7 +180,7 @@
<tr>
<td class="admin-search">
<input type="text" class="form-control" placeholder="New token description" ng-model="newToken.friendlyName" required>
<input type="text" class="form-control" placeholder="New token description" ng-model="newTokenName" required>
</td>
<td class="admin-search">
<button type="submit" ng-disabled="createTokenForm.$invalid" class="btn btn-sm btn-default">Create</button>