Refactor tg-us-status directive: 👯 refactor of a refactor 👯

stable
David Barragán Merino 2014-10-14 23:16:21 +02:00
parent c08f972d83
commit d41b259fbd
3 changed files with 22 additions and 10 deletions

View File

@ -114,7 +114,8 @@ CreatedByDisplayDirective = ->
# div.us-created-by(tg-created-by-display, ng-model="us") # div.us-created-by(tg-created-by-display, ng-model="us")
# #
# Requirements: # Requirements:
# - model object must have the attributes 'created_date' and 'owner' # - model object must have the attributes 'created_date' and
# 'owner'(ng-model)
# - scope.usersById object is required. # - scope.usersById object is required.
template = _.template(""" template = _.template("""
@ -142,7 +143,11 @@ CreatedByDisplayDirective = ->
$scope.$on "$destroy", -> $scope.$on "$destroy", ->
$el.off() $el.off()
return {link:link, require:"ngModel"} return {
link: link
restrict: "EA"
require: "ngModel"
}
module.directive("tgCreatedByDisplay", CreatedByDisplayDirective) module.directive("tgCreatedByDisplay", CreatedByDisplayDirective)

View File

@ -372,10 +372,10 @@ UsStatusDisplayDirective = ->
# Display if a US is open or closed and its kanban status. # Display if a US is open or closed and its kanban status.
# #
# Example: # Example:
# h1(tg-us-status-display, ng-model="us") # tg-us-status-display(ng-model="us")
# #
# Requirements: # Requirements:
# - US object # - US object (ng-model)
# - scope.statusById object # - scope.statusById object
template = _.template(""" template = _.template("""
@ -405,7 +405,11 @@ UsStatusDisplayDirective = ->
$scope.$on "$destroy", -> $scope.$on "$destroy", ->
$el.off() $el.off()
return {link:link, require:"ngModel"} return {
link: link
restrict: "EA"
require: "ngModel"
}
module.directive("tgUsStatusDisplay", UsStatusDisplayDirective) module.directive("tgUsStatusDisplay", UsStatusDisplayDirective)
@ -418,10 +422,10 @@ UsTasksProgressDisplayDirective = ->
# Display a progress bar with the stats of completed tasks. # Display a progress bar with the stats of completed tasks.
# #
# Example: # Example:
# div.us-detail-progress-bar(tg-us-tasks-progress-display, ng-model="tasks") # tg-us-tasks-progress-display(ng-model="tasks")
# #
# Requirements: # Requirements:
# - Task object list # - Task object list (ng-model)
# - scope.taskStatusById object # - scope.taskStatusById object
template = _.template(""" template = _.template("""
@ -451,7 +455,11 @@ UsTasksProgressDisplayDirective = ->
$scope.$on "$destroy", -> $scope.$on "$destroy", ->
$el.off() $el.off()
return {link:link, require:"ngModel"} return {
link: link
restrict: "EA"
require: "ngModel"
}
module.directive("tgUsTasksProgressDisplay", UsTasksProgressDisplayDirective) module.directive("tgUsTasksProgressDisplay", UsTasksProgressDisplayDirective)
@ -506,7 +514,6 @@ UsEstimationDirective = ($rootScope, $repo, $confirm) ->
saveAfterModify = $attrs.saveAfterModify or false saveAfterModify = $attrs.saveAfterModify or false
render = (us) -> render = (us) ->
console.log us.points
totalPoints = us.total_points or 0 totalPoints = us.total_points or 0
computableRoles = _.filter($scope.project.roles, "computable") computableRoles = _.filter($scope.project.roles, "computable")

View File

@ -53,7 +53,7 @@ block content
section.us-status section.us-status
h1(tg-us-status-display, ng-model="us") h1(tg-us-status-display, ng-model="us")
div.us-detail-progress-bar(tg-us-tasks-progress-display, ng-model="tasks") div.us-detail-progress-bar(tg-us-tasks-progress-display, ng-model="tasks")
div.us-created-by(tg-created-by-display, ng-model="us") tg-created-by-display.us-created-by(ng-model="us")
tg-us-estimation(ng-model="us", save-after-modify="true") tg-us-estimation(ng-model="us", save-after-modify="true")
tg-us-status-button.issue-data(ng-model="us") tg-us-status-button.issue-data(ng-model="us")