Other cosmetic fixes.

stable
Andrey Antukh 2014-07-23 13:10:46 +02:00
parent 5a4982942f
commit afbab5d966
1 changed files with 48 additions and 189 deletions

View File

@ -126,7 +126,6 @@ class IssueDetailController extends mixOf(taiga.Controller, taiga.PageMixin)
# TODO: i18n
if size == 1
return "Made #{size} change"
return "Made #{size} changes"
block: ->
@ -261,146 +260,6 @@ TagLineDirective = ($log) ->
module.directive("tgTagLine", ["$log", TagLineDirective])
#############################################################################
## Watchers directive
#############################################################################
WatchersDirective = ($rootscope, $confirm) ->
#TODO: i18n
template = _.template("""
<div class="watchers-header">
<span class="title">watchers</span>
<% if (editable) { %>
<a href="" title="Add watcher" class="icon icon-plus add-watcher">
</a>
<% } %>
</div>
<% _.each(watchers, function(watcher) { %>
<div class="watcher-single">
<div class="watcher-avatar">
<a class="avatar" href="" title="Assigned to">
<img src="<%= watcher.photo %>" alt="<%= watcher.full_name_display %>">
</a>
</div>
<div class="watcher-name">
<a href="" title="<%= watcher.full_name_display %>">
<%= watcher.full_name_display %>
</a>
<% if (editable) { %>
<a class="icon icon-delete" data-watcher-id="<%= watcher.id %>" href="" title="delete-watcher"></a>
<% } %>
</div>
</div>
<% }); %>
""")
link = ($scope, $el, $attrs, $model) ->
editable = $attrs.editable?
$scope.$watch $attrs.ngModel, (watcherIds) ->
watchers = _.map(watcherIds, (watcherId) -> $scope.usersById[watcherId])
html = template({watchers: watchers, editable:editable})
$el.html(html)
if watchers.length == 0
if editable
$el.find(".title").text("Add watchers")
$el.find(".watchers-header").addClass("no-watchers")
else
$el.find(".watchers-header").hide()
if not editable
$el.find(".add-watcher").remove()
$el.on "click", ".icon-delete", (event) ->
event.preventDefault()
target = angular.element(event.currentTarget)
watcherId = target.data("watcher-id")
title = "Remove watcher"
subtitle = $scope.usersById[watcherId].full_name_display
$confirm.ask(title, subtitle).then =>
watcherIds = _.clone($model.$modelValue, false)
watcherIds = _.pull(watcherIds, watcherId)
$model.$setViewValue(watcherIds)
$el.on "click", ".add-watcher", (event) ->
event.preventDefault()
target = angular.element(event.currentTarget)
$rootscope.$broadcast("watcher:add")
$scope.$on "watcher:added", (ctx, watcher) ->
watcherIds = _.clone($model.$modelValue, false)
watcherIds.push(watcher.id)
watcherIds = _.uniq(watcherIds)
$scope.$apply ->
$model.$setViewValue(watcherIds)
return {link:link, require:"ngModel"}
module.directive("tgWatchers", ["$rootScope", "$tgConfirm", WatchersDirective])
#############################################################################
## Assigned to directive
#############################################################################
AssignedToDirective = ($rootscope, $confirm) ->
#TODO: i18n
template = _.template("""
<% if (assignedTo) { %>
<div class="user-avatar">
<a href="" title="Assigned to" class="avatar"><img src="<%= assignedTo.photo %>" alt="<%= assignedTo.full_name_display %>"></a>
</div>
<% } %>
<div class="assigned-to">
<span class="assigned-title">Assigned to</span>
<a href="" title="edit assignment" class="user-assigned">
<% if (assignedTo) { %>
<%= assignedTo.full_name_display %>
<% } else { %>
Not assigned
<% } %>
<% if (editable) { %>
<span class="icon icon-arrow-bottom"></span>
<% } %>
</a>
<% if (editable && assignedTo!==null) { %>
<a href="" title="delete assignment" class="icon icon-delete"></a>
<% } %>
</div>
""")
link = ($scope, $el, $attrs, $model) ->
editable = $attrs.editable?
renderAssignedTo = (issue) ->
assignedToId = issue?.assigned_to
assignedTo = null
assignedTo = $scope.usersById[assignedToId] if assignedToId?
html = template({assignedTo: assignedTo, editable:editable})
$el.html(html)
$scope.$watch $attrs.ngModel, (instance) ->
renderAssignedTo(instance)
$el.on "click", ".user-assigned", (event) ->
event.preventDefault()
$scope.$apply(
$rootscope.$broadcast("assigned-to:add", $model.$modelValue)
)
$el.on "click", ".icon-delete", (event) ->
event.preventDefault()
title = "Remove assigned to"
subtitle = ""
$confirm.ask(title, subtitle).then =>
$model.$modelValue.assigned_to = null
renderAssignedTo($model.$modelValue)
$scope.$on "assigned-to:added", (ctx, issue) ->
renderAssignedTo(issue)
return {link:link, require:"ngModel"}
module.directive("tgAssignedTo", ["$rootScope", "$tgConfirm", AssignedToDirective])
#############################################################################
## Issue status directive
@ -541,7 +400,7 @@ module.directive("tgIssueStatus", IssueStatusDirective)
## Comment directive
#############################################################################
CommentDirective = () ->
CommentDirective = ->
link = ($scope, $el, $attrs, $model) ->
$el.on "click", ".activity-title", (event) ->
event.preventDefault()