From afbab5d96609dca851312fded419df76ea1d91ac Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 23 Jul 2014 13:10:46 +0200 Subject: [PATCH] Other cosmetic fixes. --- app/coffee/modules/issues/detail.coffee | 237 +++++------------------- 1 file changed, 48 insertions(+), 189 deletions(-) diff --git a/app/coffee/modules/issues/detail.coffee b/app/coffee/modules/issues/detail.coffee index 77a7480b..9270ed1e 100644 --- a/app/coffee/modules/issues/detail.coffee +++ b/app/coffee/modules/issues/detail.coffee @@ -123,10 +123,9 @@ class IssueDetailController extends mixOf(taiga.Controller, taiga.PageMixin) buildChangesText: (comment) -> size = @.countChanges(comment) - #TODO: i18n + # TODO: i18n if size == 1 return "Made #{size} change" - return "Made #{size} changes" block: -> @@ -136,7 +135,7 @@ class IssueDetailController extends mixOf(taiga.Controller, taiga.PageMixin) @rootscope.$broadcast("unblock", @scope.issue) delete: -> - #TODO: i18n + # TODO: i18n title = "Delete Issue" subtitle = @scope.issue.subject @@ -261,205 +260,65 @@ TagLineDirective = ($log) -> module.directive("tgTagLine", ["$log", TagLineDirective]) -############################################################################# -## Watchers directive -############################################################################# - -WatchersDirective = ($rootscope, $confirm) -> - #TODO: i18n - template = _.template(""" -
- watchers - <% if (editable) { %> - - - <% } %> -
- <% _.each(watchers, function(watcher) { %> -
-
- - <%= watcher.full_name_display %> - -
-
- - <%= watcher.full_name_display %> - - <% if (editable) { %> - - <% } %> -
-
- <% }); %> - """) - - 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) { %> -
- <%= assignedTo.full_name_display %> -
- <% } %> -
- Assigned to - - <% if (assignedTo) { %> - <%= assignedTo.full_name_display %> - <% } else { %> - Not assigned - <% } %> - <% if (editable) { %> - - <% } %> - - <% if (editable && assignedTo!==null) { %> - - <% } %> -
- """) - - 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 ############################################################################# IssueStatusDirective = () -> - #TODO: i18n + # TODO: i18n template = _.template(""" -

- - <% if (status.is_closed) { %> - Closed - <% } else { %> - Open - <% } %> - - <%= status.name %> -

-
-
- - <%= severity.name %> - severity -
-
- - <%= priority.name %> - priority -
-
- - <%= status.name %> - status -
+

+ + <% if (status.is_closed) { %> + Closed + <% } else { %> + Open + <% } %> + + <%= status.name %> +

+
+
+ + <%= severity.name %> + severity
+
+ + <%= priority.name %> + priority +
+
+ + <%= status.name %> + status +
+
""") selectionSeverityTemplate = _.template(""" - + """) selectionPriorityTemplate = _.template(""" - + """) selectionStatusTemplate = _.template(""" - + """) link = ($scope, $el, $attrs, $model) -> @@ -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()