Refactor resources structure.
parent
25cb1209f9
commit
93d2c041fa
|
@ -50,18 +50,24 @@ configure.$inject = ["$routeProvider", "$locationProvider", "$httpProvider"]
|
||||||
init.$inject = ["$log", "$rootScope"]
|
init.$inject = ["$log", "$rootScope"]
|
||||||
|
|
||||||
modules = [
|
modules = [
|
||||||
"ngRoute",
|
# Main Modules
|
||||||
"ngAnimate",
|
|
||||||
|
|
||||||
"taigaConfig",
|
"taigaConfig",
|
||||||
|
"taigaBase",
|
||||||
"taigaResources",
|
"taigaResources",
|
||||||
|
|
||||||
|
# Specific Modules
|
||||||
"taigaBacklog",
|
"taigaBacklog",
|
||||||
|
|
||||||
# Vendor modules
|
# Vendor modules
|
||||||
|
"ngRoute",
|
||||||
|
"ngAnimate",
|
||||||
"pasvaz.bindonce",
|
"pasvaz.bindonce",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Default Value for taiga local config module.
|
||||||
angular.module("taigaLocalConfig", []).value("localconfig", {})
|
angular.module("taigaLocalConfig", []).value("localconfig", {})
|
||||||
|
|
||||||
|
# Main module definition
|
||||||
module = angular.module("taiga", modules)
|
module = angular.module("taiga", modules)
|
||||||
module.config(configure)
|
module.config(configure)
|
||||||
module.run(init)
|
module.run(init)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
###
|
||||||
# Copyright (C) 2014 Andrey Antukh <niwi@niwi.be>
|
# Copyright (C) 2014 Andrey Antukh <niwi@niwi.be>
|
||||||
# Copyright (C) 2014 Jesús Espino Garcia <jespinog@gmail.com>
|
# Copyright (C) 2014 Jesús Espino Garcia <jespinog@gmail.com>
|
||||||
# Copyright (C) 2014 David Barragán Merino <bameda@dbarragan.com>
|
# Copyright (C) 2014 David Barragán Merino <bameda@dbarragan.com>
|
||||||
|
@ -14,23 +15,27 @@
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# 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/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# File: modules/backlog.coffee
|
||||||
|
###
|
||||||
|
|
||||||
taiga = @.taiga
|
taiga = @.taiga
|
||||||
|
|
||||||
class BacklogController extends taiga.TaigaController
|
class BacklogController extends taiga.TaigaController
|
||||||
constructor: (@scope, @repo, @params, @rs, @q) ->
|
constructor: (@scope, @repo, @params, @rs, @q) ->
|
||||||
promise = @.loadInitialData()
|
promise = @.loadInitialData()
|
||||||
|
|
||||||
# Obviously fail condition
|
# Obviously fail condition
|
||||||
promise.then null, =>
|
promise.then null, =>
|
||||||
console.log "FAIL"
|
console.log "FAIL"
|
||||||
|
|
||||||
loadSprints: ->
|
loadSprints: ->
|
||||||
return @rs.getSprints(@scope.projectId).then (sprints) =>
|
return @rs.sprints.list(@scope.projectId).then (sprints) =>
|
||||||
@scope.sprints = sprints
|
@scope.sprints = sprints
|
||||||
return sprints
|
return sprints
|
||||||
|
|
||||||
loadUserstories: ->
|
loadUserstories: ->
|
||||||
return @rs.getUnassignedUserstories(@scope.projectId).then (userstories) =>
|
return @rs.userstories.listUnassigned(@scope.projectId).then (userstories) =>
|
||||||
@scope.userstories = userstories
|
@scope.userstories = userstories
|
||||||
return userstories
|
return userstories
|
||||||
|
|
||||||
|
@ -45,7 +50,7 @@ class BacklogController extends taiga.TaigaController
|
||||||
promise = @repo.resolve({pslug: @params.pslug}).then (data) =>
|
promise = @repo.resolve({pslug: @params.pslug}).then (data) =>
|
||||||
console.log "resolve", data.project
|
console.log "resolve", data.project
|
||||||
@scope.projectId = data.project
|
@scope.projectId = data.project
|
||||||
return @rs.getProject(@scope.projectId)
|
return @rs.projects.get(@scope.projectId)
|
||||||
|
|
||||||
# Load project
|
# Load project
|
||||||
promise = promise.then (project) =>
|
promise = promise.then (project) =>
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
module = angular.module("taigaBase", [])
|
|
@ -66,5 +66,5 @@ class HttpService extends taiga.TaigaService
|
||||||
return @.request(options)
|
return @.request(options)
|
||||||
|
|
||||||
|
|
||||||
module = angular.module("taigaResources")
|
module = angular.module("taigaBase")
|
||||||
module.service("$tgHttp", HttpService)
|
module.service("$tgHttp", HttpService)
|
|
@ -139,5 +139,5 @@ provider = ($q, $http, $gmUrls, $gmStorage) ->
|
||||||
|
|
||||||
return service
|
return service
|
||||||
|
|
||||||
module = angular.module("taigaResources")
|
module = angular.module("taigaBase")
|
||||||
module.factory("$tgModel", ["$q", "$http", "$tgUrls", "$tgStorage", provider])
|
module.factory("$tgModel", ["$q", "$http", "$tgUrls", "$tgStorage", provider])
|
|
@ -138,5 +138,5 @@ class RepositoryService extends taiga.TaigaService
|
||||||
return @.queryOneRaw("resolver", null, params)
|
return @.queryOneRaw("resolver", null, params)
|
||||||
|
|
||||||
|
|
||||||
module = angular.module("taigaResources")
|
module = angular.module("taigaBase")
|
||||||
module.service("$tgRepo", RepositoryService)
|
module.service("$tgRepo", RepositoryService)
|
|
@ -48,5 +48,5 @@ class StorageService extends taiga.TaigaService
|
||||||
localStorage.clear()
|
localStorage.clear()
|
||||||
|
|
||||||
|
|
||||||
module = angular.module("taigaResources")
|
module = angular.module("taigaBase")
|
||||||
module.service("$tgStorage", StorageService)
|
module.service("$tgStorage", StorageService)
|
|
@ -41,5 +41,5 @@ class UrlsService
|
||||||
return format("%s://%s%s", [@.scheme, @.host, url])
|
return format("%s://%s%s", [@.scheme, @.host, url])
|
||||||
|
|
||||||
|
|
||||||
module = angular.module("taigaResources")
|
module = angular.module("taigaBase")
|
||||||
module.service('$tgUrls', UrlsService)
|
module.service('$tgUrls', UrlsService)
|
|
@ -18,40 +18,8 @@
|
||||||
taiga = @.taiga
|
taiga = @.taiga
|
||||||
|
|
||||||
class ResourcesService extends taiga.TaigaService
|
class ResourcesService extends taiga.TaigaService
|
||||||
@.$inject = ["$q", "$tgRepo", "$tgUrls", "$tgModel"]
|
|
||||||
|
|
||||||
constructor: (@q, @repo, @urls, @model) ->
|
initUrls = (urls) ->
|
||||||
super()
|
|
||||||
|
|
||||||
#############################################################################
|
|
||||||
# Common
|
|
||||||
#############################################################################
|
|
||||||
|
|
||||||
getProject: (projectId) ->
|
|
||||||
return @repo.queryOne("projects", projectId)
|
|
||||||
|
|
||||||
getProjects: ->
|
|
||||||
return @repo.queryMany("projects")
|
|
||||||
|
|
||||||
#############################################################################
|
|
||||||
# Backlog
|
|
||||||
#############################################################################
|
|
||||||
|
|
||||||
getSprints: (projectId) ->
|
|
||||||
params = {"project": projectId}
|
|
||||||
return @repo.queryMany("milestones", params).then (milestones) =>
|
|
||||||
for m in milestones
|
|
||||||
uses = m.user_stories
|
|
||||||
uses = _.map(uses, (u) => @model.make_model("userstories", u))
|
|
||||||
m._attrs.user_stories = uses
|
|
||||||
return milestones
|
|
||||||
|
|
||||||
getUnassignedUserstories: (projectId) ->
|
|
||||||
params = {"project": projectId, "milestone": "null"}
|
|
||||||
return @repo.queryMany("userstories", params)
|
|
||||||
|
|
||||||
|
|
||||||
init = (urls) ->
|
|
||||||
urls.update({
|
urls.update({
|
||||||
"auth": "/api/v1/auth"
|
"auth": "/api/v1/auth"
|
||||||
"auth-register": "/api/v1/auth/register"
|
"auth-register": "/api/v1/auth/register"
|
||||||
|
@ -110,6 +78,25 @@ init = (urls) ->
|
||||||
"wiki/attachments": "/api/v1/wiki/attachments"
|
"wiki/attachments": "/api/v1/wiki/attachments"
|
||||||
})
|
})
|
||||||
|
|
||||||
module = angular.module("taigaResources", [])
|
# Initialize resources service populating it with methods
|
||||||
|
# defined in separated files.
|
||||||
|
initResources = ($log, $rs) ->
|
||||||
|
$log.debug "Initialize resources"
|
||||||
|
providers = _.toArray(arguments).slice(2)
|
||||||
|
|
||||||
|
for provider in providers
|
||||||
|
provider($rs)
|
||||||
|
|
||||||
|
module = angular.module("taigaResources", ["taigaBase"])
|
||||||
module.service("$tgResources", ResourcesService)
|
module.service("$tgResources", ResourcesService)
|
||||||
module.run(["$tgUrls", init])
|
|
||||||
|
# Module entry point
|
||||||
|
module.run(["$tgUrls", initUrls])
|
||||||
|
module.run([
|
||||||
|
"$log",
|
||||||
|
"$tgResources",
|
||||||
|
"$tgProjectsResourcesProvider",
|
||||||
|
"$tgSprintsResourcesProvider",
|
||||||
|
"$tgUserstoriesResourcesProvider",
|
||||||
|
initResources
|
||||||
|
])
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
###
|
||||||
|
# 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/resources/projects.coffee
|
||||||
|
###
|
||||||
|
|
||||||
|
|
||||||
|
taiga = @.taiga
|
||||||
|
|
||||||
|
resourceProvider = ($repo) ->
|
||||||
|
service = {}
|
||||||
|
|
||||||
|
service.get = (id) ->
|
||||||
|
return $repo.queryOne("projects", id)
|
||||||
|
|
||||||
|
service.list = ->
|
||||||
|
return $repo.queryMany("projects")
|
||||||
|
|
||||||
|
return (instance) ->
|
||||||
|
instance.projects = service
|
||||||
|
|
||||||
|
|
||||||
|
module = angular.module("taigaResources")
|
||||||
|
module.factory("$tgProjectsResourcesProvider", ["$tgRepo", resourceProvider])
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
###
|
||||||
|
# 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/resources/sprints.coffee
|
||||||
|
###
|
||||||
|
|
||||||
|
taiga = @.taiga
|
||||||
|
|
||||||
|
resourceProvider = ($repo, $model) ->
|
||||||
|
service = {}
|
||||||
|
|
||||||
|
service.list = (projectId) ->
|
||||||
|
params = {"project": projectId}
|
||||||
|
return $repo.queryMany("milestones", params).then (milestones) =>
|
||||||
|
for m in milestones
|
||||||
|
uses = m.user_stories
|
||||||
|
uses = _.map(uses, (u) => $model.make_model("userstories", u))
|
||||||
|
m._attrs.user_stories = uses
|
||||||
|
return milestones
|
||||||
|
|
||||||
|
return (instance) ->
|
||||||
|
instance.sprints = service
|
||||||
|
|
||||||
|
module = angular.module("taigaResources")
|
||||||
|
module.factory("$tgSprintsResourcesProvider", ["$tgRepo", "$tgModel", resourceProvider])
|
|
@ -0,0 +1,35 @@
|
||||||
|
###
|
||||||
|
# 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/resources/userstories.coffee
|
||||||
|
###
|
||||||
|
|
||||||
|
taiga = @.taiga
|
||||||
|
|
||||||
|
resourceProvider = ($repo) ->
|
||||||
|
service = {}
|
||||||
|
|
||||||
|
service.listUnassigned = (projectId) ->
|
||||||
|
params = {"project": projectId, "milestone": "null"}
|
||||||
|
return $repo.queryMany("userstories", params)
|
||||||
|
|
||||||
|
return (instance) ->
|
||||||
|
instance.userstories = service
|
||||||
|
|
||||||
|
module = angular.module("taigaResources")
|
||||||
|
module.factory("$tgUserstoriesResourcesProvider", ["$tgRepo", resourceProvider])
|
|
@ -36,7 +36,7 @@ paths = {
|
||||||
"config/main.coffee",
|
"config/main.coffee",
|
||||||
"app/coffee/*.coffee",
|
"app/coffee/*.coffee",
|
||||||
"app/coffee/modules/*.coffee",
|
"app/coffee/modules/*.coffee",
|
||||||
"app/coffee/modules/resources/init.coffee",
|
"app/coffee/modules/base/*.coffee",
|
||||||
"app/coffee/modules/resources/*.coffee",
|
"app/coffee/modules/resources/*.coffee",
|
||||||
"app/coffee/**/*.coffee"]
|
"app/coffee/**/*.coffee"]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue