diff --git a/CHANGELOG.md b/CHANGELOG.md index c0c1b890..2434d416 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog # +## 1.1.0 (2014-10-19) + +### Features +- Promote an issue to a user story + + ## 1.0.0 (2014-10-07) ### Misc diff --git a/app/coffee/modules/common/confirm.coffee b/app/coffee/modules/common/confirm.coffee index a0da50ac..8834066e 100644 --- a/app/coffee/modules/common/confirm.coffee +++ b/app/coffee/modules/common/confirm.coffee @@ -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 diff --git a/app/coffee/modules/issues/detail.coffee b/app/coffee/modules/issues/detail.coffee index 2d9ae266..78c19e90 100644 --- a/app/coffee/modules/issues/detail.coffee +++ b/app/coffee/modules/issues/detail.coffee @@ -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(""" + + Promote to User Story + + """) # 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]) diff --git a/app/partials/issues-detail-edit.jade b/app/partials/issues-detail-edit.jade index 32e2aca0..4bcc146b 100644 --- a/app/partials/issues-detail-edit.jade +++ b/app/partials/issues-detail-edit.jade @@ -37,7 +37,6 @@ block content section.watchers(tg-watchers, ng-model="issue", editable="true") section.us-detail-settings - a.button.button-green.clickable() Promote to User Story a.button.button-gray.clickable(title="Click to block the issue", ng-show="!issue.is_blocked", ng-click="ctrl.block()") Block a.button.button-red(title="Click to delete the issue", tg-check-permission="delete_issue", ng-click="ctrl.delete()", href="") Delete diff --git a/app/partials/issues-detail.jade b/app/partials/issues-detail.jade index dfd6acc3..15075c3a 100644 --- a/app/partials/issues-detail.jade +++ b/app/partials/issues-detail.jade @@ -17,9 +17,18 @@ block content h2.us-title-text span.us-number(tg-bo-ref="issue.ref") span.us-name(ng-bind="issue.subject") + + p.us-related-task(ng-if="issue.generated_user_stories") This issue has been promoted to US: + a(ng-repeat="us in issue.generated_user_stories", + tg-check-permission="view_us", href="", + tg-bo-title="'#' + us.ref + ' ' + us.subject", + tg-nav="project-userstories-detail:project=project.slug, ref=us.ref") + span(tg-bo-ref="us.ref") + p.block-desc-container(ng-show="issue.is_blocked") span.block-description-title Blocked span.block-description(tg-bind-html="issue.blocked_note || 'This issue is blocked'") + div.issue-nav a.icon.icon-arrow-left(ng-show="previousUrl",href="{{ previousUrl }}", title="previous issue") a.icon.icon-arrow-right(ng-show="nextUrl", href="{{ nextUrl }}", title="next issue") @@ -35,3 +44,6 @@ block content section.us-status(tg-issue-status, ng-model="issue") section.us-assigned-to(tg-assigned-to, ng-model="issue") section.watchers(tg-watchers, ng-model="issue") + + section.us-detail-settings + tg-promote-issue-to-us-button(ng-model="issue") diff --git a/app/partials/issues.jade b/app/partials/issues.jade index 4b3552d7..a233c230 100644 --- a/app/partials/issues.jade +++ b/app/partials/issues.jade @@ -15,7 +15,7 @@ block content include views/modules/list-filters include views/modules/issues-table - // Paginator is rended using js. + // Paginator is rendered using js. div.paginator.issues-paginator div.lightbox.lightbox-select-user(tg-lb-assignedto) diff --git a/app/partials/us-detail.jade b/app/partials/us-detail.jade index 235021ea..2553c7f4 100644 --- a/app/partials/us-detail.jade +++ b/app/partials/us-detail.jade @@ -26,6 +26,12 @@ block content span.us-number(tg-bo-ref="us.ref") span.us-name(ng-bind="us.subject") + p.us-related-task(ng-if="us.origin_issue") This US has been promoted from Issue + a(tg-check-permission="view_us", href="", title="Go to issue", + tg-nav="project-issues-detail:project=project.slug, ref=us.origin_issue.ref" + tg-bo-title="'#' + us.origin_issue.ref + ' ' + us.origin_issue.subject") + span(tg-bo-ref="us.origin_issue.ref") + p.block-desc-container(ng-show="us.is_blocked") span.block-description-title Blocked span.block-description(tg-bind-html="us.blocked_note || 'This user story is blocked'") diff --git a/app/styles/layout/us-detail.scss b/app/styles/layout/us-detail.scss index 85dae2a5..98bebef4 100644 --- a/app/styles/layout/us-detail.scss +++ b/app/styles/layout/us-detail.scss @@ -17,8 +17,16 @@ margin-bottom: .5rem; } .us-number, - .us-name { + .us-name, + .us-related-task { color: $white; + a { + @include transition(color .3s linear); + color: $white; + &:hover { + color: $red-light; + } + } } .unblock { @extend %bold; @@ -35,6 +43,9 @@ } } } + p { + margin-bottom: 0; + } .us-edit-name-inner { @include table-flex(); } @@ -68,16 +79,18 @@ margin-top: .5rem; a { @include transition(color .3s linear); - color: lighten($grayer, 30%); - margin-left: .2rem; + border-left: 1px solid $gray-light; + padding: 0 .2rem; &:hover { color: $green-taiga; } + &:first-child { + border: 0; + } } } .block-desc-container { @extend %small; - margin: 0 0 1.2rem; } .block-description-title { @extend %bold;