@@ -436,6 +436,24 @@ HistoryDirective = ($log, $loading) ->
html = renderHistory(changes, totalChanges)
$el.find(".changes-list").html(html)
+ save = $qqueue.bindAdd (target) =>
+ $scope.$broadcast("markdown-editor:submit")
+
+ $el.find(".comment-list").addClass("activeanimation")
+
+ onSuccess = ->
+ $ctrl.loadHistory(type, objectId).finally ->
+ $loading.finish(target)
+
+ onError = ->
+ $loading.finish(target)
+ $confirm.notify("error")
+
+ model = $scope.$eval($attrs.ngModel)
+ $loading.start(target)
+
+ $ctrl.repo.save(model).then(onSuccess, onError)
+
# Watchers
$scope.$watch("comments", renderComments)
@@ -447,22 +465,10 @@ HistoryDirective = ($log, $loading) ->
$el.on "click", ".add-comment a.button-green", debounce 2000, (event) ->
event.preventDefault()
- $scope.$broadcast("markdown-editor:submit")
target = angular.element(event.currentTarget)
- $el.find(".comment-list").addClass("activeanimation")
- onSuccess = ->
- $ctrl.loadHistory(type, objectId).finally ->
- $loading.finish(target)
-
- onError = ->
- $loading.finish(target)
- $confirm.notify("error")
-
- model = $scope.$eval($attrs.ngModel)
- $loading.start(target)
- $ctrl.repo.save(model).then(onSuccess, onError)
+ save(target)
$el.on "click", ".show-more", (event) ->
event.preventDefault()
@@ -526,4 +532,4 @@ HistoryDirective = ($log, $loading) ->
}
-module.directive("tgHistory", ["$log", "$tgLoading", HistoryDirective])
+module.directive("tgHistory", ["$log", "$tgLoading", "$tgQqueue", HistoryDirective])
diff --git a/app/coffee/modules/common/lightboxes.coffee b/app/coffee/modules/common/lightboxes.coffee
index fd07cb7a..685a0c91 100644
--- a/app/coffee/modules/common/lightboxes.coffee
+++ b/app/coffee/modules/common/lightboxes.coffee
@@ -126,19 +126,11 @@ module.directive("lightbox", ["lightboxService", LightboxDirective])
# Issue/Userstory blocking message lightbox directive.
-BlockLightboxDirective = ($rootscope, $tgrepo, $confirm, lightboxService, $loading) ->
+BlockLightboxDirective = ($rootscope, $tgrepo, $confirm, lightboxService, $loading, $qqueue) ->
link = ($scope, $el, $attrs, $model) ->
$el.find("h2.title").text($attrs.title)
- $scope.$on "block", ->
- $el.find(".reason").val($model.$modelValue.blocked_note)
- lightboxService.open($el)
-
- $scope.$on "unblock", (event, model, finishCallback) ->
- item = $model.$modelValue.clone()
- item.is_blocked = false
- item.blocked_note = ""
-
+ unblock = $qqueue.bindAdd (item, finishCallback) =>
promise = $tgrepo.save(item)
promise.then ->
$confirm.notify("success")
@@ -154,15 +146,9 @@ BlockLightboxDirective = ($rootscope, $tgrepo, $confirm, lightboxService, $loadi
promise.finally ->
finishCallback()
- $scope.$on "$destroy", ->
- $el.off()
+ return promise
- $el.on "click", ".button-green", (event) ->
- event.preventDefault()
-
- item = $model.$modelValue.clone()
- item.is_blocked = true
- item.blocked_note = $el.find(".reason").val()
+ block = $qqueue.bindAdd (item) =>
$model.$setViewValue(item)
$loading.start($el.find(".button-green"))
@@ -181,13 +167,36 @@ BlockLightboxDirective = ($rootscope, $tgrepo, $confirm, lightboxService, $loadi
$loading.finish($el.find(".button-green"))
lightboxService.close($el)
+ $scope.$on "block", ->
+ $el.find(".reason").val($model.$modelValue.blocked_note)
+ lightboxService.open($el)
+
+ $scope.$on "unblock", (event, model, finishCallback) =>
+ item = $model.$modelValue.clone()
+ item.is_blocked = false
+ item.blocked_note = ""
+
+ unblock(item, finishCallback)
+
+ $scope.$on "$destroy", ->
+ $el.off()
+
+ $el.on "click", ".button-green", (event) ->
+ event.preventDefault()
+
+ item = $model.$modelValue.clone()
+ item.is_blocked = true
+ item.blocked_note = $el.find(".reason").val()
+
+ block(item)
+
return {
templateUrl: "/partials/views/modules/lightbox-block.html"
link: link
require: "ngModel"
}
-module.directive("tgLbBlock", ["$rootScope", "$tgRepo", "$tgConfirm", "lightboxService", "$tgLoading", BlockLightboxDirective])
+module.directive("tgLbBlock", ["$rootScope", "$tgRepo", "$tgConfirm", "lightboxService", "$tgLoading", "$tgQqueue", BlockLightboxDirective])
#############################################################################
diff --git a/app/coffee/modules/common/tags.coffee b/app/coffee/modules/common/tags.coffee
index 3e910882..3a8e7fbf 100644
--- a/app/coffee/modules/common/tags.coffee
+++ b/app/coffee/modules/common/tags.coffee
@@ -228,7 +228,7 @@ module.directive("tgLbTagLine", ["$tgResources", LbTagLineDirective])
## TagLine Directive (for detail pages)
#############################################################################
-TagLineDirective = ($rootScope, $repo, $rs, $confirm) ->
+TagLineDirective = ($rootScope, $repo, $rs, $confirm, $qqueue) ->
ENTER_KEY = 13
ESC_KEY = 27
@@ -288,7 +288,7 @@ TagLineDirective = ($rootScope, $repo, $rs, $confirm) ->
$el.find("input").autocomplete("close")
## Aux methods
- addValue = (value) ->
+ addValue = $qqueue.bindAdd (value) ->
value = trim(value.toLowerCase())
return if value.length == 0
@@ -308,7 +308,7 @@ TagLineDirective = ($rootScope, $repo, $rs, $confirm) ->
$model.$setViewValue(model)
$repo.save(model).then(onSuccess, onError)
- deleteValue = (value) ->
+ deleteValue = $qqueue.bindAdd (value) ->
value = trim(value.toLowerCase())
return if value.length == 0
@@ -325,7 +325,8 @@ TagLineDirective = ($rootScope, $repo, $rs, $confirm) ->
$confirm.notify("error")
model.revert()
$model.$setViewValue(model)
- $repo.save(model).then(onSuccess, onError)
+
+ return $repo.save(model).then(onSuccess, onError)
saveInputTag = () ->
value = $el.find("input").val()
@@ -369,6 +370,7 @@ TagLineDirective = ($rootScope, $repo, $rs, $confirm) ->
target = angular.element(event.currentTarget)
value = target.siblings(".tag-name").text()
+
deleteValue(value)
bindOnce $scope, "project", (project) ->
@@ -415,4 +417,4 @@ TagLineDirective = ($rootScope, $repo, $rs, $confirm) ->
template: template
}
-module.directive("tgTagLine", ["$rootScope", "$tgRepo", "$tgResources", "$tgConfirm", TagLineDirective])
+module.directive("tgTagLine", ["$rootScope", "$tgRepo", "$tgResources", "$tgConfirm", "$tgQqueue", TagLineDirective])
diff --git a/app/coffee/modules/issues/detail.coffee b/app/coffee/modules/issues/detail.coffee
index cb5f7aa4..ff9f2456 100644
--- a/app/coffee/modules/issues/detail.coffee
+++ b/app/coffee/modules/issues/detail.coffee
@@ -195,7 +195,7 @@ module.directive("tgIssueStatusDisplay", IssueStatusDisplayDirective)
## Issue status button directive
#############################################################################
-IssueStatusButtonDirective = ($rootScope, $repo, $confirm, $loading) ->
+IssueStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue) ->
# Display the status of Issue and you can edit it.
#
# Example:
@@ -236,6 +236,21 @@ IssueStatusButtonDirective = ($rootScope, $repo, $confirm, $loading) ->
})
$el.html(html)
+ save = $qqueue.bindAdd (value, issue) =>
+ onSuccess = ->
+ $confirm.notify("success")
+ $rootScope.$broadcast("history:reload")
+ $loading.finish($el.find(".level-name"))
+ onError = ->
+ $confirm.notify("error")
+ issue.revert()
+ $model.$setViewValue(issue)
+ $loading.finish($el.find(".level-name"))
+
+ $loading.start($el.find(".level-name"))
+
+ $repo.save(value).then(onSuccess, onError)
+
$el.on "click", ".status-data", (event) ->
event.preventDefault()
event.stopPropagation()
@@ -256,20 +271,7 @@ IssueStatusButtonDirective = ($rootScope, $repo, $confirm, $loading) ->
issue.status = target.data("status-id")
$model.$setViewValue(issue)
- $scope.$apply()
-
- onSuccess = ->
- $confirm.notify("success")
- $rootScope.$broadcast("history:reload")
- $loading.finish($el.find(".level-name"))
- onError = ->
- $confirm.notify("error")
- issue.revert()
- $model.$setViewValue(issue)
- $loading.finish($el.find(".level-name"))
-
- $loading.start($el.find(".level-name"))
- $repo.save($model.$modelValue).then(onSuccess, onError)
+ save($model.$modelValue, issue)
$scope.$watch $attrs.ngModel, (issue) ->
render(issue) if issue
@@ -283,13 +285,13 @@ IssueStatusButtonDirective = ($rootScope, $repo, $confirm, $loading) ->
require: "ngModel"
}
-module.directive("tgIssueStatusButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", IssueStatusButtonDirective])
+module.directive("tgIssueStatusButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQqueue", IssueStatusButtonDirective])
#############################################################################
## Issue type button directive
#############################################################################
-IssueTypeButtonDirective = ($rootScope, $repo, $confirm, $loading) ->
+IssueTypeButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue) ->
# Display the type of Issue and you can edit it.
#
# Example:
@@ -330,6 +332,26 @@ IssueTypeButtonDirective = ($rootScope, $repo, $confirm, $loading) ->
})
$el.html(html)
+ save = $qqueue.bindAdd (type) =>
+ $.fn.popover().closeAll()
+ issue = $model.$modelValue.clone()
+ issue.type = type
+
+ $model.$setViewValue(issue)
+
+ onSuccess = ->
+ $confirm.notify("success")
+ $rootScope.$broadcast("history:reload")
+ $loading.finish($el.find(".level-name"))
+ onError = ->
+ $confirm.notify("error")
+ issue.revert()
+ $model.$setViewValue(issue)
+ $loading.finish($el.find(".level-name"))
+ $loading.start($el.find(".level-name"))
+
+ $repo.save($model.$modelValue).then(onSuccess, onError)
+
$el.on "click", ".type-data", (event) ->
event.preventDefault()
event.stopPropagation()
@@ -343,26 +365,8 @@ IssueTypeButtonDirective = ($rootScope, $repo, $confirm, $loading) ->
return if not isEditable()
target = angular.element(event.currentTarget)
-
- $.fn.popover().closeAll()
-
- issue = $model.$modelValue.clone()
- issue.type = target.data("type-id")
- $model.$setViewValue(issue)
-
- $scope.$apply()
-
- onSuccess = ->
- $confirm.notify("success")
- $rootScope.$broadcast("history:reload")
- $loading.finish($el.find(".level-name"))
- onError = ->
- $confirm.notify("error")
- issue.revert()
- $model.$setViewValue(issue)
- $loading.finish($el.find(".level-name"))
- $loading.start($el.find(".level-name"))
- $repo.save($model.$modelValue).then(onSuccess, onError)
+ type = target.data("type-id")
+ save(type)
$scope.$watch $attrs.ngModel, (issue) ->
render(issue) if issue
@@ -376,14 +380,14 @@ IssueTypeButtonDirective = ($rootScope, $repo, $confirm, $loading) ->
require: "ngModel"
}
-module.directive("tgIssueTypeButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", IssueTypeButtonDirective])
+module.directive("tgIssueTypeButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQqueue", IssueTypeButtonDirective])
#############################################################################
## Issue severity button directive
#############################################################################
-IssueSeverityButtonDirective = ($rootScope, $repo, $confirm, $loading) ->
+IssueSeverityButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue) ->
# Display the severity of Issue and you can edit it.
#
# Example:
@@ -424,6 +428,26 @@ IssueSeverityButtonDirective = ($rootScope, $repo, $confirm, $loading) ->
})
$el.html(html)
+ save = $qqueue.bindAdd (severity) =>
+ $.fn.popover().closeAll()
+
+ issue = $model.$modelValue.clone()
+ issue.severity = severity
+ $model.$setViewValue(issue)
+
+ onSuccess = ->
+ $confirm.notify("success")
+ $rootScope.$broadcast("history:reload")
+ $loading.finish($el.find(".level-name"))
+ onError = ->
+ $confirm.notify("error")
+ issue.revert()
+ $model.$setViewValue(issue)
+ $loading.finish($el.find(".level-name"))
+ $loading.start($el.find(".level-name"))
+
+ $repo.save($model.$modelValue).then(onSuccess, onError)
+
$el.on "click", ".severity-data", (event) ->
event.preventDefault()
event.stopPropagation()
@@ -437,26 +461,9 @@ IssueSeverityButtonDirective = ($rootScope, $repo, $confirm, $loading) ->
return if not isEditable()
target = angular.element(event.currentTarget)
+ severity = target.data("severity-id")
- $.fn.popover().closeAll()
-
- issue = $model.$modelValue.clone()
- issue.severity = target.data("severity-id")
- $model.$setViewValue(issue)
-
- $scope.$apply()
-
- onSuccess = ->
- $confirm.notify("success")
- $rootScope.$broadcast("history:reload")
- $loading.finish($el.find(".level-name"))
- onError = ->
- $confirm.notify("error")
- issue.revert()
- $model.$setViewValue(issue)
- $loading.finish($el.find(".level-name"))
- $loading.start($el.find(".level-name"))
- $repo.save($model.$modelValue).then(onSuccess, onError)
+ save(severity)
$scope.$watch $attrs.ngModel, (issue) ->
render(issue) if issue
@@ -470,14 +477,14 @@ IssueSeverityButtonDirective = ($rootScope, $repo, $confirm, $loading) ->
require: "ngModel"
}
-module.directive("tgIssueSeverityButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", IssueSeverityButtonDirective])
+module.directive("tgIssueSeverityButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQqueue", IssueSeverityButtonDirective])
#############################################################################
## Issue priority button directive
#############################################################################
-IssuePriorityButtonDirective = ($rootScope, $repo, $confirm, $loading) ->
+IssuePriorityButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue) ->
# Display the priority of Issue and you can edit it.
#
# Example:
@@ -518,6 +525,26 @@ IssuePriorityButtonDirective = ($rootScope, $repo, $confirm, $loading) ->
})
$el.html(html)
+ save = $qqueue.bindAdd (priority) =>
+ $.fn.popover().closeAll()
+
+ issue = $model.$modelValue.clone()
+ issue.priority = priority
+ $model.$setViewValue(issue)
+
+ onSuccess = ->
+ $confirm.notify("success")
+ $rootScope.$broadcast("history:reload")
+ $loading.finish($el.find(".level-name"))
+ onError = ->
+ $confirm.notify("error")
+ issue.revert()
+ $model.$setViewValue(issue)
+ $loading.finish($el.find(".level-name"))
+ $loading.start($el.find(".level-name"))
+
+ $repo.save($model.$modelValue).then(onSuccess, onError)
+
$el.on "click", ".priority-data", (event) ->
event.preventDefault()
event.stopPropagation()
@@ -531,26 +558,9 @@ IssuePriorityButtonDirective = ($rootScope, $repo, $confirm, $loading) ->
return if not isEditable()
target = angular.element(event.currentTarget)
+ priority = target.data("priority-id")
- $.fn.popover().closeAll()
-
- issue = $model.$modelValue.clone()
- issue.priority = target.data("priority-id")
- $model.$setViewValue(issue)
-
- $scope.$apply()
-
- onSuccess = ->
- $confirm.notify("success")
- $rootScope.$broadcast("history:reload")
- $loading.finish($el.find(".level-name"))
- onError = ->
- $confirm.notify("error")
- issue.revert()
- $model.$setViewValue(issue)
- $loading.finish($el.find(".level-name"))
- $loading.start($el.find(".level-name"))
- $repo.save($model.$modelValue).then(onSuccess, onError)
+ save(priority)
$scope.$watch $attrs.ngModel, (issue) ->
render(issue) if issue
@@ -564,14 +574,14 @@ IssuePriorityButtonDirective = ($rootScope, $repo, $confirm, $loading) ->
require: "ngModel"
}
-module.directive("tgIssuePriorityButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", IssuePriorityButtonDirective])
+module.directive("tgIssuePriorityButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQqueue", IssuePriorityButtonDirective])
#############################################################################
## Promote Issue to US button directive
#############################################################################
-PromoteIssueToUsButtonDirective = ($rootScope, $repo, $confirm) ->
+PromoteIssueToUsButtonDirective = ($rootScope, $repo, $confirm, $qqueue) ->
template = _.template("""
Promote to User Story
@@ -579,6 +589,30 @@ PromoteIssueToUsButtonDirective = ($rootScope, $repo, $confirm) ->
""") # TODO: i18n
link = ($scope, $el, $attrs, $model) ->
+
+ save = $qqueue.bindAdd (issue, finish) =>
+ data = {
+ generated_from_issue: issue.id
+ project: issue.project,
+ subject: issue.subject
+ description: issue.description
+ tags: issue.tags
+ is_blocked: issue.is_blocked
+ blocked_note: issue.blocked_note
+ }
+
+ onSuccess = ->
+ finish()
+ $confirm.notify("success")
+ $rootScope.$broadcast("promote-issue-to-us:success")
+
+ onError = ->
+ finish(false)
+ $confirm.notify("error")
+
+ $repo.create("userstories", data).then(onSuccess, onError)
+
+
$el.on "click", "a", (event) ->
event.preventDefault()
issue = $model.$modelValue
@@ -588,26 +622,8 @@ PromoteIssueToUsButtonDirective = ($rootScope, $repo, $confirm) ->
subtitle = issue.subject
$confirm.ask(title, subtitle, message).then (finish) =>
- data = {
- generated_from_issue: issue.id
- project: issue.project,
- subject: issue.subject
- description: issue.description
- tags: issue.tags
- is_blocked: issue.is_blocked
- blocked_note: issue.blocked_note
- }
+ save(issue, finish)
- onSuccess = ->
- finish()
- $confirm.notify("success")
- $rootScope.$broadcast("promote-issue-to-us:success")
-
- onError = ->
- finish(false)
- $confirm.notify("error")
-
- $repo.create("userstories", data).then(onSuccess, onError)
$scope.$on "$destroy", ->
$el.off()
@@ -619,5 +635,5 @@ PromoteIssueToUsButtonDirective = ($rootScope, $repo, $confirm) ->
link: link
}
-module.directive("tgPromoteIssueToUsButton", ["$rootScope", "$tgRepo", "$tgConfirm",
+module.directive("tgPromoteIssueToUsButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgQqueue",
PromoteIssueToUsButtonDirective])
diff --git a/app/coffee/modules/tasks/detail.coffee b/app/coffee/modules/tasks/detail.coffee
index 0dfef32a..0bbe2730 100644
--- a/app/coffee/modules/tasks/detail.coffee
+++ b/app/coffee/modules/tasks/detail.coffee
@@ -199,7 +199,7 @@ module.directive("tgTaskStatusDisplay", TaskStatusDisplayDirective)
## Task status button directive
#############################################################################
-TaskStatusButtonDirective = ($rootScope, $repo, $confirm, $loading) ->
+TaskStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue) ->
# Display the status of Task and you can edit it.
#
# Example:
@@ -240,6 +240,26 @@ TaskStatusButtonDirective = ($rootScope, $repo, $confirm, $loading) ->
})
$el.html(html)
+ save = $qqueue.bindAdd (status) =>
+ task = $model.$modelValue.clone()
+ task.status = status
+
+ $model.$setViewValue(task)
+
+ onSuccess = ->
+ $confirm.notify("success")
+ $rootScope.$broadcast("history:reload")
+ $loading.finish($el.find(".level-name"))
+
+ onError = ->
+ $confirm.notify("error")
+ task.revert()
+ $model.$setViewValue(task)
+ $loading.finish($el.find(".level-name"))
+
+ $loading.start($el.find(".level-name"))
+ $repo.save($model.$modelValue).then(onSuccess, onError)
+
$el.on "click", ".status-data", (event) ->
event.preventDefault()
event.stopPropagation()
@@ -256,25 +276,7 @@ TaskStatusButtonDirective = ($rootScope, $repo, $confirm, $loading) ->
$.fn.popover().closeAll()
- task = $model.$modelValue.clone()
- task.status = target.data("status-id")
- $model.$setViewValue(task)
-
- $scope.$apply()
-
- onSuccess = ->
- $confirm.notify("success")
- $rootScope.$broadcast("history:reload")
- $loading.finish($el.find(".level-name"))
-
- onError = ->
- $confirm.notify("error")
- task.revert()
- $model.$setViewValue(task)
- $loading.finish($el.find(".level-name"))
-
- $loading.start($el.find(".level-name"))
- $repo.save($model.$modelValue).then(onSuccess, onError)
+ save(target.data("status-id"))
$scope.$watch $attrs.ngModel, (task) ->
render(task) if task
@@ -288,11 +290,11 @@ TaskStatusButtonDirective = ($rootScope, $repo, $confirm, $loading) ->
require: "ngModel"
}
-module.directive("tgTaskStatusButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading",
+module.directive("tgTaskStatusButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQqueue",
TaskStatusButtonDirective])
-TaskIsIocaineButtonDirective = ($rootscope, $tgrepo, $confirm, $loading) ->
+TaskIsIocaineButtonDirective = ($rootscope, $tgrepo, $confirm, $loading, $qqueue) ->
template = _.template("""