Add frontend and API support for deleting tags. Model support is needed.
This commit is contained in:
parent
ee80f43375
commit
9da93c7caf
8 changed files with 195 additions and 6 deletions
|
@ -194,6 +194,38 @@ function RepoCtrl($scope, Restangular, ApiService, $routeParams, $rootScope, $lo
|
|||
}
|
||||
};
|
||||
|
||||
$scope.askDeleteTag = function(tagName) {
|
||||
if (!$scope.repo.can_admin) { return; }
|
||||
|
||||
$scope.tagToDelete = tagName;
|
||||
$('#confirmdeleteTagModal').modal('show');
|
||||
};
|
||||
|
||||
$scope.deleteTag = function(tagName) {
|
||||
if (!$scope.repo.can_admin) { return; }
|
||||
$('#confirmdeleteTagModal').modal('hide');
|
||||
|
||||
var params = {
|
||||
'repository': namespace + '/' + name,
|
||||
'tag': tagName
|
||||
};
|
||||
|
||||
ApiService.deleteFullTag(null, params).then(function() {
|
||||
loadViewInfo();
|
||||
}, function(resp) {
|
||||
bootbox.dialog({
|
||||
"message": resp.data ? resp.data : 'Could not delete tag',
|
||||
"title": "Cannot delete tag",
|
||||
"buttons": {
|
||||
"close": {
|
||||
"label": "Close",
|
||||
"className": "btn-primary"
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.setTag = function(tagName, opt_updateURL) {
|
||||
var repo = $scope.repo;
|
||||
var proposedTag = repo.tags[tagName];
|
||||
|
@ -229,6 +261,40 @@ function RepoCtrl($scope, Restangular, ApiService, $routeParams, $rootScope, $lo
|
|||
return count;
|
||||
};
|
||||
|
||||
$scope.hideTagMenu = function(tagName, clientX, clientY) {
|
||||
$scope.currentMenuTag = null;
|
||||
|
||||
var tagMenu = $("#tagContextMenu");
|
||||
tagMenu.hide();
|
||||
};
|
||||
|
||||
$scope.showTagMenu = function(tagName, clientX, clientY) {
|
||||
if (!$scope.repo.can_admin) { return; }
|
||||
|
||||
$scope.currentMenuTag = tagName;
|
||||
|
||||
var tagMenu = $("#tagContextMenu");
|
||||
tagMenu.css({
|
||||
display: "block",
|
||||
left: clientX,
|
||||
top: clientY
|
||||
});
|
||||
|
||||
tagMenu.on("blur", function() {
|
||||
setTimeout(function() {
|
||||
tagMenu.hide();
|
||||
}, 100); // Needed to allow clicking on menu items.
|
||||
});
|
||||
|
||||
tagMenu.on("click", "a", function() {
|
||||
setTimeout(function() {
|
||||
tagMenu.hide();
|
||||
}, 100); // Needed to allow clicking on menu items.
|
||||
});
|
||||
|
||||
tagMenu[0].focus();
|
||||
};
|
||||
|
||||
var getDefaultTag = function() {
|
||||
if ($scope.repo === undefined) {
|
||||
return undefined;
|
||||
|
@ -343,6 +409,14 @@ function RepoCtrl($scope, Restangular, ApiService, $routeParams, $rootScope, $lo
|
|||
$scope.$apply(function() { $scope.setImage(e.image); });
|
||||
});
|
||||
|
||||
$($scope.tree).bind('showTagMenu', function(e) {
|
||||
$scope.$apply(function() { $scope.showTagMenu(e.tag, e.clientX, e.clientY); });
|
||||
});
|
||||
|
||||
$($scope.tree).bind('hideTagMenu', function(e) {
|
||||
$scope.$apply(function() { $scope.hideTagMenu(); });
|
||||
});
|
||||
|
||||
return resp.images;
|
||||
});
|
||||
};
|
||||
|
|
Reference in a new issue