parent
7958774361
commit
22ec3ca70e
|
@ -50,12 +50,15 @@ class ConfirmService extends taiga.Service
|
|||
|
||||
el.off(".confirm-dialog")
|
||||
|
||||
ask: (title, subtitle, lightboxSelector=".lightbox_confirm-delete") ->
|
||||
ask: (title, subtitle, message=null, lightboxSelector=".lightbox_confirm-delete") ->
|
||||
el = angular.element(lightboxSelector)
|
||||
|
||||
# Render content
|
||||
el.find("h2.title").html(title)
|
||||
el.find("span.subtitle").html(subtitle)
|
||||
if message
|
||||
el.find("span.delete-question").html(message)
|
||||
|
||||
defered = @q.defer()
|
||||
|
||||
# Assign event handlers
|
||||
|
|
|
@ -65,9 +65,12 @@ class IssueDetailController extends mixOf(taiga.Controller, taiga.PageMixin)
|
|||
@location.replace()
|
||||
return @q.reject(xhr)
|
||||
|
||||
@scope.$on("attachment:create", => @rootscope.$broadcast("history:reload"))
|
||||
@scope.$on("attachment:edit", => @rootscope.$broadcast("history:reload"))
|
||||
@scope.$on("attachment:delete", => @rootscope.$broadcast("history:reload"))
|
||||
@scope.$on "attachment:create", => @rootscope.$broadcast("history:reload")
|
||||
@scope.$on "attachment:edit", => @rootscope.$broadcast("history:reload")
|
||||
@scope.$on "attachment:delete", => @rootscope.$broadcast("history:reload")
|
||||
@scope.$on "promote-issue-to-us:success", =>
|
||||
@rootscope.$broadcast("history:reload")
|
||||
@.loadIssue()
|
||||
|
||||
loadProject: ->
|
||||
return @rs.projects.get(@scope.projectId).then (project) =>
|
||||
|
@ -362,3 +365,59 @@ IssueStatusDirective = () ->
|
|||
return {link:link, require:"ngModel"}
|
||||
|
||||
module.directive("tgIssueStatus", IssueStatusDirective)
|
||||
|
||||
|
||||
#############################################################################
|
||||
## Promote Issue to US button directive
|
||||
#############################################################################
|
||||
|
||||
PromoteIssueToUsButtonDirective = ($rootScope, $repo, $confirm) ->
|
||||
template = _.template("""
|
||||
<a class="button button-gray clickable" tg-check-permission="add_us">
|
||||
Promote to User Story
|
||||
</a>
|
||||
""") # TODO: i18n
|
||||
|
||||
link = ($scope, $el, $attrs, $model) ->
|
||||
$el.on "click", "a", (event) ->
|
||||
event.preventDefault()
|
||||
issue = $model.$modelValue
|
||||
|
||||
title = "Promote this issue to a new user story" # TODO: i18n
|
||||
message = "Are you sure you want to create a new US from this Issue?" # TODO: i18n
|
||||
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
|
||||
}
|
||||
|
||||
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()
|
||||
|
||||
return {
|
||||
restrict: "AE"
|
||||
require: "ngModel"
|
||||
template: template
|
||||
link: link
|
||||
}
|
||||
|
||||
module.directive("tgPromoteIssueToUsButton", ["$rootScope", "$tgRepo", "$tgConfirm",
|
||||
PromoteIssueToUsButtonDirective])
|
||||
|
|
|
@ -44,8 +44,4 @@ block content
|
|||
section.watchers(tg-watchers, ng-model="issue")
|
||||
|
||||
section.us-detail-settings
|
||||
a.button.button-gray.clickable(tg-check-permission="add_us",
|
||||
ng-click="ctrl.promoteToUs()", href="") Promote to User Story
|
||||
|
||||
div.lightbox.lightbox-generic-form.lb-create-edit-userstory(tg-lb-create-edit-userstory)
|
||||
include views/modules/lightbox-us-create-edit
|
||||
tg-promote-issue-to-us-button(ng-model="issue")
|
||||
|
|
Loading…
Reference in New Issue