fix 'show closed sprints' visibility
parent
14e8429dba
commit
43c23ed819
|
@ -100,7 +100,7 @@ CreateEditSprint = ($repo, $confirm, $rs, $rootscope, lightboxService, $loading,
|
||||||
finish()
|
finish()
|
||||||
$scope.milestonesCounter -= 1
|
$scope.milestonesCounter -= 1
|
||||||
lightboxService.close($el)
|
lightboxService.close($el)
|
||||||
$rootscope.$broadcast("sprintform:remove:success")
|
$rootscope.$broadcast("sprintform:remove:success", $scope.sprint)
|
||||||
|
|
||||||
onError = ->
|
onError = ->
|
||||||
finish(false)
|
finish(false)
|
||||||
|
|
|
@ -104,10 +104,14 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
|
||||||
@scope.$on "sprintform:edit:success", =>
|
@scope.$on "sprintform:edit:success", =>
|
||||||
@.loadProjectStats()
|
@.loadProjectStats()
|
||||||
|
|
||||||
@scope.$on "sprintform:remove:success", =>
|
@scope.$on "sprintform:remove:success", (event, sprint) =>
|
||||||
@.loadSprints()
|
@.loadSprints()
|
||||||
@.loadProjectStats()
|
@.loadProjectStats()
|
||||||
@.loadUserstories()
|
@.loadUserstories()
|
||||||
|
|
||||||
|
if sprint.closed
|
||||||
|
@.loadClosedSprints()
|
||||||
|
|
||||||
@rootscope.$broadcast("filters:update")
|
@rootscope.$broadcast("filters:update")
|
||||||
|
|
||||||
@scope.$on "usform:edit:success", =>
|
@scope.$on "usform:edit:success", =>
|
||||||
|
@ -157,17 +161,26 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
|
||||||
|
|
||||||
loadClosedSprints: ->
|
loadClosedSprints: ->
|
||||||
params = {closed: true}
|
params = {closed: true}
|
||||||
return @rs.sprints.list(@scope.projectId, params).then (sprints) =>
|
return @rs.sprints.list(@scope.projectId, params).then (result) =>
|
||||||
|
sprints = result.milestones
|
||||||
|
|
||||||
|
@scope.totalClosedMilestones = result.closed
|
||||||
|
|
||||||
# NOTE: Fix order of USs because the filter orderBy does not work propertly in partials files
|
# NOTE: Fix order of USs because the filter orderBy does not work propertly in partials files
|
||||||
for sprint in sprints
|
for sprint in sprints
|
||||||
sprint.user_stories = _.sortBy(sprint.user_stories, "sprint_order")
|
sprint.user_stories = _.sortBy(sprint.user_stories, "sprint_order")
|
||||||
@scope.closedSprints = sprints
|
@scope.closedSprints = sprints
|
||||||
|
@scope.closedSprintsById = groupBy(sprints, (x) -> x.id)
|
||||||
@rootscope.$broadcast("closed-sprints:reloaded", sprints)
|
@rootscope.$broadcast("closed-sprints:reloaded", sprints)
|
||||||
return sprints
|
return sprints
|
||||||
|
|
||||||
loadSprints: ->
|
loadSprints: ->
|
||||||
params = {closed: false}
|
params = {closed: false}
|
||||||
return @rs.sprints.list(@scope.projectId, params).then (sprints) =>
|
return @rs.sprints.list(@scope.projectId, params).then (result) =>
|
||||||
|
sprints = result.milestones
|
||||||
|
|
||||||
|
@scope.totalClosedMilestones = result.closed
|
||||||
|
|
||||||
# NOTE: Fix order of USs because the filter orderBy does not work propertly in partials files
|
# NOTE: Fix order of USs because the filter orderBy does not work propertly in partials files
|
||||||
for sprint in sprints
|
for sprint in sprints
|
||||||
sprint.user_stories = _.sortBy(sprint.user_stories, "sprint_order")
|
sprint.user_stories = _.sortBy(sprint.user_stories, "sprint_order")
|
||||||
|
@ -231,7 +244,7 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
|
||||||
|
|
||||||
@scope.projectId = project.id
|
@scope.projectId = project.id
|
||||||
@scope.project = project
|
@scope.project = project
|
||||||
@scope.totalClosedMilestones = project.total_closed_milestones
|
@scope.closedMilestones = !!project.total_closed_milestones
|
||||||
@scope.$emit('project:loaded', project)
|
@scope.$emit('project:loaded', project)
|
||||||
@scope.points = _.sortBy(project.points, "order")
|
@scope.points = _.sortBy(project.points, "order")
|
||||||
@scope.pointsById = groupBy(project.points, (x) -> x.id)
|
@scope.pointsById = groupBy(project.points, (x) -> x.id)
|
||||||
|
@ -267,6 +280,23 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
|
||||||
oldSprintId = usList[0].milestone
|
oldSprintId = usList[0].milestone
|
||||||
project = usList[0].project
|
project = usList[0].project
|
||||||
|
|
||||||
|
movedFromClosedSprint = false
|
||||||
|
movedToClosedSprint = false
|
||||||
|
|
||||||
|
sprint = @scope.sprintsById[oldSprintId]
|
||||||
|
|
||||||
|
# Move from closed sprint
|
||||||
|
if !sprint && @scope.closedSprintsById
|
||||||
|
sprint = @scope.closedSprintsById[oldSprintId]
|
||||||
|
movedFromClosedSprint = true if sprint
|
||||||
|
|
||||||
|
newSprint = @scope.sprintsById[newSprintId]
|
||||||
|
|
||||||
|
# Move to closed sprint
|
||||||
|
if !newSprint
|
||||||
|
newSprint = @scope.closedSprintsById[newSprintId]
|
||||||
|
movedToClosedSprint = true if newSprint
|
||||||
|
|
||||||
# In the same sprint or in the backlog
|
# In the same sprint or in the backlog
|
||||||
if newSprintId == oldSprintId
|
if newSprintId == oldSprintId
|
||||||
items = null
|
items = null
|
||||||
|
@ -275,7 +305,7 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
|
||||||
if newSprintId == null
|
if newSprintId == null
|
||||||
userstories = @scope.userstories
|
userstories = @scope.userstories
|
||||||
else
|
else
|
||||||
userstories = @scope.sprintsById[newSprintId].user_stories
|
userstories = newSprint.user_stories
|
||||||
|
|
||||||
@scope.$apply ->
|
@scope.$apply ->
|
||||||
for us, key in usList
|
for us, key in usList
|
||||||
|
@ -322,8 +352,6 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
|
||||||
args = [newUsIndex, 0].concat(usList)
|
args = [newUsIndex, 0].concat(usList)
|
||||||
Array.prototype.splice.apply(@scope.userstories, args)
|
Array.prototype.splice.apply(@scope.userstories, args)
|
||||||
|
|
||||||
# Remove the us from the sprint list.
|
|
||||||
sprint = @scope.sprintsById[oldSprintId]
|
|
||||||
for us, key in usList
|
for us, key in usList
|
||||||
r = sprint.user_stories.indexOf(us)
|
r = sprint.user_stories.indexOf(us)
|
||||||
sprint.user_stories.splice(r, 1)
|
sprint.user_stories.splice(r, 1)
|
||||||
|
@ -339,13 +367,15 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
|
||||||
return @rs.userstories.bulkUpdateBacklogOrder(us.project, data).then =>
|
return @rs.userstories.bulkUpdateBacklogOrder(us.project, data).then =>
|
||||||
@rootscope.$broadcast("sprint:us:moved", us, oldSprintId, newSprintId)
|
@rootscope.$broadcast("sprint:us:moved", us, oldSprintId, newSprintId)
|
||||||
|
|
||||||
|
if movedFromClosedSprint
|
||||||
|
@rootscope.$broadcast("backlog:load-closed-sprints")
|
||||||
|
|
||||||
promise.then null, ->
|
promise.then null, ->
|
||||||
console.log "FAIL" # TODO
|
console.log "FAIL" # TODO
|
||||||
|
|
||||||
return promise
|
return promise
|
||||||
|
|
||||||
# From backlog to sprint
|
# From backlog to sprint
|
||||||
newSprint = @scope.sprintsById[newSprintId]
|
|
||||||
if oldSprintId == null
|
if oldSprintId == null
|
||||||
us.milestone = newSprintId for us in usList
|
us.milestone = newSprintId for us in usList
|
||||||
|
|
||||||
|
@ -372,9 +402,8 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
|
||||||
|
|
||||||
# Remove the us from the sprint list.
|
# Remove the us from the sprint list.
|
||||||
for us in usList
|
for us in usList
|
||||||
oldSprint = @scope.sprintsById[oldSprintId]
|
r = sprint.user_stories.indexOf(us)
|
||||||
r = oldSprint.user_stories.indexOf(us)
|
sprint.user_stories.splice(r, 1)
|
||||||
oldSprint.user_stories.splice(r, 1)
|
|
||||||
|
|
||||||
# Persist the milestone change of userstory
|
# Persist the milestone change of userstory
|
||||||
promises = _.map usList, (us) => @repo.save(us)
|
promises = _.map usList, (us) => @repo.save(us)
|
||||||
|
@ -385,13 +414,16 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
|
||||||
items = @.resortUserStories(newSprint.user_stories, "sprint_order")
|
items = @.resortUserStories(newSprint.user_stories, "sprint_order")
|
||||||
data = @.prepareBulkUpdateData(items, "sprint_order")
|
data = @.prepareBulkUpdateData(items, "sprint_order")
|
||||||
|
|
||||||
@rs.userstories.bulkUpdateSprintOrder(project, data).then =>
|
@rs.userstories.bulkUpdateSprintOrder(project, data).then (result) =>
|
||||||
@rootscope.$broadcast("sprint:us:moved", us, oldSprintId, newSprintId)
|
@rootscope.$broadcast("sprint:us:moved", us, oldSprintId, newSprintId)
|
||||||
|
|
||||||
@rs.userstories.bulkUpdateBacklogOrder(project, data).then =>
|
@rs.userstories.bulkUpdateBacklogOrder(project, data).then =>
|
||||||
for us in usList
|
for us in usList
|
||||||
@rootscope.$broadcast("sprint:us:moved", us, oldSprintId, newSprintId)
|
@rootscope.$broadcast("sprint:us:moved", us, oldSprintId, newSprintId)
|
||||||
|
|
||||||
|
if movedToClosedSprint || movedFromClosedSprint
|
||||||
|
@scope.$broadcast("backlog:load-closed-sprints")
|
||||||
|
|
||||||
promise.then null, ->
|
promise.then null, ->
|
||||||
console.log "FAIL" # TODO
|
console.log "FAIL" # TODO
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@ class RepositoryService extends taiga.Service
|
||||||
|
|
||||||
return defered.promise
|
return defered.promise
|
||||||
|
|
||||||
queryMany: (name, params, options={}) ->
|
queryMany: (name, params, options={}, headers=false) ->
|
||||||
url = @urls.resolve(name)
|
url = @urls.resolve(name)
|
||||||
httpOptions = {headers: {}}
|
httpOptions = {headers: {}}
|
||||||
|
|
||||||
|
@ -148,7 +148,12 @@ class RepositoryService extends taiga.Service
|
||||||
httpOptions.headers["x-disable-pagination"] = "1"
|
httpOptions.headers["x-disable-pagination"] = "1"
|
||||||
|
|
||||||
return @http.get(url, params, httpOptions).then (data) =>
|
return @http.get(url, params, httpOptions).then (data) =>
|
||||||
return _.map(data.data, (x) => @model.make_model(name, x))
|
result = _.map(data.data, (x) => @model.make_model(name, x))
|
||||||
|
|
||||||
|
if headers
|
||||||
|
return [result, data.headers]
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
queryOneAttribute: (name, id, attribute, params, options={}) ->
|
queryOneAttribute: (name, id, attribute, params, options={}) ->
|
||||||
url = @urls.resolve(name, id)
|
url = @urls.resolve(name, id)
|
||||||
|
|
|
@ -39,12 +39,20 @@ resourceProvider = ($repo, $model, $storage) ->
|
||||||
service.list = (projectId, filters) ->
|
service.list = (projectId, filters) ->
|
||||||
params = {"project": projectId}
|
params = {"project": projectId}
|
||||||
params = _.extend({}, params, filters or {})
|
params = _.extend({}, params, filters or {})
|
||||||
return $repo.queryMany("milestones", params).then (milestones) =>
|
return $repo.queryMany("milestones", params, {}, true).then (result) =>
|
||||||
|
milestones = result[0]
|
||||||
|
headers = result[1]
|
||||||
|
|
||||||
for m in milestones
|
for m in milestones
|
||||||
uses = m.user_stories
|
uses = m.user_stories
|
||||||
uses = _.map(uses, (u) => $model.make_model("userstories", u))
|
uses = _.map(uses, (u) => $model.make_model("userstories", u))
|
||||||
m._attrs.user_stories = uses
|
m._attrs.user_stories = uses
|
||||||
return milestones
|
|
||||||
|
return {
|
||||||
|
milestones: milestones,
|
||||||
|
closed: parseInt(headers("Taiga-Info-Total-Closed-Milestones"), 10),
|
||||||
|
open: parseInt(headers("Taiga-Info-Total-Opened-Milestones"), 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return (instance) ->
|
return (instance) ->
|
||||||
|
|
Loading…
Reference in New Issue