diff --git a/app/coffee/modules/tasks/detail.coffee b/app/coffee/modules/tasks/detail.coffee index 9abb3640..ee9e58d6 100644 --- a/app/coffee/modules/tasks/detail.coffee +++ b/app/coffee/modules/tasks/detail.coffee @@ -249,6 +249,131 @@ TaskStatusDirective = () -> module.directive("tgTaskStatus", TaskStatusDirective) + +############################################################################# +## Task status display directive +############################################################################# + +TaskStatusDisplayDirective = -> + # Display if a Task is open or closed and its taskboard status. + # + # Example: + # tg-task-status-display(ng-model="task") + # + # Requirements: + # - Task object (ng-model) + # - scope.statusById object + + template = _.template(""" + + <% if (status.is_closed) { %> + Closed + <% } else { %> + Open + <% } %> + + + <%= status.name %> + + """) # TODO: i18n + + link = ($scope, $el, $attrs) -> + render = (task) -> + html = template({ + status: $scope.statusById[task.status] + }) + $el.html(html) + + $scope.$watch $attrs.ngModel, (task) -> + render(task) if task? + + $scope.$on "$destroy", -> + $el.off() + + return { + link: link + restrict: "EA" + require: "ngModel" + } + +module.directive("tgTaskStatusDisplay", TaskStatusDisplayDirective) + + +############################################################################# +## Task status button directive +############################################################################# + +TaskStatusButtonDirective = ($rootScope, $repo) -> + # Display the status of Task and you can edit it. + # + # Example: + # tg-task-status-button(ng-model="task") + # + # Requirements: + # - Task object (ng-model) + # - scope.statusById object + + template = _.template(""" +
+ + <%= status.name %> + + status + + +
+ """) #TODO: i18n + + link = ($scope, $el, $attrs, $model) -> + render = (task) => + status = $scope.statusById[task.status] + + html = template({ + status: status + statuses: $scope.statusList + }) + $el.html(html) + + $el.on "click", ".status-data", (event) -> + event.preventDefault() + event.stopPropagation() + + $el.find(".pop-status").popover().open() + + $el.on "click", ".status", (event) -> + event.preventDefault() + event.stopPropagation() + target = angular.element(event.currentTarget) + + $.fn.popover().closeAll() + + us = $model.$modelValue.clone() + us.status = target.data("status-id") + + $model.$setViewValue(us) + $repo.save($model.$modelValue).then -> + $rootScope.$broadcast("history:reload") + + $scope.$watch $attrs.ngModel, (task) -> + render(task) if task + + $scope.$on "$destroy", -> + $el.off() + + return { + link: link + restrict: "EA" + require: "ngModel" + } + +module.directive("tgTaskStatusButton", ["$rootScope", "$tgRepo", TaskStatusButtonDirective]) + + TaskIsIocaineButtonDirective = ($rootscope, $tgrepo) -> template = _.template("""
diff --git a/app/partials/task-detail.jade b/app/partials/task-detail.jade index d961d7cb..351d664f 100644 --- a/app/partials/task-detail.jade +++ b/app/partials/task-detail.jade @@ -46,9 +46,15 @@ block content tg-history(ng-model="task", type="task") sidebar.menu-secondary.sidebar - section.us-status(tg-task-status, ng-model="task") + section.us-status + h1(tg-task-status-display, ng-model="task") + tg-created-by-display.us-created-by(ng-model="task") + tg-task-status-button.issue-data(ng-model="task") + section.us-assigned-to(tg-assigned-to, ng-model="task") + section.watchers(tg-watchers, ng-model="task") + section.us-detail-settings fieldset(tg-task-is-iocaine-button, ng-model="task") div(tg-block-button, ng-model="task")