Load main data for render backlog.
parent
ab03bb9eff
commit
cd7068c18a
|
@ -18,27 +18,44 @@
|
|||
taiga = @.taiga
|
||||
|
||||
class BacklogController extends taiga.TaigaController
|
||||
constructor: (@repo) ->
|
||||
console.log "foo"
|
||||
constructor: (@scope, @repo, @params, @rs) ->
|
||||
# Resolve project slug
|
||||
promise = @repo.resolve({pslug: @params.pslug}).then (data) =>
|
||||
console.log "resolve", data.project
|
||||
@scope.projectId = data.project
|
||||
return @rs.getProject(@scope.projectId)
|
||||
|
||||
getMilestones: ->
|
||||
projectId = 1
|
||||
return @repo.queryMany("milestones", {project:projectId}).then (milestones) ->
|
||||
console.log milestones
|
||||
return milestones
|
||||
# Load project
|
||||
promise = promise.then (project) =>
|
||||
@scope.project = project
|
||||
console.log project
|
||||
return @rs.getMilestones(@scope.projectId)
|
||||
|
||||
# Load milestones
|
||||
promise = promise.then (milestones) =>
|
||||
@scope.milestones = milestones
|
||||
return @rs.getBacklog(@scope.projectId)
|
||||
|
||||
# Load unassigned userstories
|
||||
promise = promise.then (userstories) =>
|
||||
@scope.userstories = userstories
|
||||
|
||||
# Obviously fail condition
|
||||
promise.then null, =>
|
||||
console.log "FAIL"
|
||||
|
||||
|
||||
BacklogDirective = ($compile) ->
|
||||
controller: ["$tgRepo", BacklogController]
|
||||
controller: ["$scope", "$tgRepo", "$routeParams", "$tgResources", BacklogController]
|
||||
link: (scope, element, attrs, ctrl) ->
|
||||
ctrl.getMilestones().then =>
|
||||
console.log "kaka"
|
||||
|
||||
|
||||
BacklogTableDirective = ($compile, $templateCache) ->
|
||||
require: "^tgBacklog"
|
||||
link: (scope, element, attrs, ctrl) ->
|
||||
content = $templateCache.get("backlog-row.html")
|
||||
scope.$watch "userstories", (userstories) =>
|
||||
console.log "ready to render", userstories
|
||||
|
||||
|
||||
module = angular.module("taiga")
|
||||
|
|
|
@ -108,7 +108,14 @@ class RepositoryService extends taiga.TaigaService
|
|||
url = "#{url}/#{id}" if id
|
||||
|
||||
return @http.get(url, params).then (data) =>
|
||||
return @model.make_model(name, data)
|
||||
return @model.make_model(name, data.data)
|
||||
|
||||
queryOneRaw: (name, id, params) ->
|
||||
url = @urls.resolve(name)
|
||||
url = "#{url}/#{id}" if id
|
||||
|
||||
return @http.get(url, params).then (data) =>
|
||||
return data.data
|
||||
|
||||
queryPaginated: (name, params) ->
|
||||
url = @urls.resolve(name)
|
||||
|
@ -121,5 +128,15 @@ class RepositoryService extends taiga.TaigaService
|
|||
result.paginatedBy = parseInt(headers["x-paginated-by"], 10)
|
||||
return result
|
||||
|
||||
resolve: (options) ->
|
||||
params = {}
|
||||
params.project = options.pslug if options.pslug?
|
||||
params.us = options.usref if options.usref?
|
||||
params.task = options.taskref if options.taskref?
|
||||
params.issue = options.issueref if options.issueref?
|
||||
params.milestone = options.mlref if options.mlref?
|
||||
return @.queryOneRaw("resolver", null, params)
|
||||
|
||||
|
||||
module = angular.module("taigaResources")
|
||||
module.service("$tgRepo", RepositoryService)
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
# 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/>.
|
||||
|
||||
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)
|
|
@ -4,10 +4,9 @@ block head
|
|||
title Taiga Project management web application with scrum in mind!
|
||||
|
||||
block content
|
||||
div(tg-backlog)
|
||||
sidebar.menu-secondary.extrabar.filters-bar
|
||||
include views/modules/filters
|
||||
section.main.backlog
|
||||
section.main.backlog(tg-backlog)
|
||||
include views/components/mainTitle
|
||||
include views/components/summary
|
||||
include views/modules/burndown
|
||||
|
@ -32,3 +31,7 @@ block content
|
|||
div.lightbox.lightbox_add-sprint
|
||||
include views/modules/lightbox_add-sprint
|
||||
|
||||
// Preloading angular templates parts
|
||||
script(type="text/ng-template" id="backlog-row.html")
|
||||
include views/components/backlog-row
|
||||
|
||||
|
|
|
@ -67,6 +67,3 @@ section.backlog-table(tg-backlog-table)
|
|||
a(href="", title="Status 3") Status 3
|
||||
hr.doom-line
|
||||
|
||||
// Preloading angular templates parts
|
||||
script(type="text/ng-template" id="backlog-row.html")
|
||||
include ../components/backlog-row
|
||||
|
|
Loading…
Reference in New Issue