diff --git a/services/web/app/views/project/list/item.pug b/services/web/app/views/project/list/item.pug index 2b1cb59090..deb9863d04 100644 --- a/services/web/app/views/project/list/item.pug +++ b/services/web/app/views/project/list/item.pug @@ -90,6 +90,14 @@ if settings.overleaf ng-click="restore($event)" ) i.icon.fa.fa-reply + button.btn.btn-link.action-btn( + ng-if="project.archived && isOwner()" + tooltip=translate('delete_forever'), + tooltip-placement="top", + tooltip-append-to-body="true", + ng-click="deleteProject($event)" + ) + i.icon.fa.fa-trash div( ng-if="project.isTableActionInflight" ) diff --git a/services/web/public/coffee/main/project-list/project-list.coffee b/services/web/public/coffee/main/project-list/project-list.coffee index 6bc0ac1771..9a8d7f7a73 100644 --- a/services/web/public/coffee/main/project-list/project-list.coffee +++ b/services/web/public/coffee/main/project-list/project-list.coffee @@ -469,7 +469,7 @@ define [ else $scope.updateVisibleProjects() - App.controller "ProjectListItemController", ($scope) -> + App.controller "ProjectListItemController", ($scope, $modal, queuedHttp) -> $scope.shouldDisableCheckbox = (project) -> $scope.filter == 'archived' && project.accessLevel != 'owner' @@ -518,3 +518,28 @@ define [ $scope.restore = (e) -> e.stopPropagation() $scope.restoreProjects([$scope.project]) + + $scope.deleteProject = (e) -> + e.stopPropagation() + modalInstance = $modal.open( + templateUrl: "deleteProjectsModalTemplate" + controller: "DeleteProjectsModalController" + resolve: + projects: () -> [ $scope.project ] + ) + + modalInstance.result.then () -> + $scope.project.isTableActionInflight = true + queuedHttp({ + method: "DELETE" + url: "/project/#{$scope.project.id}?forever=true" + headers: + "X-CSRF-Token": window.csrfToken + }).then () -> + $scope.project.isTableActionInflight = false + $scope._removeProjectFromList $scope.project + for tag in $scope.tags + $scope._removeProjectIdsFromTagArray(tag, [ $scope.project.id ]) + $scope.updateVisibleProjects() + .catch () -> + $scope.project.isTableActionInflight = false