diff --git a/app/coffee/modules/issues/detail.coffee b/app/coffee/modules/issues/detail.coffee index 81e4c302..f2f99554 100644 --- a/app/coffee/modules/issues/detail.coffee +++ b/app/coffee/modules/issues/detail.coffee @@ -56,15 +56,20 @@ class IssueDetailController extends mixOf(taiga.Controller, taiga.PageMixin, tai promise = @.loadInitialData() - promise.then () => + # On Success + promise.then => @appTitle.set(@scope.issue.subject + " - " + @scope.project.name) - promise.then null, -> - console.log "FAIL" #TODO + # On Error + 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:edit", @loadHistory - @scope.$on "attachment:delete", @loadHistory + @scope.$on("attachment:create", => @.loadHistory()) + @scope.$on("attachment:edit", => @.loadHistory()) + @scope.$on("attachment:delete", => @.loadHistory()) loadProject: -> return @rs.projects.get(@scope.projectId).then (project) => @@ -102,8 +107,8 @@ class IssueDetailController extends mixOf(taiga.Controller, taiga.PageMixin, tai loadHistory: => return @rs.issues.history(@scope.issueId).then (history) => - _.each history, (historyResult) -> - #If description was modified take only the description_html field + for historyResult in history + # If description was modified take only the description_html field if historyResult.values_diff.description? 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 return data - promise.then null, => - @location.path("/not-found") - @location.replace() - return promise.then(=> @.loadProject()) - .then(=> @.loadUsersAndRoles()) - .then(=> @.loadIssue()) - .then(=> @.loadAttachments(@scope.issueId)) - .then(=> @.loadHistory()) + .then(=> @q.all([@.loadUsersAndRoles(), + @.loadIssue(), + @.loadAttachments(@scope.issueId), + @.loadHistory()])) block: -> @rootscope.$broadcast("block", @scope.issue)