Merge pull request #850 from taigaio/issue/3460/hide-activity-comments

hide comments & activity if no content
stable
David Barragán Merino 2016-02-03 10:50:07 +01:00
commit 802b632845
4 changed files with 40 additions and 9 deletions

View File

@ -88,7 +88,7 @@ class HistoryController extends taiga.Controller
return @rs.history.undeleteComment(type, objectId, activityId).then => @.loadHistory(type, objectId)
HistoryDirective = ($log, $loading, $qqueue, $template, $confirm, $translate, $compile, $navUrls, $rootScope) ->
HistoryDirective = ($log, $loading, $qqueue, $template, $confirm, $translate, $compile, $navUrls, $rootScope, checkPermissionsService) ->
templateChangeDiff = $template.get("common/history/history-change-diff.html", true)
templateChangePoints = $template.get("common/history/history-change-points.html", true)
templateChangeGeneric = $template.get("common/history/history-change-generic.html", true)
@ -343,6 +343,30 @@ HistoryDirective = ($log, $loading, $qqueue, $template, $confirm, $translate, $c
# Render into DOM (operations with dom mutability)
renderBase = ->
comments = $scope.comments or []
changes = $scope.history or []
historyVisible = !!changes.length
commentsVisible = (!!comments.length) || checkPermissionsService.check('modify_' + $attrs.type)
html = templateBase({
ngmodel: $attrs.ngModel,
type: $attrs.type,
mode: $attrs.mode,
historyVisible: historyVisible,
commentsVisible: commentsVisible
})
html = $compile(html)($scope)
$el.html(html)
rerender = ->
renderBase()
renderComments()
renderActivity()
renderComments = ->
comments = $scope.comments or []
totalComments = comments.length
@ -388,8 +412,8 @@ HistoryDirective = ($log, $loading, $qqueue, $template, $confirm, $translate, $c
# Watchers
$scope.$watch("comments", renderComments)
$scope.$watch("history", renderActivity)
$scope.$watch("comments", rerender)
$scope.$watch("history", rerender)
$scope.$on("object:updated", -> $ctrl.loadHistory(type, objectId))
@ -467,14 +491,10 @@ HistoryDirective = ($log, $loading, $qqueue, $template, $confirm, $translate, $c
$scope.$on "$destroy", ->
$el.off()
templateFn = ($el, $attrs) ->
html = templateBase({ngmodel: $attrs.ngModel, type: $attrs.type, mode: $attrs.mode})
return html
renderBase()
return {
controller: HistoryController
template: templateFn
restrict: "AE"
link: link
# require: ["ngModel", "tgHistory"]
@ -482,4 +502,4 @@ HistoryDirective = ($log, $loading, $qqueue, $template, $confirm, $translate, $c
module.directive("tgHistory", ["$log", "$tgLoading", "$tgQqueue", "$tgTemplate", "$tgConfirm", "$translate",
"$compile", "$tgNavUrls", "$rootScope", HistoryDirective])
"$compile", "$tgNavUrls", "$rootScope", "tgCheckPermissionsService", HistoryDirective])

View File

@ -27,6 +27,8 @@ class ChekcPermissionsService
constructor: (@projectService) ->
check: (permission) ->
return false if !@projectService.project
return @projectService.project.get('my_permissions').indexOf(permission) != -1
angular.module("taigaCommon").service("tgCheckPermissionsService", ChekcPermissionsService)

View File

@ -1,15 +1,21 @@
include ../components/wysiwyg.jade
section.history
<% if (commentsVisible || historyVisible) { %>
ul.history-tabs
<% if (commentsVisible) { %>
li
a(href="#", class="active", data-section-class="history-comments")
span.icon.icon-comment
span.tab-title(translate="COMMENTS.TITLE")
<% } %>
<% if (historyVisible) { %>
li
a(href="#", data-section-class="history-activity")
span.icon.icon-issues
span.tab-title(translate="ACTIVITY.TITLE")
<% } %>
<% } %>
section.history-comments
.comments-list
div(tg-editable-wysiwyg, ng-model!="<%- ngmodel %>")

View File

@ -49,6 +49,9 @@
&:first-child {
border-right: 1px solid $gray-light;
}
&:last-child {
border-right: 0;
}
}
a {
color: $gray-light;