From 2ef0a6967904c9af1067f9431c3d394f63acc4e8 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 22 Jul 2014 12:34:00 +0200 Subject: [PATCH] Now implemented create/edit userstory from kanban. --- app/coffee/modules/common/lightboxes.coffee | 2 +- app/coffee/modules/kanban/main.coffee | 45 +++++++++++-------- app/coffee/modules/kanban/sortable.coffee | 3 ++ app/coffee/modules/taskboard/main.coffee | 16 +++++-- app/partials/kanban.jade | 3 ++ .../views/components/kanban-task.jade | 6 +-- app/partials/views/modules/kanban-table.jade | 6 ++- 7 files changed, 53 insertions(+), 28 deletions(-) diff --git a/app/coffee/modules/common/lightboxes.coffee b/app/coffee/modules/common/lightboxes.coffee index 998d6f34..eba36127 100644 --- a/app/coffee/modules/common/lightboxes.coffee +++ b/app/coffee/modules/common/lightboxes.coffee @@ -70,7 +70,7 @@ CreateEditUserstoryDirective = ($repo, $model, $rs, $rootScope) -> $scope.us = { project: $scope.projectId is_archived: false - status: $scope.project.default_us_status + status: statusId or $scope.project.default_us_status } isNew = true # Update texts for creation diff --git a/app/coffee/modules/kanban/main.coffee b/app/coffee/modules/kanban/main.coffee index f1bc4aad..dffe80b9 100644 --- a/app/coffee/modules/kanban/main.coffee +++ b/app/coffee/modules/kanban/main.coffee @@ -59,8 +59,8 @@ class KanbanController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi # @scope.$on("sprintform:create:success", @.loadProjectStats) # @scope.$on("sprintform:remove:success", @.loadSprints) # @scope.$on("sprintform:remove:success", @.loadProjectStats) - # @scope.$on("usform:new:success", @.loadUserstories) - # @scope.$on("usform:edit:success", @.loadUserstories) + @scope.$on("usform:new:success", @.onNewUserstory) + @scope.$on("usform:edit:success", @.onUserstoryEdited) @scope.$on("kanban:us:move", @.moveUs) # @scope.$on("sprint:us:moved", @.loadSprints) # @scope.$on("sprint:us:moved", @.loadProjectStats) @@ -157,25 +157,19 @@ class KanbanController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi return promise ## Template actions - # editUserStory: (us) -> - # @rootscope.$broadcast("usform:edit", us) + editUserStory: (us) -> + @rootscope.$broadcast("usform:edit", us) - # deleteUserStory: (us) -> - # #TODO: i18n - # title = "Delete User Story" - # subtitle = us.subject + addNewUs: (type, statusId) -> + switch type + when "standard" then @rootscope.$broadcast("usform:new", statusId) + when "bulk" then @rootscope.$broadcast("usform:bulk", statusId) - # @confirm.ask(title, subtitle).then => - # # We modify the userstories in scope so the user doesn't see the removed US for a while - # @scope.userstories = _.without(@scope.userstories, us); - # @filterVisibleUserstories() - # @.repo.remove(us).then => - # @.loadBacklog() + onNewUserstory: (ctx, us) -> + @scope.usByStatus[us.status].splice(0, 0, us) - # addNewUs: (type) -> - # switch type - # when "standard" then @rootscope.$broadcast("usform:new") - # when "bulk" then @rootscope.$broadcast("usform:bulk") + onUserstoryEdited: (ctx, us) -> + @.loadUserstories() module.controller("KanbanController", KanbanController) @@ -191,11 +185,24 @@ KanbanDirective = ($repo, $rootscope) -> module.directive("tgKanban", ["$tgRepo", "$rootScope", KanbanDirective]) + +############################################################################# +## Taskboard Task Directive +############################################################################# + +KanbanUserstoryDirective = -> + link = ($scope, $el, $attrs) -> + $el.disableSelection() + return {link:link} + + +module.directive("tgKanbanUserstory", KanbanUserstoryDirective) + + ############################################################################# ## Kanban User Directive ############################################################################# - KanbanUserDirective = ($log) -> template = _.template("""
diff --git a/app/coffee/modules/kanban/sortable.coffee b/app/coffee/modules/kanban/sortable.coffee index f1ecea6b..0248ec77 100644 --- a/app/coffee/modules/kanban/sortable.coffee +++ b/app/coffee/modules/kanban/sortable.coffee @@ -41,6 +41,9 @@ KanbanSortableDirective = ($repo, $rs, $rootscope) -> ######################### link = ($scope, $el, $attrs) -> + $el.css("height", "800px") + $el.closest(".kanban-table-body").css("height", "800px") + oldParentScope = null newParentScope = null itemEl = null diff --git a/app/coffee/modules/taskboard/main.coffee b/app/coffee/modules/taskboard/main.coffee index fcb3f0b6..f0aa99a3 100644 --- a/app/coffee/modules/taskboard/main.coffee +++ b/app/coffee/modules/taskboard/main.coffee @@ -185,6 +185,12 @@ TaskboardDirective = ($rootscope) -> return {link: link} +module.directive("tgTaskboard", ["$rootScope", TaskboardDirective]) + + +############################################################################# +## Taskboard Task Directive +############################################################################# TaskboardTaskDirective = -> link = ($scope, $el, $attrs) -> @@ -198,7 +204,7 @@ module.directive("tgTaskboardTask", TaskboardTaskDirective) ############################################################################# -## Task Row Size Fixer Directive +## Taskboard Task Row Size Fixer Directive ############################################################################# TaskboardRowSizeFixer = -> @@ -210,6 +216,12 @@ TaskboardRowSizeFixer = -> return {link: link} +module.directive("tgTaskboardRowSizeFixer", TaskboardRowSizeFixer) + + +############################################################################# +## Taskboard us points Directive +############################################################################# TaskboardUsPointsDirective = ($repo, $confirm) -> # TODO: i18n @@ -305,6 +317,4 @@ TaskboardUsPointsDirective = ($repo, $confirm) -> return {link: link} -module.directive("tgTaskboard", ["$rootScope", TaskboardDirective]) -module.directive("tgTaskboardRowSizeFixer", TaskboardRowSizeFixer) module.directive("tgTaskboardUsPoints", ["$tgRepo", "$tgConfirm", TaskboardUsPointsDirective]) diff --git a/app/partials/kanban.jade b/app/partials/kanban.jade index 92b47194..67c75aa9 100644 --- a/app/partials/kanban.jade +++ b/app/partials/kanban.jade @@ -21,3 +21,6 @@ block content //-include views/modules/burndown //-include views/modules/list-filters-kanban include views/modules/kanban-table + + div.lightbox.lightbox_add-new-us.hidden(tg-lb-create-edit-userstory) + include views/modules/lightbox_add-new-us diff --git a/app/partials/views/components/kanban-task.jade b/app/partials/views/components/kanban-task.jade index ad42399b..4dff5e28 100644 --- a/app/partials/views/components/kanban-task.jade +++ b/app/partials/views/components/kanban-task.jade @@ -3,10 +3,10 @@ div.kanban-tagline div.kanban-task-inner p.task-text span.task-num(tg-bo-ref="us.ref") - a.task-name(href="", title="", tg-bo-html="us.subject") + a.task-name(href="", title="", tg-bind-html="us.subject") tg-kanban-user-avatar(model="us.assigned_to") - a.icon.icon-edit(href="", title="Edit", ng-click="ctrl.editTask(task)") + a.icon.icon-edit(href="", title="Edit", ng-click="ctrl.editUserStory(us)") a.icon.icon-drag-h(href="", title="Drag&Drop") - a.task-points(href="", title="task points", tg-bo-html="us.total_points") -- + a.task-points(href="", title="task points", tg-bind-html="us.total_points") -- diff --git a/app/partials/views/modules/kanban-table.jade b/app/partials/views/modules/kanban-table.jade index ccb2f234..9d84b916 100644 --- a/app/partials/views/modules/kanban-table.jade +++ b/app/partials/views/modules/kanban-table.jade @@ -3,11 +3,13 @@ div.kanban-table div.kanban-table-inner h2.task-colum_name(ng-repeat="s in usStatusList track by s.id") span(tg-bo-html="s.name") - a.icon.icon-plus(href="", title="Add New task") + a.icon.icon-plus(href="", title="Add New task", + ng-click="ctrl.addNewUs('standard', s.id)") div.kanban-table-body div.kanban-table-inner div.kanban-uses-box.task-column(ng-repeat="status in usStatusList track by status.id", tg-kanban-sortable) - div.kanban-task(ng-repeat="us in usByStatus[status.id] track by us.id") + div.kanban-task(ng-repeat="us in usByStatus[status.id] track by us.id", + tg-kanban-userstory) include ../components/kanban-task