From 5ec238cae88483325d4b93c960b8aadd71dac6e2 Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Thu, 17 May 2018 15:04:50 +0100 Subject: [PATCH] Switch archive button with restore button for archived projects --- services/web/app/views/project/list/item.pug | 11 ++++++++++- .../coffee/main/project-list/project-list.coffee | 13 +++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/services/web/app/views/project/list/item.pug b/services/web/app/views/project/list/item.pug index a5362ebfd7..bc37683489 100644 --- a/services/web/app/views/project/list/item.pug +++ b/services/web/app/views/project/list/item.pug @@ -64,9 +64,18 @@ if settings.overleaf ) i.icon.fa.fa-cloud-download button.btn.btn-link.action-btn( + ng-if="!project.archived" tooltip=translate('archive'), tooltip-placement="top", tooltip-append-to-body="true", ng-click="archive($event)" ) - i.icon.fa.fa-inbox \ No newline at end of file + 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 \ No newline at end of file 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 72074a19b9..c2b251bd65 100644 --- a/services/web/public/coffee/main/project-list/project-list.coffee +++ b/services/web/public/coffee/main/project-list/project-list.coffee @@ -415,13 +415,14 @@ define [ $scope.updateVisibleProjects() $scope.restoreSelectedProjects = () -> - selected_projects = $scope.getSelectedProjects() - selected_project_ids = $scope.getSelectedProjectIds() + $scope.restoreProjects($scope.getSelectedProjects()) - for project in selected_projects + $scope.restoreProjects = (projects) -> + projectIds = projects.map (p) -> p.id + for project in projects project.archived = false - for project_id in selected_project_ids + for projectId in projectIds queuedHttp { method: "POST" url: "/project/#{project_id}/restore" @@ -504,3 +505,7 @@ define [ $scope.archive = (e) -> e.stopPropagation() $scope.archiveOrLeaveProjects([$scope.project]) + + $scope.restore = (e) -> + e.stopPropagation() + $scope.restoreProjects([$scope.project])