Merge pull request #553 from taigaio/issue/2785/fix-user-mentions

Issue/2785/fix user mentions
stable
Alejandro 2015-06-26 05:35:58 -07:00
commit c98b15ce10
7 changed files with 20 additions and 23 deletions

View File

@ -152,7 +152,7 @@ module.directive("tgSprintProgressbar", SprintProgressBarDirective)
## Created-by display directive
#############################################################################
CreatedByDisplayDirective = ($template, $compile, $translate)->
CreatedByDisplayDirective = ($template, $compile, $translate, $navUrls)->
# Display the owner information (full name and photo) and the date of
# creation of an object (like USs, tasks and issues).
#
@ -168,13 +168,14 @@ CreatedByDisplayDirective = ($template, $compile, $translate)->
link = ($scope, $el, $attrs) ->
render = (model) ->
owner = $scope.usersById?[model.owner] or {
owner = model.owner_extra_info or {
full_name_display: $translate.instant("COMMON.EXTERNAL_USER")
photo: "/images/unnamed.png"
photo: "/images/user-noimage.png"
}
html = template({
owner: owner
url: if owner?.is_active then $navUrls.resolve("user-profile", {username: owner.username}) else ""
date: moment(model.created_date).format($translate.instant("COMMON.DATETIME"))
})
@ -194,7 +195,8 @@ CreatedByDisplayDirective = ($template, $compile, $translate)->
require: "ngModel"
}
module.directive("tgCreatedByDisplay", ["$tgTemplate", "$compile", "$translate", CreatedByDisplayDirective])
module.directive("tgCreatedByDisplay", ["$tgTemplate", "$compile", "$translate", "$tgNavUrls",
CreatedByDisplayDirective])
#############################################################################

View File

@ -68,7 +68,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) ->
HistoryDirective = ($log, $loading, $qqueue, $template, $confirm, $translate, $compile, $navUrls) ->
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)
@ -136,15 +136,6 @@ HistoryDirective = ($log, $loading, $qqueue, $template, $confirm, $translate, $c
return humanizedFieldNames[field] or field
getUserFullName = (userId) ->
return $scope.usersById[userId]?.full_name_display
getUserAvatar = (userId) ->
if $scope.usersById[userId]?
return $scope.usersById[userId].photo
else
return "/images/unnamed.png"
countChanges = (comment) ->
return _.keys(comment.values_diff).length
@ -286,8 +277,9 @@ HistoryDirective = ($log, $loading, $qqueue, $template, $confirm, $translate, $c
return html[0].outerHTML
html = templateActivity({
avatar: getUserAvatar(comment.user.pk)
avatar: comment.user.photo
userFullName: comment.user.name
userProfileUrl: if comment.user.is_active then $navUrls.resolve("user-profile", {username: comment.user.username}) else ""
creationDate: moment(comment.created_at).format(getPrettyDateFormat())
comment: comment.comment_html
changesText: renderChangesHelperText(comment)
@ -305,8 +297,9 @@ HistoryDirective = ($log, $loading, $qqueue, $template, $confirm, $translate, $c
renderChange = (change) ->
return templateActivity({
avatar: getUserAvatar(change.user.pk)
avatar: change.user.photo
userFullName: change.user.name
userProfileUrl: if change.user.is_active then $navUrls.resolve("user-profile", {username: change.user.username}) else ""
creationDate: moment(change.created_at).format(getPrettyDateFormat())
comment: change.comment_html
changes: renderChangeEntries(change)
@ -458,4 +451,4 @@ HistoryDirective = ($log, $loading, $qqueue, $template, $confirm, $translate, $c
module.directive("tgHistory", ["$log", "$tgLoading", "$tgQqueue", "$tgTemplate", "$tgConfirm", "$translate",
"$compile", HistoryDirective])
"$compile", "$tgNavUrls", HistoryDirective])

View File

@ -155,7 +155,7 @@ WikiSummaryDirective = ($log, $template, $compile, $translate) ->
user = $scope.usersById[wiki.last_modifier]
if user is undefined
user = {name: "unknown", imgUrl: "/images/unnamed.png"}
user = {name: "unknown", imgUrl: "/images/user-noimage.png"}
else
user = {name: user.full_name_display, imgUrl: user.photo}

BIN
app/images/user-noimage.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

@ -3,7 +3,7 @@ div.activity-item
div.activity-info
div.profile-contact-picture
a(tg-nav="user-profile:username=vm.activity.user.username", title="{{::vm.activity.user.name }}")
img(ng-src="{{::vm.activity.user.photo || '/images/unnamed.png'}}", alt="{{::vm.activity.user.name}}")
img(ng-src="{{::vm.activity.user.photo || '/images/user-noimage.png'}}", alt="{{::vm.activity.user.name}}")
p(tg-compile-html="vm.activity.title")

View File

@ -1,7 +1,9 @@
.user-avatar
img(src!="<%- owner.photo %>", alt!="<%- owner.full_name_display %>")
a(href!="<%- url %>", title!="<%- owner.full_name_display %>")
img(src!="<%- owner.photo %>", alt!="<%- owner.full_name_display %>")
.created-by
span.created-title(translate="COMMON.CREATED_BY", translate-values!="{ 'fullDisplayName': '<%- owner.full_name_display %>'}")
a(href!="<%- url %>", title!="<%- owner.full_name_display %>")
span.created-title(translate="COMMON.CREATED_BY", translate-values!="{ 'fullDisplayName': '<%- owner.full_name_display %>'}")
span.created-date
| <%- date %>

View File

@ -1,10 +1,10 @@
div(class!="activity-single <%- mode %>")
.activity-user
a.avatar(href="" title!="<%- userFullName %>")
a.avatar(href!="<%- userProfileUrl %>", title!="<%- userFullName %>")
img(src!="<%- avatar %>", alt!="<%- userFullName %>")
.activity-content
.activity-username
a.username(href="", title!="<%- userFullName %>")
a.username(href!="<%- userProfileUrl %>", title!="<%- userFullName %>")
| <%- userFullName %>
span.date
| <%- creationDate %>