Improve resource loading on issues detail.

stable
Andrey Antukh 2014-09-04 12:41:57 +02:00
parent 10457af144
commit a8f753af55
1 changed files with 17 additions and 16 deletions

View File

@ -56,15 +56,20 @@ class IssueDetailController extends mixOf(taiga.Controller, taiga.PageMixin, tai
promise = @.loadInitialData() promise = @.loadInitialData()
promise.then () => # On Success
promise.then =>
@appTitle.set(@scope.issue.subject + " - " + @scope.project.name) @appTitle.set(@scope.issue.subject + " - " + @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)
@scope.$on "attachment:create", @loadHistory @scope.$on("attachment:create", => @.loadHistory())
@scope.$on "attachment:edit", @loadHistory @scope.$on("attachment:edit", => @.loadHistory())
@scope.$on "attachment:delete", @loadHistory @scope.$on("attachment:delete", => @.loadHistory())
loadProject: -> loadProject: ->
return @rs.projects.get(@scope.projectId).then (project) => return @rs.projects.get(@scope.projectId).then (project) =>
@ -102,8 +107,8 @@ class IssueDetailController extends mixOf(taiga.Controller, taiga.PageMixin, tai
loadHistory: => loadHistory: =>
return @rs.issues.history(@scope.issueId).then (history) => return @rs.issues.history(@scope.issueId).then (history) =>
_.each history, (historyResult) -> for historyResult in history
#If description was modified take only the description_html field # If description was modified take only the description_html field
if historyResult.values_diff.description? if historyResult.values_diff.description?
historyResult.values_diff.description = historyResult.values_diff.description_diff historyResult.values_diff.description = historyResult.values_diff.description_diff
@ -124,15 +129,11 @@ class IssueDetailController extends mixOf(taiga.Controller, taiga.PageMixin, tai
@scope.issueId = data.issue @scope.issueId = data.issue
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(=> @.loadIssue()) @.loadIssue(),
.then(=> @.loadAttachments(@scope.issueId)) @.loadAttachments(@scope.issueId),
.then(=> @.loadHistory()) @.loadHistory()]))
block: -> block: ->
@rootscope.$broadcast("block", @scope.issue) @rootscope.$broadcast("block", @scope.issue)