From fd008e38fe5757e71b4aa162f0a577cd55bb7c55 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Wed, 5 Jul 2017 16:04:02 +0100 Subject: [PATCH] Show simpler UI when there is only one user. --- .../web/app/views/project/editor/review-panel.pug | 12 ++++++++++-- .../controllers/ReviewPanelController.coffee | 11 ++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/services/web/app/views/project/editor/review-panel.pug b/services/web/app/views/project/editor/review-panel.pug index 844e7946e4..c0ac5dd75b 100644 --- a/services/web/app/views/project/editor/review-panel.pug +++ b/services/web/app/views/project/editor/review-panel.pug @@ -51,14 +51,22 @@ ng-if="editor.wantTrackChanges === true" ) i.fa.fa-circle - span(ng-click="toggleFullTCStateCollapse();", ng-if="editor.wantTrackChanges === false") !{translate("track_changes_is_off")} - span(ng-click="toggleFullTCStateCollapse();", ng-if="editor.wantTrackChanges === true") !{translate("track_changes_is_on")} + span(ng-click="handleTrackChangesStateClick();", ng-if="editor.wantTrackChanges === false") !{translate("track_changes_is_off")} + span(ng-click="handleTrackChangesStateClick();", ng-if="editor.wantTrackChanges === true") !{translate("track_changes_is_on")} span.rp-tc-state-collapse( + ng-if="reviewPanel.isMultiUser" ng-class="{ 'rp-tc-state-collapse-on': reviewPanel.fullTCStateCollapsed }" ) i.fa.fa-angle-down + review-panel-toggle( + ng-if="!reviewPanel.isMultiUser" + ng-model="reviewPanel.trackChangesOnForEveryone" + on-toggle="toggleTrackChangesForEveryone(isOn);" + disabled="!project.features.trackChanges || !permissions.write" + ) ul.rp-tc-state( review-panel-collapse-height="reviewPanel.fullTCStateCollapsed" + ng-if="reviewPanel.isMultiUser" ) li.rp-tc-state-item.rp-tc-state-item-everyone span.rp-tc-state-item-name Everyone diff --git a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee index 800e5aace8..c9cb9d8ea1 100644 --- a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee +++ b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee @@ -34,6 +34,7 @@ define [ resolvedThreadIds: {} rendererData: {} formattedProjectMembers: {} + isMultiUser: false fullTCStateCollapsed: true loadingThreads: false # All selected changes. If a aggregated change (insertion + deletion) is selection, the two ids @@ -71,11 +72,13 @@ define [ $scope.$watch "project.members", (members) -> $scope.reviewPanel.formattedProjectMembers = {} + $scope.reviewPanel.isMultiUser = false if $scope.project?.owner? $scope.reviewPanel.formattedProjectMembers[$scope.project.owner._id] = formatUser($scope.project.owner) if $scope.project?.members? for member in members if member.privileges == "readAndWrite" + $scope.reviewPanel.isMultiUser = true $scope.reviewPanel.formattedProjectMembers[member._id] = formatUser(member) $scope.commentState = @@ -584,6 +587,12 @@ define [ $scope.gotoEntry = (doc_id, entry) -> ide.editorManager.openDocId(doc_id, { gotoOffset: entry.offset }) + $scope.handleTrackChangesStateClick = () -> + if $scope.reviewPanel.isMultiUser + $scope.toggleFullTCStateCollapse() + else + $scope.toggleTrackChangesForEveryone() + $scope.toggleFullTCStateCollapse = () -> if $scope.project.features.trackChanges reviewPanel.fullTCStateCollapsed = !reviewPanel.fullTCStateCollapsed @@ -632,7 +641,7 @@ define [ _setUserTCState(member._id, state[member._id] ? false) _setUserTCState($scope.project.owner._id, state[$scope.project.owner._id] ? false) - $scope.toggleTrackChangesForEveryone = (onForEveryone) -> + $scope.toggleTrackChangesForEveryone = (onForEveryone = !reviewPanel.trackChangesOnForEveryone) -> _setEveryoneTCState onForEveryone, true applyClientTrackChangesStateToServer()