diff --git a/app/coffee/modules/backlog/main.coffee b/app/coffee/modules/backlog/main.coffee index daafc857..16c53c66 100644 --- a/app/coffee/modules/backlog/main.coffee +++ b/app/coffee/modules/backlog/main.coffee @@ -335,8 +335,8 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F addNewUs: (type) -> switch type - when "standard" then @rootscope.$broadcast("usform:new", @scope.project.default_us_status) - when "bulk" then @rootscope.$broadcast("usform:bulk") + when "standard" then @rootscope.$broadcast("usform:new", @scope.projectId, @scope.project.default_us_status) + when "bulk" then @rootscope.$broadcast("usform:bulk", @scope.projectId, @scope.project.default_us_status) addNewSprint: () -> @rootscope.$broadcast("sprintform:create") diff --git a/app/coffee/modules/common/lightboxes.coffee b/app/coffee/modules/common/lightboxes.coffee index ecf97c58..41f8cd3a 100644 --- a/app/coffee/modules/common/lightboxes.coffee +++ b/app/coffee/modules/common/lightboxes.coffee @@ -72,11 +72,11 @@ CreateEditUserstoryDirective = ($repo, $model, $rs, $rootScope) -> link = ($scope, $el, attrs) -> isNew = true - $scope.$on "usform:new", (ctx, statusId) -> + $scope.$on "usform:new", (ctx, projectId, status) -> $scope.us = { - project: $scope.projectId + project: projectId + status: status is_archived: false - status: statusId or $scope.project.default_us_status } isNew = true # Update texts for creation @@ -113,7 +113,6 @@ CreateEditUserstoryDirective = ($repo, $model, $rs, $rootScope) -> $el.on "click", ".button-green", (event) -> event.preventDefault() - form = $el.find("form").checksley() if not form.validate() return @@ -166,11 +165,13 @@ module.directive("tgLbCreateEditUserstory", [ CreateBulkUserstoriesDirective = ($repo, $rs, $rootscope) -> link = ($scope, $el, attrs) -> - $scope.form = {data: ""} - - $scope.$on "usform:bulk", -> + $scope.$on "usform:bulk", (ctx, projectId, status) -> + $scope.new = { + projectId: projectId + statusId: status + bulk: "" + } $el.removeClass("hidden") - $scope.form = {data: ""} $el.on "click", ".close", (event) -> event.preventDefault() @@ -183,10 +184,7 @@ CreateBulkUserstoriesDirective = ($repo, $rs, $rootscope) -> if not form.validate() return - data = $scope.form.data - projectId = $scope.projectId - - $rs.userstories.bulkCreate(projectId, data).then (result) -> + $rs.userstories.bulkCreate($scope.new.projectId, $scope.new.statusId, $scope.new.bulk).then (result) -> $rootscope.$broadcast("usform:bulk:success", result) $el.addClass("hidden") diff --git a/app/coffee/modules/issues/lightboxes.coffee b/app/coffee/modules/issues/lightboxes.coffee index cdf0ad3b..904268fb 100644 --- a/app/coffee/modules/issues/lightboxes.coffee +++ b/app/coffee/modules/issues/lightboxes.coffee @@ -33,16 +33,16 @@ CreateIssueDirective = ($repo, $model, $rs, $rootscope) -> form = $el.find("form").checksley() $scope.issue = {} - $scope.$on "issueform:new", -> + $scope.$on "issueform:new", (ctx, project)-> $el.removeClass("hidden") $scope.issue = { - project: $scope.projectId + project: project.id subject: "" - status: $scope.project.default_issue_status - type: $scope.project.default_issue_type - priority: $scope.project.default_priority - severity: $scope.project.default_severity + status: project.default_issue_status + type: project.default_issue_type + priority: project.default_priority + severity: project.default_severity estimated_start: null estimated_finish: null } @@ -51,7 +51,6 @@ CreateIssueDirective = ($repo, $model, $rs, $rootscope) -> $el.off() submit = -> - console.log $scope.issue if not form.validate() return @@ -83,11 +82,12 @@ CreateIssueDirective = ($repo, $model, $rs, $rootscope) -> CreateBulkIssuesDirective = ($repo, $rs, $rootscope) -> link = ($scope, $el, attrs) -> - $scope.form = {data: "", usId: null} - - $scope.$on "issueform:bulk", (ctx, sprintId, usId)-> + $scope.$on "issueform:bulk", (ctx, projectId, status)-> $el.removeClass("hidden") - $scope.form = {data: "", sprintId: sprintId, usId: usId} + $scope.new = { + projectId: projectId + bulk: "" + } $el.on "click", ".close", (event) -> event.preventDefault() @@ -100,12 +100,12 @@ CreateBulkIssuesDirective = ($repo, $rs, $rootscope) -> if not form.validate() return - data = $scope.form.data - projectId = $scope.projectId + data = $scope.new.bulk + projectId = $scope.new.projectId promise = $rs.issues.bulkCreate(projectId, data) promise.then (result) -> - $rootscope.$broadcast("issueform:bulk:success", result) + $rootscope.$broadcast("issueform:new:success", result) $el.addClass("hidden") # TODO: error handling diff --git a/app/coffee/modules/issues/list.coffee b/app/coffee/modules/issues/list.coffee index d8907151..bcede694 100644 --- a/app/coffee/modules/issues/list.coffee +++ b/app/coffee/modules/issues/list.coffee @@ -57,7 +57,7 @@ class IssuesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi promise.then null, -> console.log "FAIL" #TODO - @scope.$on "issueform:new:succcess", => + @scope.$on "issueform:new:success", => @.loadIssues() @.loadFilters() @@ -192,10 +192,10 @@ class IssuesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi # Functions used from templates addNewIssue: -> - @rootscope.$broadcast("issueform:new") + @rootscope.$broadcast("issueform:new", @scope.project) addIssuesInBulk: -> - @rootscope.$broadcast("issueform:bulk") + @rootscope.$broadcast("issueform:bulk", @scope.projectId) module.controller("IssuesController", IssuesController) diff --git a/app/coffee/modules/kanban/main.coffee b/app/coffee/modules/kanban/main.coffee index f48f93eb..5835c69b 100644 --- a/app/coffee/modules/kanban/main.coffee +++ b/app/coffee/modules/kanban/main.coffee @@ -55,6 +55,7 @@ class KanbanController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi console.log "FAIL" @scope.$on("usform:new:success", @.onNewUserstory) + @scope.$on("usform:bulk:success", @.onNewUserstory) @scope.$on("usform:edit:success", @.onUserstoryEdited) @scope.$on("assigned-to:added", @.onAssignedToChanged) @scope.$on("kanban:us:move", @.moveUs) @@ -66,16 +67,22 @@ class KanbanController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi addNewUs: (type, statusId) -> switch type - when "standard" then @rootscope.$broadcast("usform:new", statusId) - when "bulk" then @rootscope.$broadcast("usform:bulk", statusId) + when "standard" then @rootscope.$broadcast("usform:new", @scope.projectId, statusId) + when "bulk" then @rootscope.$broadcast("usform:bulk", @scope.projectId, statusId) changeUsAssignedTo: (us) -> @rootscope.$broadcast("assigned-to:add", us) # Scope Events Handlers - onNewUserstory: (ctx, us) -> - @scope.usByStatus[us.status].splice(0, 0, us) + onNewUserstory: (ctx, result) -> + if result.data + items = result.data + else + items = [result] + + for us in items + @scope.usByStatus[us.status].splice(0, 0, us) onAssignedToChanged: (ctx, userid, us) -> us.assigned_to = userid diff --git a/app/coffee/modules/resources/userstories.coffee b/app/coffee/modules/resources/userstories.coffee index 3c552041..32a5f545 100644 --- a/app/coffee/modules/resources/userstories.coffee +++ b/app/coffee/modules/resources/userstories.coffee @@ -34,10 +34,16 @@ resourceProvider = ($repo, $http, $urls) -> return $repo.queryMany("userstories", params) - service.bulkCreate = (projectId, data) -> + service.bulkCreate = (projectId, status, bulk) -> + data = { + projectId: projectId + statusId: status + bulkStories: bulk + } + url = $urls.resolve("bulk-create-us") - params = {projectId: projectId, bulkStories: data} - return $http.post(url, params) + + return $http.post(url, data) service.bulkUpdateOrder = (projectId, data) -> url = $urls.resolve("bulk-update-us-order") diff --git a/app/partials/kanban.jade b/app/partials/kanban.jade index ba432816..c1056aa6 100644 --- a/app/partials/kanban.jade +++ b/app/partials/kanban.jade @@ -25,4 +25,7 @@ block content div.lightbox.lightbox_add-new-us.hidden(tg-lb-create-edit-userstory) include views/modules/lightbox_add-new-us + div.lightbox.lightbox_add-bulk.hidden(tg-lb-create-bulk-userstories) + include views/modules/lightbox_add-bulk + div.lightbox.lightbox_select_user.hidden(tg-lb-assignedto) diff --git a/app/partials/views/modules/kanban-table.jade b/app/partials/views/modules/kanban-table.jade index 108c6a2c..97711c2a 100644 --- a/app/partials/views/modules/kanban-table.jade +++ b/app/partials/views/modules/kanban-table.jade @@ -5,7 +5,7 @@ div.kanban-table ng-style="{'border-top-color':s.color}") span(tg-bo-html="s.name") a.icon.icon-plus(href="", title="Add New task", ng-click="ctrl.addNewUs('standard', s.id)") - a.icon.icon-bulk(href="", title="Add New bulk") + a.icon.icon-bulk(href="", title="Add New bulk", ng-click="ctrl.addNewUs('bulk', s.id)") div.kanban-table-body div.kanban-table-inner diff --git a/app/partials/views/modules/lightbox_add-bulk.jade b/app/partials/views/modules/lightbox_add-bulk.jade index c0ef989d..2ec4d93e 100644 --- a/app/partials/views/modules/lightbox_add-bulk.jade +++ b/app/partials/views/modules/lightbox_add-bulk.jade @@ -3,6 +3,6 @@ a.close(href="", title="close") form h2.title(tg-i18n="common.new-bulk") fieldset - textarea(tg-i18n="placeholder:common.one-item-line", ng-model="form.data", data-required="true") + textarea(tg-i18n="placeholder:common.one-item-line", ng-model="new.bulk", data-required="true") a.button.button-green(href="", tg-i18n="title:common.save") span(tg-i18n="common.save")