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

@ -123,10 +123,9 @@ class IssueDetailController extends mixOf(taiga.Controller, taiga.PageMixin)
buildChangesText: (comment) -> buildChangesText: (comment) ->
size = @.countChanges(comment) size = @.countChanges(comment)
#TODO: i18n # TODO: i18n
if size == 1 if size == 1
return "Made #{size} change" return "Made #{size} change"
return "Made #{size} changes" return "Made #{size} changes"
block: -> block: ->
@ -136,7 +135,7 @@ class IssueDetailController extends mixOf(taiga.Controller, taiga.PageMixin)
@rootscope.$broadcast("unblock", @scope.issue) @rootscope.$broadcast("unblock", @scope.issue)
delete: -> delete: ->
#TODO: i18n # TODO: i18n
title = "Delete Issue" title = "Delete Issue"
subtitle = @scope.issue.subject subtitle = @scope.issue.subject
@ -261,205 +260,65 @@ TagLineDirective = ($log) ->
module.directive("tgTagLine", ["$log", TagLineDirective]) 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 ## Issue status directive
############################################################################# #############################################################################
IssueStatusDirective = () -> IssueStatusDirective = () ->
#TODO: i18n # TODO: i18n
template = _.template(""" template = _.template("""
<h1> <h1>
<span> <span>
<% if (status.is_closed) { %> <% if (status.is_closed) { %>
Closed Closed
<% } else { %> <% } else { %>
Open Open
<% } %> <% } %>
</span> </span>
<span class="us-detail-status" style="color:<%= status.color %>"><%= status.name %></span> <span class="us-detail-status" style="color:<%= status.color %>"><%= status.name %></span>
</h1> </h1>
<div class="issue-data"> <div class="issue-data">
<div class="severity-data <% if (editable) { %>clickable<% } %>"> <div class="severity-data <% if (editable) { %>clickable<% } %>">
<span class="level" style="background-color:<%= severity.color %>"></span> <span class="level" style="background-color:<%= severity.color %>"></span>
<span class="severity-status"><%= severity.name %></span> <span class="severity-status"><%= severity.name %></span>
<span class="level-name">severity</span> <span class="level-name">severity</span>
</div>
<div class="priority-data <% if (editable) { %>clickable<% } %>">
<span class="level" style="background-color:<%= priority.color %>"></span>
<span class="priority-status"><%= priority.name %></span>
<span class="level-name">priority</span>
</div>
<div class="status-data <% if (editable) { %>clickable<% } %>">
<span class="level" style="background-color:<%= status.color %>"></span>
<span class="status-status"><%= status.name %></span>
<span class="level-name">status</span>
</div>
</div> </div>
<div class="priority-data <% if (editable) { %>clickable<% } %>">
<span class="level" style="background-color:<%= priority.color %>"></span>
<span class="priority-status"><%= priority.name %></span>
<span class="level-name">priority</span>
</div>
<div class="status-data <% if (editable) { %>clickable<% } %>">
<span class="level" style="background-color:<%= status.color %>"></span>
<span class="status-status"><%= status.name %></span>
<span class="level-name">status</span>
</div>
</div>
""") """)
selectionSeverityTemplate = _.template(""" selectionSeverityTemplate = _.template("""
<ul class="popover pop-severity"> <ul class="popover pop-severity">
<% _.each(severities, function(severity) { %> <% _.each(severities, function(severity) { %>
<li><a href="" class="severity" title="<%- severity.name %>" <li><a href="" class="severity" title="<%- severity.name %>"
data-severity-id="<%- severity.id %>"><%- severity.name %></a></li> data-severity-id="<%- severity.id %>"><%- severity.name %></a></li>
<% }); %> <% }); %>
</ul> </ul>
""") """)
selectionPriorityTemplate = _.template(""" selectionPriorityTemplate = _.template("""
<ul class="popover pop-priority"> <ul class="popover pop-priority">
<% _.each(priorities, function(priority) { %> <% _.each(priorities, function(priority) { %>
<li><a href="" class="priority" title="<%- priority.name %>" <li><a href="" class="priority" title="<%- priority.name %>"
data-priority-id="<%- priority.id %>"><%- priority.name %></a></li> data-priority-id="<%- priority.id %>"><%- priority.name %></a></li>
<% }); %> <% }); %>
</ul> </ul>
""") """)
selectionStatusTemplate = _.template(""" selectionStatusTemplate = _.template("""
<ul class="popover pop-status"> <ul class="popover pop-status">
<% _.each(statuses, function(status) { %> <% _.each(statuses, function(status) { %>
<li><a href="" class="status" title="<%- status.name %>" <li><a href="" class="status" title="<%- status.name %>"
data-status-id="<%- status.id %>"><%- status.name %></a></li> data-status-id="<%- status.id %>"><%- status.name %></a></li>
<% }); %> <% }); %>
</ul> </ul>
""") """)
link = ($scope, $el, $attrs, $model) -> link = ($scope, $el, $attrs, $model) ->
@ -541,7 +400,7 @@ module.directive("tgIssueStatus", IssueStatusDirective)
## Comment directive ## Comment directive
############################################################################# #############################################################################
CommentDirective = () -> CommentDirective = ->
link = ($scope, $el, $attrs, $model) -> link = ($scope, $el, $attrs, $model) ->
$el.on "click", ".activity-title", (event) -> $el.on "click", ".activity-title", (event) ->
event.preventDefault() event.preventDefault()