hide comments & activity if no content
parent
efad795b53
commit
562e1c7ddd
|
@ -88,7 +88,7 @@ class HistoryController extends taiga.Controller
|
||||||
return @rs.history.undeleteComment(type, objectId, activityId).then => @.loadHistory(type, objectId)
|
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)
|
templateChangeDiff = $template.get("common/history/history-change-diff.html", true)
|
||||||
templateChangePoints = $template.get("common/history/history-change-points.html", true)
|
templateChangePoints = $template.get("common/history/history-change-points.html", true)
|
||||||
templateChangeGeneric = $template.get("common/history/history-change-generic.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)
|
# 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 = ->
|
renderComments = ->
|
||||||
comments = $scope.comments or []
|
comments = $scope.comments or []
|
||||||
totalComments = comments.length
|
totalComments = comments.length
|
||||||
|
@ -388,8 +412,8 @@ HistoryDirective = ($log, $loading, $qqueue, $template, $confirm, $translate, $c
|
||||||
|
|
||||||
# Watchers
|
# Watchers
|
||||||
|
|
||||||
$scope.$watch("comments", renderComments)
|
$scope.$watch("comments", rerender)
|
||||||
$scope.$watch("history", renderActivity)
|
$scope.$watch("history", rerender)
|
||||||
|
|
||||||
$scope.$on("object:updated", -> $ctrl.loadHistory(type, objectId))
|
$scope.$on("object:updated", -> $ctrl.loadHistory(type, objectId))
|
||||||
|
|
||||||
|
@ -467,14 +491,10 @@ HistoryDirective = ($log, $loading, $qqueue, $template, $confirm, $translate, $c
|
||||||
$scope.$on "$destroy", ->
|
$scope.$on "$destroy", ->
|
||||||
$el.off()
|
$el.off()
|
||||||
|
|
||||||
templateFn = ($el, $attrs) ->
|
renderBase()
|
||||||
html = templateBase({ngmodel: $attrs.ngModel, type: $attrs.type, mode: $attrs.mode})
|
|
||||||
|
|
||||||
return html
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
controller: HistoryController
|
controller: HistoryController
|
||||||
template: templateFn
|
|
||||||
restrict: "AE"
|
restrict: "AE"
|
||||||
link: link
|
link: link
|
||||||
# require: ["ngModel", "tgHistory"]
|
# require: ["ngModel", "tgHistory"]
|
||||||
|
@ -482,4 +502,4 @@ HistoryDirective = ($log, $loading, $qqueue, $template, $confirm, $translate, $c
|
||||||
|
|
||||||
|
|
||||||
module.directive("tgHistory", ["$log", "$tgLoading", "$tgQqueue", "$tgTemplate", "$tgConfirm", "$translate",
|
module.directive("tgHistory", ["$log", "$tgLoading", "$tgQqueue", "$tgTemplate", "$tgConfirm", "$translate",
|
||||||
"$compile", "$tgNavUrls", "$rootScope", HistoryDirective])
|
"$compile", "$tgNavUrls", "$rootScope", "tgCheckPermissionsService", HistoryDirective])
|
||||||
|
|
|
@ -27,6 +27,8 @@ class ChekcPermissionsService
|
||||||
constructor: (@projectService) ->
|
constructor: (@projectService) ->
|
||||||
|
|
||||||
check: (permission) ->
|
check: (permission) ->
|
||||||
|
return false if !@projectService.project
|
||||||
|
|
||||||
return @projectService.project.get('my_permissions').indexOf(permission) != -1
|
return @projectService.project.get('my_permissions').indexOf(permission) != -1
|
||||||
|
|
||||||
angular.module("taigaCommon").service("tgCheckPermissionsService", ChekcPermissionsService)
|
angular.module("taigaCommon").service("tgCheckPermissionsService", ChekcPermissionsService)
|
||||||
|
|
|
@ -1,15 +1,21 @@
|
||||||
include ../components/wysiwyg.jade
|
include ../components/wysiwyg.jade
|
||||||
|
|
||||||
section.history
|
section.history
|
||||||
|
<% if (commentsVisible || historyVisible) { %>
|
||||||
ul.history-tabs
|
ul.history-tabs
|
||||||
|
<% if (commentsVisible) { %>
|
||||||
li
|
li
|
||||||
a(href="#", class="active", data-section-class="history-comments")
|
a(href="#", class="active", data-section-class="history-comments")
|
||||||
span.icon.icon-comment
|
span.icon.icon-comment
|
||||||
span.tab-title(translate="COMMENTS.TITLE")
|
span.tab-title(translate="COMMENTS.TITLE")
|
||||||
|
<% } %>
|
||||||
|
<% if (historyVisible) { %>
|
||||||
li
|
li
|
||||||
a(href="#", data-section-class="history-activity")
|
a(href="#", data-section-class="history-activity")
|
||||||
span.icon.icon-issues
|
span.icon.icon-issues
|
||||||
span.tab-title(translate="ACTIVITY.TITLE")
|
span.tab-title(translate="ACTIVITY.TITLE")
|
||||||
|
<% } %>
|
||||||
|
<% } %>
|
||||||
section.history-comments
|
section.history-comments
|
||||||
.comments-list
|
.comments-list
|
||||||
div(tg-editable-wysiwyg, ng-model!="<%- ngmodel %>")
|
div(tg-editable-wysiwyg, ng-model!="<%- ngmodel %>")
|
||||||
|
|
|
@ -49,6 +49,9 @@
|
||||||
&:first-child {
|
&:first-child {
|
||||||
border-right: 1px solid $gray-light;
|
border-right: 1px solid $gray-light;
|
||||||
}
|
}
|
||||||
|
&:last-child {
|
||||||
|
border-right: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
a {
|
a {
|
||||||
color: $gray-light;
|
color: $gray-light;
|
||||||
|
|
Loading…
Reference in New Issue