Improve resource loading on taskboard.
parent
9709039edc
commit
7ae59899d9
|
@ -53,11 +53,16 @@ class TaskboardController extends mixOf(taiga.Controller, taiga.PageMixin)
|
||||||
|
|
||||||
promise = @.loadInitialData()
|
promise = @.loadInitialData()
|
||||||
|
|
||||||
promise.then () =>
|
# On Success
|
||||||
|
promise.then =>
|
||||||
@appTitle.set("Taskboard - " + @scope.project.name)
|
@appTitle.set("Taskboard - " + @scope.project.name)
|
||||||
|
|
||||||
promise.then null, ->
|
# On Error
|
||||||
console.log "FAIL" #TODO
|
promise.then null, (xhr) =>
|
||||||
|
if xhr and xhr.status == 404
|
||||||
|
@location.path("/not-found")
|
||||||
|
@location.replace()
|
||||||
|
return @q.reject(xhr)
|
||||||
|
|
||||||
# TODO: Reload entire taskboard after create/edit tasks seems
|
# TODO: Reload entire taskboard after create/edit tasks seems
|
||||||
# a big overhead. It should be optimized in near future.
|
# a big overhead. It should be optimized in near future.
|
||||||
|
@ -72,6 +77,20 @@ class TaskboardController extends mixOf(taiga.Controller, taiga.PageMixin)
|
||||||
promise.then null, ->
|
promise.then null, ->
|
||||||
console.log "FAIL" # TODO
|
console.log "FAIL" # TODO
|
||||||
|
|
||||||
|
loadProject: ->
|
||||||
|
return @rs.projects.get(@scope.projectId).then (project) =>
|
||||||
|
@scope.project = project
|
||||||
|
@scope.$emit('project:loaded', project)
|
||||||
|
# Not used at this momment
|
||||||
|
@scope.pointsList = _.sortBy(project.points, "order")
|
||||||
|
# @scope.roleList = _.sortBy(project.roles, "order")
|
||||||
|
@scope.pointsById = groupBy(project.points, (e) -> e.id)
|
||||||
|
@scope.roleById = groupBy(project.roles, (e) -> e.id)
|
||||||
|
@scope.taskStatusList = _.sortBy(project.task_statuses, "order")
|
||||||
|
@scope.usStatusList = _.sortBy(project.us_statuses, "order")
|
||||||
|
@scope.usStatusById = groupBy(project.us_statuses, (e) -> e.id)
|
||||||
|
return project
|
||||||
|
|
||||||
loadSprintStats: ->
|
loadSprintStats: ->
|
||||||
return @rs.sprints.stats(@scope.projectId, @scope.sprintId).then (stats) =>
|
return @rs.sprints.stats(@scope.projectId, @scope.sprintId).then (stats) =>
|
||||||
totalPointsSum =_.reduce(_.values(stats.total_points), ((res, n) -> res + n), 0)
|
totalPointsSum =_.reduce(_.values(stats.total_points), ((res, n) -> res + n), 0)
|
||||||
|
@ -100,42 +119,28 @@ class TaskboardController extends mixOf(taiga.Controller, taiga.PageMixin)
|
||||||
return sprint
|
return sprint
|
||||||
|
|
||||||
loadTasks: ->
|
loadTasks: ->
|
||||||
return @.refreshTagsColors().then =>
|
return @rs.tasks.list(@scope.projectId, @scope.sprintId).then (tasks) =>
|
||||||
return @rs.tasks.list(@scope.projectId, @scope.sprintId).then (tasks) =>
|
@scope.tasks = tasks
|
||||||
@scope.tasks = tasks
|
@scope.usTasks = {}
|
||||||
@scope.usTasks = {}
|
|
||||||
|
|
||||||
# Iterate over all userstories and
|
# Iterate over all userstories and
|
||||||
# null userstory for unassigned tasks
|
# null userstory for unassigned tasks
|
||||||
for us in _.union(@scope.userstories, [{id:null}])
|
for us in _.union(@scope.userstories, [{id:null}])
|
||||||
@scope.usTasks[us.id] = {}
|
@scope.usTasks[us.id] = {}
|
||||||
for status in @scope.taskStatusList
|
for status in @scope.taskStatusList
|
||||||
@scope.usTasks[us.id][status.id] = []
|
@scope.usTasks[us.id][status.id] = []
|
||||||
|
|
||||||
for task in @scope.tasks
|
for task in @scope.tasks
|
||||||
@scope.usTasks[task.user_story][task.status].push(task)
|
@scope.usTasks[task.user_story][task.status].push(task)
|
||||||
|
|
||||||
return tasks
|
return tasks
|
||||||
|
|
||||||
loadProject: ->
|
|
||||||
return @rs.projects.get(@scope.projectId).then (project) =>
|
|
||||||
@scope.project = project
|
|
||||||
@scope.$emit('project:loaded', project)
|
|
||||||
# Not used at this momment
|
|
||||||
@scope.pointsList = _.sortBy(project.points, "order")
|
|
||||||
# @scope.roleList = _.sortBy(project.roles, "order")
|
|
||||||
@scope.pointsById = groupBy(project.points, (e) -> e.id)
|
|
||||||
@scope.roleById = groupBy(project.roles, (e) -> e.id)
|
|
||||||
@scope.taskStatusList = _.sortBy(project.task_statuses, "order")
|
|
||||||
@scope.usStatusList = _.sortBy(project.us_statuses, "order")
|
|
||||||
@scope.usStatusById = groupBy(project.us_statuses, (e) -> e.id)
|
|
||||||
return project
|
|
||||||
|
|
||||||
loadTaskboard: ->
|
loadTaskboard: ->
|
||||||
return @q.all([
|
return @q.all([
|
||||||
|
@.refreshTagsColors(),
|
||||||
@.loadSprintStats(),
|
@.loadSprintStats(),
|
||||||
@.loadSprint()
|
@.loadSprint().then(=> @.loadTasks())
|
||||||
]).then(=> @.loadTasks())
|
])
|
||||||
|
|
||||||
loadInitialData: ->
|
loadInitialData: ->
|
||||||
params = {
|
params = {
|
||||||
|
@ -148,13 +153,9 @@ class TaskboardController extends mixOf(taiga.Controller, taiga.PageMixin)
|
||||||
@scope.sprintId = data.milestone
|
@scope.sprintId = data.milestone
|
||||||
return data
|
return data
|
||||||
|
|
||||||
promise.then null, =>
|
|
||||||
@location.path("/not-found")
|
|
||||||
@location.replace()
|
|
||||||
|
|
||||||
return promise.then(=> @.loadProject())
|
return promise.then(=> @.loadProject())
|
||||||
.then(=> @.loadUsersAndRoles())
|
.then(=> @q.all([@.loadUsersAndRoles(),
|
||||||
.then(=> @.loadTaskboard())
|
@.loadTaskboard()]))
|
||||||
|
|
||||||
taskMove: (ctx, task, usId, statusId, order) ->
|
taskMove: (ctx, task, usId, statusId, order) ->
|
||||||
# Remove task from old position
|
# Remove task from old position
|
||||||
|
|
Loading…
Reference in New Issue