diff --git a/app/coffee/app.coffee b/app/coffee/app.coffee index 79546507..20ffaf84 100644 --- a/app/coffee/app.coffee +++ b/app/coffee/app.coffee @@ -91,6 +91,7 @@ modules = [ "taigaIssues", "taigaSearch", "taigaAdmin", + "taigaLightboxes", # Vendor modules "ngRoute", diff --git a/app/coffee/modules/issues/detail.coffee b/app/coffee/modules/issues/detail.coffee index d0d3160f..339a1915 100644 --- a/app/coffee/modules/issues/detail.coffee +++ b/app/coffee/modules/issues/detail.coffee @@ -86,6 +86,12 @@ class IssueDetailController extends mixOf(taiga.Controller, taiga.PageMixin) .then(=> @.loadUsersAndRoles()) .then(=> @.loadIssue()) + block: -> + @rootscope.$broadcast("block", @scope.issue) + + unblock: -> + @rootscope.$broadcast("unblock", @scope.issue) + module.controller("IssueDetailController", IssueDetailController) diff --git a/app/coffee/modules/lightboxes.coffee b/app/coffee/modules/lightboxes.coffee new file mode 100644 index 00000000..5202d677 --- /dev/null +++ b/app/coffee/modules/lightboxes.coffee @@ -0,0 +1,55 @@ +### +# Copyright (C) 2014 Andrey Antukh +# Copyright (C) 2014 Jesús Espino Garcia +# Copyright (C) 2014 David Barragán Merino +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +# File: modules/lightboxes.coffee +### + +module = angular.module("taigaLightboxes", []) + + +BlockDirective = () -> + link = ($scope, $el, $attrs, $model) -> + title = $attrs.title + $el.find("h2.title").text(title) + $scope.$on "block", -> + $el.removeClass("hidden") + + $scope.$on "unblock", -> + $model.$modelValue.is_blocked = false + $model.$modelValue.blocked_note_html = "" + + $scope.$on "$destroy", -> + $el.off() + + $el.on "click", ".close", (event) -> + event.preventDefault() + $el.addClass("hidden") + + $el.on "click", ".button-green", (event) -> + event.preventDefault() + target = angular.element(event.currentTarget) + + $scope.$apply -> + $model.$modelValue.is_blocked = true + $model.$modelValue.blocked_note_html = $el.find(".reason").val() + + $el.addClass("hidden") + + return {link:link, require:"ngModel"} + +module.directive("tgLbBlock", BlockDirective) diff --git a/app/partials/issues-detail-edit.jade b/app/partials/issues-detail-edit.jade index a3ef9cc2..8d1bb4f3 100644 --- a/app/partials/issues-detail-edit.jade +++ b/app/partials/issues-detail-edit.jade @@ -15,11 +15,11 @@ block content div.us-title input(type="text", ng-model="issue.subject") - // div.blocked-warning - // span.icon.icon-warning - // p.blocked Blocked! - // p We need Pilar to make a prototype out of this or we are not sure - // a.button.button-red.button-block(href="", title="Unblock US") Unblock + div.blocked-warning(ng-hide="!issue.is_blocked") + span.icon.icon-warning + p.blocked Blocked! + p(tg-bind-html="issue.blocked_note_html") + a.button.button-red.button-block.unblock(ng-click="ctrl.unblock()", href="", title="Unblock US") Unblock div.user-story-tags(tg-tag-line, editable="true", ng-model="issue.tags") @@ -54,13 +54,11 @@ block content //fieldset // label.clickable.button.button-green(for="team-requirement", ng-class="{true:'active', false:''}[issue.team_requirement]") Team requirement // input(ng-model="issue.team_requirement", type="checkbox", id="team-requirement", name="team-requirement") - fieldset - label.clickable.button.button-gray(for="blocked", ng-class="issue.is_blocked ? 'active' : ''") Block - input(ng-model="issue.is_blocked", type="checkbox", id="blocked", name="blocked") + a.button.button-gray.clickable(ng-hide="issue.is_blocked", ng-click="ctrl.block()") Block a.button.button-red(href="") Delete - div.lightbox.lightbox_block.hidden + div.lightbox.lightbox_block.hidden(tg-lb-block, title="Blocking issue", ng-model="issue") include views/modules/lightbox_block div.lightbox.lightbox_select_user.hidden(tg-lb-add-assigned-to) diff --git a/app/partials/issues-detail.jade b/app/partials/issues-detail.jade index 91d48a24..1f68f84f 100644 --- a/app/partials/issues-detail.jade +++ b/app/partials/issues-detail.jade @@ -20,11 +20,10 @@ block content a.icon.icon-arrow-left(href="", title="next issue") a.icon.icon-arrow-right(href="", title="previous issue") - // div.blocked-warning - // span.icon.icon-warning - // p.blocked Blocked! - // p We need Pilar to make a prototype out of this or we are not sure - // a.button.button-red.button-block(href="", title="Unblock US") Unblock + div.blocked-warning(ng-hide="!issue.is_blocked") + span.icon.icon-warning + p.blocked Blocked! + p(tg-bind-html="issue.blocked_note_html") div.user-story-tags(tg-tag-line, ng-model="issue.tags") @@ -53,7 +52,6 @@ block content //TODO: remove commented from issues-detail when copied to user-story-detail //span.button.button-gray Client requirement //span.button.button-gray Team requirement - span.button.button-gray Block div.lightbox.lightbox_block.hidden include views/modules/lightbox_block diff --git a/app/partials/views/modules/lightbox_block.jade b/app/partials/views/modules/lightbox_block.jade index 4dfe6569..bc3df2e6 100644 --- a/app/partials/views/modules/lightbox_block.jade +++ b/app/partials/views/modules/lightbox_block.jade @@ -1,8 +1,9 @@ a.close(href="", title="close") span.icon.icon-delete form - h2.title Story blocked + h2.title fieldset - textarea(placeholder="Please explain the reason") + textarea.reason(placeholder="Please explain the reason") + a.button.button-green(href="") span Save