Separate backlog modules in 3 files.
parent
64083eb78a
commit
2aa95c6e3d
|
@ -19,170 +19,4 @@
|
||||||
# File: modules/backlog.coffee
|
# File: modules/backlog.coffee
|
||||||
###
|
###
|
||||||
|
|
||||||
taiga = @.taiga
|
|
||||||
mixOf = @.taiga.mixOf
|
|
||||||
|
|
||||||
class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin)
|
|
||||||
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q) ->
|
|
||||||
_.bindAll(@)
|
|
||||||
promise = @.loadInitialData()
|
|
||||||
promise.then null, =>
|
|
||||||
console.log "FAIL"
|
|
||||||
|
|
||||||
@rootscope.$on("usform:bulk:success", @.loadUserstories)
|
|
||||||
|
|
||||||
loadSprints: ->
|
|
||||||
return @rs.sprints.list(@scope.projectId).then (sprints) =>
|
|
||||||
@scope.sprints = sprints
|
|
||||||
return sprints
|
|
||||||
|
|
||||||
loadUserstories: ->
|
|
||||||
return @rs.userstories.listUnassigned(@scope.projectId).then (userstories) =>
|
|
||||||
@scope.userstories = userstories
|
|
||||||
return userstories
|
|
||||||
|
|
||||||
loadBacklog: ->
|
|
||||||
return @q.all([
|
|
||||||
@.loadSprints(),
|
|
||||||
@.loadUserstories()
|
|
||||||
])
|
|
||||||
|
|
||||||
loadProject: ->
|
|
||||||
return @rs.projects.get(@scope.projectId).then (project) =>
|
|
||||||
@scope.project = project
|
|
||||||
@scope.points = _.sortBy(project.points, "order")
|
|
||||||
@scope.statusList = _.sortBy(project.us_statuses, "id")
|
|
||||||
return project
|
|
||||||
|
|
||||||
loadInitialData: ->
|
|
||||||
# Resolve project slug
|
|
||||||
promise = @repo.resolve({pslug: @params.pslug}).then (data) =>
|
|
||||||
@scope.projectId = data.project
|
|
||||||
return data
|
|
||||||
|
|
||||||
return promise.then(=> @.loadProject())
|
|
||||||
.then(=> @.loadUsersAndRoles())
|
|
||||||
.then(=> @.loadBacklog())
|
|
||||||
|
|
||||||
## Template actions
|
|
||||||
|
|
||||||
deleteUserStory: (us) ->
|
|
||||||
title = "Delete User Story"
|
|
||||||
subtitle = us.subject
|
|
||||||
|
|
||||||
@confirm.ask(title, subtitle).then =>
|
|
||||||
console.log "#TODO"
|
|
||||||
|
|
||||||
addNewUs: (type) ->
|
|
||||||
switch type
|
|
||||||
when "standard" then @rootscope.$broadcast("usform:new")
|
|
||||||
when "bulk" then @rootscope.$broadcast("usform:bulk")
|
|
||||||
|
|
||||||
|
|
||||||
BacklogDirective = ($compile, $templateCache) ->
|
|
||||||
link = ($scope, $el, $attrs) ->
|
|
||||||
$ctrl = $el.controller()
|
|
||||||
|
|
||||||
return {link: link}
|
|
||||||
|
|
||||||
|
|
||||||
SprintDirective = ($compile, $templateCache) ->
|
|
||||||
link = (scope, element, attrs) ->
|
|
||||||
sprint = scope.$eval(attrs.tgSprint)
|
|
||||||
if scope.$first
|
|
||||||
element.addClass("sprint-current")
|
|
||||||
|
|
||||||
if sprint.closed
|
|
||||||
element.addClass("sprint-closed")
|
|
||||||
|
|
||||||
# Event Handlers
|
|
||||||
element.on "click", ".sprint-summary > a", (event) ->
|
|
||||||
element.find(".sprint-table").toggle()
|
|
||||||
|
|
||||||
return {link: link}
|
|
||||||
|
|
||||||
|
|
||||||
###########################################################################################
|
|
||||||
# Lightboxes
|
|
||||||
###########################################################################################
|
|
||||||
|
|
||||||
CreateEditUserstoryDirective = ($repo, $model) ->
|
|
||||||
link = ($scope, $el, attrs) ->
|
|
||||||
$scope.us = {"tags": ["kaka", "pedo", "pis"]}
|
|
||||||
# TODO: defaults
|
|
||||||
$scope.$on "usform:new", ->
|
|
||||||
$scope.us = {"subject": "KAKA"}
|
|
||||||
$el.removeClass("hidden")
|
|
||||||
|
|
||||||
$scope.$on "usform:change", (ctx, us) ->
|
|
||||||
$el.removeClass("hidden")
|
|
||||||
$scope.us = us
|
|
||||||
|
|
||||||
$scope.$on "$destroy", ->
|
|
||||||
$el.off()
|
|
||||||
|
|
||||||
# Dom Event Handlers
|
|
||||||
$el.on "click", ".markdown-preview a", (event) ->
|
|
||||||
event.preventDefault()
|
|
||||||
target = angular.element(event.currentTarget)
|
|
||||||
|
|
||||||
target.parent().find("a").removeClass("active")
|
|
||||||
target.addClass("active")
|
|
||||||
|
|
||||||
$el.on "click", ".close", (event) ->
|
|
||||||
event.preventDefault()
|
|
||||||
$el.addClass("hidden")
|
|
||||||
|
|
||||||
$el.on "click", ".button-green", (event) ->
|
|
||||||
event.preventDefault()
|
|
||||||
console.log $scope.us
|
|
||||||
|
|
||||||
return {link: link}
|
|
||||||
|
|
||||||
CreateBulkUserstroriesDirective = ($repo, $rs, $rootscope) ->
|
|
||||||
link = ($scope, $el, attrs) ->
|
|
||||||
$scope.form = {data: ""}
|
|
||||||
|
|
||||||
$scope.$on "usform:bulk", ->
|
|
||||||
$el.removeClass("hidden")
|
|
||||||
$scope.form = {data: ""}
|
|
||||||
|
|
||||||
$el.on "click", ".close", (event) ->
|
|
||||||
event.preventDefault()
|
|
||||||
$el.addClass("hidden")
|
|
||||||
|
|
||||||
$el.on "click", ".button-green", (event) ->
|
|
||||||
event.preventDefault()
|
|
||||||
|
|
||||||
data = $scope.form.data
|
|
||||||
projectId = $scope.projectId
|
|
||||||
|
|
||||||
$rs.userstories.bulkCreate(projectId, data).then (result) ->
|
|
||||||
$rootscope.$broadcast("usform:bulk:success", result)
|
|
||||||
$el.addClass("hidden")
|
|
||||||
|
|
||||||
return {link: link}
|
|
||||||
|
|
||||||
|
|
||||||
module = angular.module("taigaBacklog", [])
|
module = angular.module("taigaBacklog", [])
|
||||||
module.directive("tgBacklog", ["$compile", "$templateCache", BacklogDirective])
|
|
||||||
module.directive("tgSprint", ["$compile", SprintDirective])
|
|
||||||
module.directive("tgLbCreateEditUserstory", ["$tgRepo", "$tgModel", CreateEditUserstoryDirective])
|
|
||||||
|
|
||||||
module.directive("tgLbCreateBulkUserstories", [
|
|
||||||
"$tgRepo",
|
|
||||||
"$tgResources",
|
|
||||||
"$rootScope",
|
|
||||||
CreateBulkUserstroriesDirective
|
|
||||||
])
|
|
||||||
|
|
||||||
module.controller("BacklogController", [
|
|
||||||
"$scope",
|
|
||||||
"$rootScope",
|
|
||||||
"$tgRepo",
|
|
||||||
"$tgConfirm",
|
|
||||||
"$tgResources",
|
|
||||||
"$routeParams",
|
|
||||||
"$q",
|
|
||||||
BacklogController
|
|
||||||
])
|
|
||||||
|
|
|
@ -0,0 +1,88 @@
|
||||||
|
###
|
||||||
|
# Copyright (C) 2014 Andrey Antukh <niwi@niwi.be>
|
||||||
|
# Copyright (C) 2014 Jesús Espino Garcia <jespinog@gmail.com>
|
||||||
|
# Copyright (C) 2014 David Barragán Merino <bameda@dbarragan.com>
|
||||||
|
#
|
||||||
|
# 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 <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# File: modules/backlog/lightboxes.coffee
|
||||||
|
###
|
||||||
|
|
||||||
|
CreateEditUserstoryDirective = ($repo, $model) ->
|
||||||
|
link = ($scope, $el, attrs) ->
|
||||||
|
$scope.us = {"tags": ["kaka", "pedo", "pis"]}
|
||||||
|
# TODO: defaults
|
||||||
|
$scope.$on "usform:new", ->
|
||||||
|
$scope.us = {"subject": "KAKA"}
|
||||||
|
$el.removeClass("hidden")
|
||||||
|
|
||||||
|
$scope.$on "usform:change", (ctx, us) ->
|
||||||
|
$el.removeClass("hidden")
|
||||||
|
$scope.us = us
|
||||||
|
|
||||||
|
$scope.$on "$destroy", ->
|
||||||
|
$el.off()
|
||||||
|
|
||||||
|
# Dom Event Handlers
|
||||||
|
$el.on "click", ".markdown-preview a", (event) ->
|
||||||
|
event.preventDefault()
|
||||||
|
target = angular.element(event.currentTarget)
|
||||||
|
|
||||||
|
target.parent().find("a").removeClass("active")
|
||||||
|
target.addClass("active")
|
||||||
|
|
||||||
|
$el.on "click", ".close", (event) ->
|
||||||
|
event.preventDefault()
|
||||||
|
$el.addClass("hidden")
|
||||||
|
|
||||||
|
$el.on "click", ".button-green", (event) ->
|
||||||
|
event.preventDefault()
|
||||||
|
console.log $scope.us
|
||||||
|
|
||||||
|
return {link: link}
|
||||||
|
|
||||||
|
CreateBulkUserstroriesDirective = ($repo, $rs, $rootscope) ->
|
||||||
|
link = ($scope, $el, attrs) ->
|
||||||
|
$scope.form = {data: ""}
|
||||||
|
|
||||||
|
$scope.$on "usform:bulk", ->
|
||||||
|
$el.removeClass("hidden")
|
||||||
|
$scope.form = {data: ""}
|
||||||
|
|
||||||
|
$el.on "click", ".close", (event) ->
|
||||||
|
event.preventDefault()
|
||||||
|
$el.addClass("hidden")
|
||||||
|
|
||||||
|
$el.on "click", ".button-green", (event) ->
|
||||||
|
event.preventDefault()
|
||||||
|
|
||||||
|
data = $scope.form.data
|
||||||
|
projectId = $scope.projectId
|
||||||
|
|
||||||
|
$rs.userstories.bulkCreate(projectId, data).then (result) ->
|
||||||
|
$rootscope.$broadcast("usform:bulk:success", result)
|
||||||
|
$el.addClass("hidden")
|
||||||
|
|
||||||
|
return {link: link}
|
||||||
|
|
||||||
|
module = angular.module("taigaBacklog")
|
||||||
|
module.directive("tgLbCreateEditUserstory", ["$tgRepo", "$tgModel", CreateEditUserstoryDirective])
|
||||||
|
module.directive("tgLbCreateBulkUserstories", [
|
||||||
|
"$tgRepo",
|
||||||
|
"$tgResources",
|
||||||
|
"$rootScope",
|
||||||
|
CreateBulkUserstroriesDirective
|
||||||
|
])
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,121 @@
|
||||||
|
###
|
||||||
|
# Copyright (C) 2014 Andrey Antukh <niwi@niwi.be>
|
||||||
|
# Copyright (C) 2014 Jesús Espino Garcia <jespinog@gmail.com>
|
||||||
|
# Copyright (C) 2014 David Barragán Merino <bameda@dbarragan.com>
|
||||||
|
#
|
||||||
|
# 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 <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# File: modules/backlog/main.coffee
|
||||||
|
###
|
||||||
|
|
||||||
|
taiga = @.taiga
|
||||||
|
mixOf = @.taiga.mixOf
|
||||||
|
|
||||||
|
class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin)
|
||||||
|
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q) ->
|
||||||
|
_.bindAll(@)
|
||||||
|
promise = @.loadInitialData()
|
||||||
|
promise.then null, =>
|
||||||
|
console.log "FAIL"
|
||||||
|
|
||||||
|
@rootscope.$on("usform:bulk:success", @.loadUserstories)
|
||||||
|
|
||||||
|
loadSprints: ->
|
||||||
|
return @rs.sprints.list(@scope.projectId).then (sprints) =>
|
||||||
|
@scope.sprints = sprints
|
||||||
|
return sprints
|
||||||
|
|
||||||
|
loadUserstories: ->
|
||||||
|
return @rs.userstories.listUnassigned(@scope.projectId).then (userstories) =>
|
||||||
|
@scope.userstories = userstories
|
||||||
|
return userstories
|
||||||
|
|
||||||
|
loadBacklog: ->
|
||||||
|
return @q.all([
|
||||||
|
@.loadSprints(),
|
||||||
|
@.loadUserstories()
|
||||||
|
])
|
||||||
|
|
||||||
|
loadProject: ->
|
||||||
|
return @rs.projects.get(@scope.projectId).then (project) =>
|
||||||
|
@scope.project = project
|
||||||
|
@scope.points = _.sortBy(project.points, "order")
|
||||||
|
@scope.statusList = _.sortBy(project.us_statuses, "id")
|
||||||
|
return project
|
||||||
|
|
||||||
|
loadInitialData: ->
|
||||||
|
# Resolve project slug
|
||||||
|
promise = @repo.resolve({pslug: @params.pslug}).then (data) =>
|
||||||
|
@scope.projectId = data.project
|
||||||
|
return data
|
||||||
|
|
||||||
|
return promise.then(=> @.loadProject())
|
||||||
|
.then(=> @.loadUsersAndRoles())
|
||||||
|
.then(=> @.loadBacklog())
|
||||||
|
|
||||||
|
## Template actions
|
||||||
|
|
||||||
|
deleteUserStory: (us) ->
|
||||||
|
title = "Delete User Story"
|
||||||
|
subtitle = us.subject
|
||||||
|
|
||||||
|
@confirm.ask(title, subtitle).then =>
|
||||||
|
console.log "#TODO"
|
||||||
|
|
||||||
|
addNewUs: (type) ->
|
||||||
|
switch type
|
||||||
|
when "standard" then @rootscope.$broadcast("usform:new")
|
||||||
|
when "bulk" then @rootscope.$broadcast("usform:bulk")
|
||||||
|
|
||||||
|
|
||||||
|
BacklogDirective = ->
|
||||||
|
link = ($scope, $el, $attrs) ->
|
||||||
|
$ctrl = $el.controller()
|
||||||
|
return {link: link}
|
||||||
|
|
||||||
|
BacklogSummaryDirective = ->
|
||||||
|
link = ($scope, $el, $attrs) ->
|
||||||
|
return {link:link}
|
||||||
|
|
||||||
|
BacklogSprintDirective = ->
|
||||||
|
link = (scope, element, attrs) ->
|
||||||
|
sprint = scope.$eval(attrs.tgBacklogSprint)
|
||||||
|
if scope.$first
|
||||||
|
element.addClass("sprint-current")
|
||||||
|
|
||||||
|
if sprint.closed
|
||||||
|
element.addClass("sprint-closed")
|
||||||
|
|
||||||
|
# Event Handlers
|
||||||
|
element.on "click", ".sprint-summary > a", (event) ->
|
||||||
|
element.find(".sprint-table").toggle()
|
||||||
|
|
||||||
|
return {link: link}
|
||||||
|
|
||||||
|
|
||||||
|
module = angular.module("taigaBacklog")
|
||||||
|
module.directive("tgBacklog", BacklogDirective)
|
||||||
|
module.directive("tgBacklogSprint", BacklogSprintDirective)
|
||||||
|
module.directive("tgBacklogSummary", BacklogSummaryDirective)
|
||||||
|
|
||||||
|
module.controller("BacklogController", [
|
||||||
|
"$scope",
|
||||||
|
"$rootScope",
|
||||||
|
"$tgRepo",
|
||||||
|
"$tgConfirm",
|
||||||
|
"$tgResources",
|
||||||
|
"$routeParams",
|
||||||
|
"$q",
|
||||||
|
BacklogController
|
||||||
|
])
|
|
@ -10,7 +10,7 @@ section.sprints
|
||||||
a.button-green(href="", title="Add New US")
|
a.button-green(href="", title="Add New US")
|
||||||
span.text + New sprint
|
span.text + New sprint
|
||||||
|
|
||||||
section.sprint(ng-repeat="sprint in sprints track by sprint.id", tg-sprint="sprint")
|
section.sprint(ng-repeat="sprint in sprints track by sprint.id", tg-backlog-sprint="sprint")
|
||||||
header
|
header
|
||||||
div.sprint-summary
|
div.sprint-summary
|
||||||
a.icon.icon-arrow-up(href="", title="compact Sprint")
|
a.icon.icon-arrow-up(href="", title="compact Sprint")
|
||||||
|
|
|
@ -8,7 +8,6 @@ plumber = require("gulp-plumber")
|
||||||
wrap = require("gulp-wrap")
|
wrap = require("gulp-wrap")
|
||||||
rename = require("gulp-rename")
|
rename = require("gulp-rename")
|
||||||
|
|
||||||
newer = require("gulp-newer")
|
|
||||||
minifyHTML = require("gulp-minify-html")
|
minifyHTML = require("gulp-minify-html")
|
||||||
sass = require("gulp-ruby-sass")
|
sass = require("gulp-ruby-sass")
|
||||||
csslint = require("gulp-csslint")
|
csslint = require("gulp-csslint")
|
||||||
|
@ -38,6 +37,7 @@ paths = {
|
||||||
"app/coffee/*.coffee",
|
"app/coffee/*.coffee",
|
||||||
"app/coffee/modules/controllerMixins.coffee",
|
"app/coffee/modules/controllerMixins.coffee",
|
||||||
"app/coffee/modules/*.coffee",
|
"app/coffee/modules/*.coffee",
|
||||||
|
"app/coffee/modules/backlog/*.coffee",
|
||||||
"app/coffee/modules/locales/*.coffee",
|
"app/coffee/modules/locales/*.coffee",
|
||||||
"app/coffee/modules/base/*.coffee",
|
"app/coffee/modules/base/*.coffee",
|
||||||
"app/coffee/modules/resources/*.coffee"]
|
"app/coffee/modules/resources/*.coffee"]
|
||||||
|
|
Loading…
Reference in New Issue