Improved backlog and change base classes names.
parent
d8ba3e328b
commit
79ca84c083
|
@ -19,6 +19,6 @@ class TaigaBase
|
||||||
class TaigaService extends TaigaBase
|
class TaigaService extends TaigaBase
|
||||||
class TaigaController extends TaigaBase
|
class TaigaController extends TaigaBase
|
||||||
|
|
||||||
@.taiga.TaigaBase = TaigaBase
|
@.taiga.Base = TaigaBase
|
||||||
@.taiga.TaigaService = TaigaService
|
@.taiga.Service = TaigaService
|
||||||
@.taiga.TaigaController = TaigaController
|
@.taiga.Controller = TaigaController
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
taiga = @.taiga
|
taiga = @.taiga
|
||||||
|
|
||||||
class AuthService extends taiga.TaigaService
|
class AuthService extends taiga.Service
|
||||||
@.$inject = ["$rootScope", "$tgStorage", "$tgModel", "$tgHttp"]
|
@.$inject = ["$rootScope", "$tgStorage", "$tgModel", "$tgHttp"]
|
||||||
|
|
||||||
constructor: (@rootScope, @storage, @model, @http) ->
|
constructor: (@rootScope, @storage, @model, @http) ->
|
||||||
|
|
|
@ -20,13 +20,17 @@
|
||||||
###
|
###
|
||||||
|
|
||||||
taiga = @.taiga
|
taiga = @.taiga
|
||||||
|
mixOf = @.taiga.mixOf
|
||||||
|
|
||||||
class BacklogController extends taiga.TaigaController
|
class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin)
|
||||||
constructor: (@scope, @repo, @confirm, @rs, @params, @q) ->
|
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q) ->
|
||||||
|
_.bindAll(@)
|
||||||
promise = @.loadInitialData()
|
promise = @.loadInitialData()
|
||||||
promise.then null, =>
|
promise.then null, =>
|
||||||
console.log "FAIL"
|
console.log "FAIL"
|
||||||
|
|
||||||
|
@rootscope.$on("usform:bulk:success", @.loadUserstories)
|
||||||
|
|
||||||
loadSprints: ->
|
loadSprints: ->
|
||||||
return @rs.sprints.list(@scope.projectId).then (sprints) =>
|
return @rs.sprints.list(@scope.projectId).then (sprints) =>
|
||||||
@scope.sprints = sprints
|
@scope.sprints = sprints
|
||||||
|
@ -43,19 +47,22 @@ class BacklogController extends taiga.TaigaController
|
||||||
@.loadUserstories()
|
@.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: ->
|
loadInitialData: ->
|
||||||
# Resolve project slug
|
# Resolve project slug
|
||||||
promise = @repo.resolve({pslug: @params.pslug}).then (data) =>
|
promise = @repo.resolve({pslug: @params.pslug}).then (data) =>
|
||||||
console.log "resolve", data.project
|
|
||||||
@scope.projectId = data.project
|
@scope.projectId = data.project
|
||||||
return @rs.projects.get(@scope.projectId)
|
return data
|
||||||
|
|
||||||
# Load project
|
return promise.then(=> @.loadProject())
|
||||||
promise = promise.then (project) =>
|
.then(=> @.loadUsersAndRoles())
|
||||||
@scope.project = project
|
.then(=> @.loadBacklog())
|
||||||
return @.loadBacklog()
|
|
||||||
|
|
||||||
return promise
|
|
||||||
|
|
||||||
## Template actions
|
## Template actions
|
||||||
|
|
||||||
|
@ -68,8 +75,8 @@ class BacklogController extends taiga.TaigaController
|
||||||
|
|
||||||
addNewUs: (type) ->
|
addNewUs: (type) ->
|
||||||
switch type
|
switch type
|
||||||
when "standard" then @rootscope.$emit("usform:new")
|
when "standard" then @rootscope.$broadcast("usform:new")
|
||||||
when "bulk" then @rootscope.$emit("usform:bulk")
|
when "bulk" then @rootscope.$broadcast("usform:bulk")
|
||||||
|
|
||||||
|
|
||||||
BacklogDirective = ($compile, $templateCache) ->
|
BacklogDirective = ($compile, $templateCache) ->
|
||||||
|
@ -99,30 +106,79 @@ SprintDirective = ($compile, $templateCache) ->
|
||||||
# Lightboxes
|
# Lightboxes
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
|
|
||||||
CreateEditUserstoryDirective = ($repo, $model) ->
|
CreateEditUserstoryDirective = ($repo, $model) ->
|
||||||
link = ($scope, $el, attrs) ->
|
link = ($scope, $el, attrs) ->
|
||||||
|
$scope.us = {"tags": ["kaka", "pedo", "pis"]}
|
||||||
# TODO: defaults
|
# TODO: defaults
|
||||||
$scope.$on "usform:new", ->
|
$scope.$on "usform:new", ->
|
||||||
$scope.us = {}
|
$scope.us = {"subject": "KAKA"}
|
||||||
$el.removeClass("hidden")
|
$el.removeClass("hidden")
|
||||||
console.log "usform new requested"
|
|
||||||
|
|
||||||
$scope.$on "usform:change", (ctx, us) ->
|
$scope.$on "usform:change", (ctx, us) ->
|
||||||
|
$el.removeClass("hidden")
|
||||||
$scope.us = us
|
$scope.us = us
|
||||||
|
|
||||||
return {
|
$scope.$on "$destroy", ->
|
||||||
scope: {}
|
$el.off()
|
||||||
link: link
|
|
||||||
}
|
# 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("tgBacklog", ["$compile", "$templateCache", BacklogDirective])
|
||||||
module.directive("tgSprint", ["$compile", SprintDirective])
|
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", [
|
module.controller("BacklogController", [
|
||||||
"$scope",
|
"$scope",
|
||||||
|
"$rootScope",
|
||||||
"$tgRepo",
|
"$tgRepo",
|
||||||
"$tgConfirm",
|
"$tgConfirm",
|
||||||
"$tgResources",
|
"$tgResources",
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
taiga = @.taiga
|
taiga = @.taiga
|
||||||
|
|
||||||
class ConfirmService extends taiga.TaigaService
|
class ConfirmService extends taiga.Service
|
||||||
@.$inject = ["$q"]
|
@.$inject = ["$q"]
|
||||||
|
|
||||||
constructor: (@q) ->
|
constructor: (@q) ->
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
taiga = @.taiga
|
taiga = @.taiga
|
||||||
|
|
||||||
class HttpService extends taiga.TaigaService
|
class HttpService extends taiga.Service
|
||||||
@.$inject = ["$http", "$q", "$tgStorage"]
|
@.$inject = ["$http", "$q", "$tgStorage"]
|
||||||
|
|
||||||
headers: ->
|
headers: ->
|
||||||
|
|
|
@ -117,7 +117,7 @@ class Model
|
||||||
|
|
||||||
taiga = @.taiga
|
taiga = @.taiga
|
||||||
|
|
||||||
class ModelService extends taiga.TaigaService
|
class ModelService extends taiga.Service
|
||||||
@.$inject = ["$q", "$tgUrls", "$tgStorage", "$tgHttp"]
|
@.$inject = ["$q", "$tgUrls", "$tgStorage", "$tgHttp"]
|
||||||
|
|
||||||
constructor: (@q, @urls, @storage, @http) ->
|
constructor: (@q, @urls, @storage, @http) ->
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
taiga = @.taiga
|
taiga = @.taiga
|
||||||
|
|
||||||
class RepositoryService extends taiga.TaigaService
|
class RepositoryService extends taiga.Service
|
||||||
@.$inject = ["$q", "$tgModel", "$tgStorage", "$tgHttp", "$tgUrls"]
|
@.$inject = ["$q", "$tgModel", "$tgStorage", "$tgHttp", "$tgUrls"]
|
||||||
|
|
||||||
constructor: (@q, @model, @storage, @http, @urls) ->
|
constructor: (@q, @model, @storage, @http, @urls) ->
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
taiga = @.taiga
|
taiga = @.taiga
|
||||||
|
|
||||||
class StorageService extends taiga.TaigaService
|
class StorageService extends taiga.Service
|
||||||
@.$inject = ["$rootScope"]
|
@.$inject = ["$rootScope"]
|
||||||
|
|
||||||
constructor: ($rootScope) ->
|
constructor: ($rootScope) ->
|
||||||
|
|
|
@ -23,7 +23,9 @@ format = (fmt, obj) ->
|
||||||
obj = _.clone(obj)
|
obj = _.clone(obj)
|
||||||
return fmt.replace /%s/g, (match) -> String(obj.shift())
|
return fmt.replace /%s/g, (match) -> String(obj.shift())
|
||||||
|
|
||||||
class UrlsService
|
taiga = @.taiga
|
||||||
|
|
||||||
|
class UrlsService extends taiga.Service
|
||||||
@.$inject = ["$tgConfig"]
|
@.$inject = ["$tgConfig"]
|
||||||
|
|
||||||
constructor: (@config) ->
|
constructor: (@config) ->
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
taiga = @.taiga
|
taiga = @.taiga
|
||||||
|
|
||||||
class ResourcesService extends taiga.TaigaService
|
class ResourcesService extends taiga.Service
|
||||||
|
|
||||||
initUrls = (urls) ->
|
initUrls = (urls) ->
|
||||||
urls.update({
|
urls.update({
|
||||||
|
|
|
@ -31,6 +31,14 @@ resourceProvider = ($repo) ->
|
||||||
service.list = ->
|
service.list = ->
|
||||||
return $repo.queryMany("projects")
|
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) ->
|
return (instance) ->
|
||||||
instance.projects = service
|
instance.projects = service
|
||||||
|
|
||||||
|
|
|
@ -21,15 +21,20 @@
|
||||||
|
|
||||||
taiga = @.taiga
|
taiga = @.taiga
|
||||||
|
|
||||||
resourceProvider = ($repo) ->
|
resourceProvider = ($repo, $http, $urls) ->
|
||||||
service = {}
|
service = {}
|
||||||
|
|
||||||
service.listUnassigned = (projectId) ->
|
service.listUnassigned = (projectId) ->
|
||||||
params = {"project": projectId, "milestone": "null"}
|
params = {"project": projectId, "milestone": "null"}
|
||||||
return $repo.queryMany("userstories", params)
|
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) ->
|
return (instance) ->
|
||||||
instance.userstories = service
|
instance.userstories = service
|
||||||
|
|
||||||
module = angular.module("taigaResources")
|
module = angular.module("taigaResources")
|
||||||
module.factory("$tgUserstoriesResourcesProvider", ["$tgRepo", resourceProvider])
|
module.factory("$tgUserstoriesResourcesProvider", ["$tgRepo", "$tgHttp", "$tgUrls", resourceProvider])
|
||||||
|
|
Loading…
Reference in New Issue