Show history section and its tabs only when it's needed

stable
David Barragán Merino 2016-09-22 11:47:25 +02:00
parent 62a20552a4
commit 2cc8b2e458
4 changed files with 21 additions and 4 deletions

View File

@ -20,10 +20,11 @@
module = angular.module('taigaHistory')
HistoryTabsDirective = () ->
return {
templateUrl:"history/history-tabs/history-tabs.html",
scope: {
showCommentTab: "&",
showActivityTab: "&"
onActiveComments: "&",
onActiveActivities: "&",
onOrderComments: "&"

View File

@ -1,5 +1,6 @@
nav.history-tabs
a.history-tab.e2e-comments-tab(
ng-if="showCommentTab()"
href=""
title="{{COMMENTS.COMMENT}}"
ng-click="onActiveComments()"
@ -8,6 +9,7 @@ nav.history-tabs
translate-values="{comments: commentsNum}"
)
a.history-tab.e2e-activity-tab(
ng-if="showActivityTab()"
href=""
title="Activities"
ng-click="onActiveActivities()"
@ -22,7 +24,7 @@ nav.history-tabs
ng-class="{'new-first': top, 'old-first': !top}"
ng-if="commentsNum > 1 && activeTab"
)
span(
translate="COMMENTS.OLDER_FIRST"
ng-if="onReverse"

View File

@ -24,9 +24,10 @@ class HistorySectionController
"$tgResources",
"$tgRepo",
"$tgStorage",
"tgProjectService",
]
constructor: (@rs, @repo, @storage) ->
constructor: (@rs, @repo, @storage, @projectService) ->
@.editing = null
@.deleting = null
@.editMode = {}
@ -49,6 +50,15 @@ class HistorySectionController
@.activities = _.filter(activities, (item) -> Object.keys(item.values_diff).length > 0)
@.activitiesNum = @.activities.length
showHistorySection: () ->
return @.showCommentTab() or @.showActivityTab()
showCommentTab: () ->
return @.commentsNum > 0 or @projectService.hasPermission("comment_#{@.name}")
showActivityTab: () ->
return @.activitiesNum > 0
toggleEditMode: (commentId) ->
@.editMode[commentId] = !@.editMode[commentId]

View File

@ -1,5 +1,9 @@
section.history
section.history(
ng-if="vm.showHistorySection()"
)
tg-history-tabs(
show-comment-tab="vm.showCommentTab()"
show-activity-tab="vm.showActivityTab()"
on-active-comments="vm.onActiveHistoryTab(true)"
on-active-activities="vm.onActiveHistoryTab(false)"
active-tab="vm.viewComments",