Switch archive button with restore button for archived projects

This commit is contained in:
Alasdair Smith 2018-05-17 15:04:50 +01:00
parent 7dffc56804
commit 5ec238cae8
2 changed files with 19 additions and 5 deletions

View file

@ -64,9 +64,18 @@ if settings.overleaf
) )
i.icon.fa.fa-cloud-download i.icon.fa.fa-cloud-download
button.btn.btn-link.action-btn( button.btn.btn-link.action-btn(
ng-if="!project.archived"
tooltip=translate('archive'), tooltip=translate('archive'),
tooltip-placement="top", tooltip-placement="top",
tooltip-append-to-body="true", tooltip-append-to-body="true",
ng-click="archive($event)" ng-click="archive($event)"
) )
i.icon.fa.fa-inbox i.icon.fa.fa-inbox
button.btn.btn-link.action-btn(
ng-if="project.archived"
tooltip=translate('unarchive'),
tooltip-placement="top",
tooltip-append-to-body="true",
ng-click="restore($event)"
)
i.icon.fa.fa-reply

View file

@ -415,13 +415,14 @@ define [
$scope.updateVisibleProjects() $scope.updateVisibleProjects()
$scope.restoreSelectedProjects = () -> $scope.restoreSelectedProjects = () ->
selected_projects = $scope.getSelectedProjects() $scope.restoreProjects($scope.getSelectedProjects())
selected_project_ids = $scope.getSelectedProjectIds()
for project in selected_projects $scope.restoreProjects = (projects) ->
projectIds = projects.map (p) -> p.id
for project in projects
project.archived = false project.archived = false
for project_id in selected_project_ids for projectId in projectIds
queuedHttp { queuedHttp {
method: "POST" method: "POST"
url: "/project/#{project_id}/restore" url: "/project/#{project_id}/restore"
@ -504,3 +505,7 @@ define [
$scope.archive = (e) -> $scope.archive = (e) ->
e.stopPropagation() e.stopPropagation()
$scope.archiveOrLeaveProjects([$scope.project]) $scope.archiveOrLeaveProjects([$scope.project])
$scope.restore = (e) ->
e.stopPropagation()
$scope.restoreProjects([$scope.project])