From 139010a2fc8c49c2a4104b117ff852546c088f73 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 12 Jun 2014 10:20:09 +0200 Subject: [PATCH] Minor reorganization on resources modules. --- app/coffee/app.coffee | 2 + app/coffee/modules/auth.coffee | 4 +- app/coffee/modules/backlog.coffee | 2 +- .../init.coffee => resources.coffee} | 33 ++++++++++++ app/coffee/modules/resources/resources.coffee | 50 ------------------- 5 files changed, 38 insertions(+), 53 deletions(-) rename app/coffee/modules/{resources/init.coffee => resources.coffee} (76%) delete mode 100644 app/coffee/modules/resources/resources.coffee diff --git a/app/coffee/app.coffee b/app/coffee/app.coffee index 530dfecc..7e75d6ca 100644 --- a/app/coffee/app.coffee +++ b/app/coffee/app.coffee @@ -55,6 +55,8 @@ modules = [ "taigaConfig", "taigaResources", + + "taigaBacklog", ] angular.module("taigaLocalConfig", []).value("localconfig", {}) diff --git a/app/coffee/modules/auth.coffee b/app/coffee/modules/auth.coffee index c8e9fd3c..e189946e 100644 --- a/app/coffee/modules/auth.coffee +++ b/app/coffee/modules/auth.coffee @@ -32,11 +32,11 @@ class AuthService extends taiga.TaigaService setUser: (user) -> @rootScope.auth = user @rootScope.$broadcast("i18n:change", user.default_language) - @gmStorage.set("userInfo", user.getAttrs()) + @storage.set("userInfo", user.getAttrs()) clear: -> @rootScope.auth = null - @gmStorage.remove("userInfo") + @storage.remove("userInfo") setToken: (token) -> @storage.set("token", token) diff --git a/app/coffee/modules/backlog.coffee b/app/coffee/modules/backlog.coffee index b97733e9..27b090cc 100644 --- a/app/coffee/modules/backlog.coffee +++ b/app/coffee/modules/backlog.coffee @@ -58,6 +58,6 @@ BacklogTableDirective = ($compile, $templateCache) -> console.log "ready to render", userstories -module = angular.module("taiga") +module = angular.module("taigaBacklog", []) module.directive("tgBacklog", ["$compile", BacklogDirective]) module.directive("tgBacklogTable", ["$compile", "$templateCache", BacklogTableDirective]) diff --git a/app/coffee/modules/resources/init.coffee b/app/coffee/modules/resources.coffee similarity index 76% rename from app/coffee/modules/resources/init.coffee rename to app/coffee/modules/resources.coffee index 662f6310..fc1e76fa 100644 --- a/app/coffee/modules/resources/init.coffee +++ b/app/coffee/modules/resources.coffee @@ -15,6 +15,38 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +taiga = @.taiga + +class ResourcesService extends taiga.TaigaService + @.$inject = ["$q", "$tgRepo", "$tgUrls", "$tgModel"] + + constructor: (@q, @repo, @urls, @model) -> + super() + + ############################################################################# + # Common + ############################################################################# + + getProject: (projectId) -> + return @repo.queryOne("projects", projectId) + + ############################################################################# + # Backlog + ############################################################################# + + getMilestones: (projectId) -> + return @repo.queryMany("milestones", {project:projectId}).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 + + getBacklog: (projectId) -> + params = {"project": projectId, "milestone": "null"} + return @repo.queryMany("userstories", params) + + init = (urls) -> urls.update({ "auth": "/api/v1/auth" @@ -75,4 +107,5 @@ init = (urls) -> }) module = angular.module("taigaResources", []) +module.service("$tgResources", ResourcesService) module.run(["$tgUrls", init]) diff --git a/app/coffee/modules/resources/resources.coffee b/app/coffee/modules/resources/resources.coffee deleted file mode 100644 index 7a1a0cdd..00000000 --- a/app/coffee/modules/resources/resources.coffee +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (C) 2014 Andrey Antukh -# Copyright (C) 2014 Jesús Espino Garcia -# Copyright (C) 2014 David Barragán Merino -# -# 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 . - -taiga = @.taiga - -class ResourcesService extends taiga.TaigaService - @.$inject = ["$q", "$tgRepo", "$tgUrls", "$tgModel"] - - constructor: (@q, @repo, @urls, @model) -> - super() - - ############################################################################# - # Common - ############################################################################# - - getProject: (projectId) -> - return @repo.queryOne("projects", projectId) - - ############################################################################# - # Backlog - ############################################################################# - - getMilestones: (projectId) -> - return @repo.queryMany("milestones", {project:projectId}).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 - - getBacklog: (projectId) -> - params = {"project": projectId, "milestone": "null"} - return @repo.queryMany("userstories", params) - -module = angular.module("taigaResources") -module.service("$tgResources", ResourcesService)