Improved backlog and change base classes names.

stable
Andrey Antukh 2014-06-18 14:55:37 +02:00
parent d8ba3e328b
commit 79ca84c083
12 changed files with 105 additions and 34 deletions

View File

@ -19,6 +19,6 @@ class TaigaBase
class TaigaService extends TaigaBase
class TaigaController extends TaigaBase
@.taiga.TaigaBase = TaigaBase
@.taiga.TaigaService = TaigaService
@.taiga.TaigaController = TaigaController
@.taiga.Base = TaigaBase
@.taiga.Service = TaigaService
@.taiga.Controller = TaigaController

View File

@ -17,7 +17,7 @@
taiga = @.taiga
class AuthService extends taiga.TaigaService
class AuthService extends taiga.Service
@.$inject = ["$rootScope", "$tgStorage", "$tgModel", "$tgHttp"]
constructor: (@rootScope, @storage, @model, @http) ->

View File

@ -20,13 +20,17 @@
###
taiga = @.taiga
mixOf = @.taiga.mixOf
class BacklogController extends taiga.TaigaController
constructor: (@scope, @repo, @confirm, @rs, @params, @q) ->
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
@ -43,19 +47,22 @@ class BacklogController extends taiga.TaigaController
@.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) =>
console.log "resolve", data.project
@scope.projectId = data.project
return @rs.projects.get(@scope.projectId)
return data
# Load project
promise = promise.then (project) =>
@scope.project = project
return @.loadBacklog()
return promise
return promise.then(=> @.loadProject())
.then(=> @.loadUsersAndRoles())
.then(=> @.loadBacklog())
## Template actions
@ -68,8 +75,8 @@ class BacklogController extends taiga.TaigaController
addNewUs: (type) ->
switch type
when "standard" then @rootscope.$emit("usform:new")
when "bulk" then @rootscope.$emit("usform:bulk")
when "standard" then @rootscope.$broadcast("usform:new")
when "bulk" then @rootscope.$broadcast("usform:bulk")
BacklogDirective = ($compile, $templateCache) ->
@ -99,30 +106,79 @@ SprintDirective = ($compile, $templateCache) ->
# Lightboxes
###########################################################################################
CreateEditUserstoryDirective = ($repo, $model) ->
link = ($scope, $el, attrs) ->
$scope.us = {"tags": ["kaka", "pedo", "pis"]}
# TODO: defaults
$scope.$on "usform:new", ->
$scope.us = {}
$scope.us = {"subject": "KAKA"}
$el.removeClass("hidden")
console.log "usform new requested"
$scope.$on "usform:change", (ctx, us) ->
$el.removeClass("hidden")
$scope.us = us
return {
scope: {}
link: link
}
$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("tgBacklog", ["$compile", "$templateCache", BacklogDirective])
module.directive("tgSprint", ["$compile", SprintDirective])
module.directive("tgLightboxCreateEditUserstory", ["$tgRepo", "$tgModel", CreateEditUserstoryDirective])
module.directive("tgLbCreateEditUserstory", ["$tgRepo", "$tgModel", CreateEditUserstoryDirective])
module.directive("tgLbCreateBulkUserstories", [
"$tgRepo",
"$tgResources",
"$rootScope",
CreateBulkUserstroriesDirective
])
module.controller("BacklogController", [
"$scope",
"$rootScope",
"$tgRepo",
"$tgConfirm",
"$tgResources",

View File

@ -21,7 +21,7 @@
taiga = @.taiga
class ConfirmService extends taiga.TaigaService
class ConfirmService extends taiga.Service
@.$inject = ["$q"]
constructor: (@q) ->

View File

@ -21,7 +21,7 @@
taiga = @.taiga
class HttpService extends taiga.TaigaService
class HttpService extends taiga.Service
@.$inject = ["$http", "$q", "$tgStorage"]
headers: ->

View File

@ -117,7 +117,7 @@ class Model
taiga = @.taiga
class ModelService extends taiga.TaigaService
class ModelService extends taiga.Service
@.$inject = ["$q", "$tgUrls", "$tgStorage", "$tgHttp"]
constructor: (@q, @urls, @storage, @http) ->

View File

@ -21,7 +21,7 @@
taiga = @.taiga
class RepositoryService extends taiga.TaigaService
class RepositoryService extends taiga.Service
@.$inject = ["$q", "$tgModel", "$tgStorage", "$tgHttp", "$tgUrls"]
constructor: (@q, @model, @storage, @http, @urls) ->

View File

@ -21,7 +21,7 @@
taiga = @.taiga
class StorageService extends taiga.TaigaService
class StorageService extends taiga.Service
@.$inject = ["$rootScope"]
constructor: ($rootScope) ->

View File

@ -23,7 +23,9 @@ format = (fmt, obj) ->
obj = _.clone(obj)
return fmt.replace /%s/g, (match) -> String(obj.shift())
class UrlsService
taiga = @.taiga
class UrlsService extends taiga.Service
@.$inject = ["$tgConfig"]
constructor: (@config) ->

View File

@ -21,7 +21,7 @@
taiga = @.taiga
class ResourcesService extends taiga.TaigaService
class ResourcesService extends taiga.Service
initUrls = (urls) ->
urls.update({

View File

@ -31,6 +31,14 @@ resourceProvider = ($repo) ->
service.list = ->
return $repo.queryMany("projects")
service.usersList = (projectId) ->
params = {"project": projectId}
return $repo.queryMany("users", params)
service.rolesList = (projectId) ->
params = {"project": projectId}
return $repo.queryMany("roles", params)
return (instance) ->
instance.projects = service

View File

@ -21,15 +21,20 @@
taiga = @.taiga
resourceProvider = ($repo) ->
resourceProvider = ($repo, $http, $urls) ->
service = {}
service.listUnassigned = (projectId) ->
params = {"project": projectId, "milestone": "null"}
return $repo.queryMany("userstories", params)
service.bulkCreate = (projectId, data) ->
url = $urls.resolve("bulk-create-us")
params = {projectId: projectId, bulkStories: data}
return $http.post(url, params)
return (instance) ->
instance.userstories = service
module = angular.module("taigaResources")
module.factory("$tgUserstoriesResourcesProvider", ["$tgRepo", resourceProvider])
module.factory("$tgUserstoriesResourcesProvider", ["$tgRepo", "$tgHttp", "$tgUrls", resourceProvider])