From dce3e9873fbae4692ba636031ec76bac19c0cf27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Barrag=C3=A1n=20Merino?= Date: Fri, 22 Aug 2014 12:54:11 +0200 Subject: [PATCH] Fix #745: Reload history when add, update or delete attachments --- app/coffee/modules/controllerMixins.coffee | 3 +++ app/coffee/modules/issues/detail.coffee | 6 +++++- app/coffee/modules/tasks/detail.coffee | 6 +++++- app/coffee/modules/userstories/detail.coffee | 6 +++++- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/app/coffee/modules/controllerMixins.coffee b/app/coffee/modules/controllerMixins.coffee index e704f398..da19ece4 100644 --- a/app/coffee/modules/controllerMixins.coffee +++ b/app/coffee/modules/controllerMixins.coffee @@ -126,13 +126,16 @@ class AttachmentsMixin onCreateAttachment: (attachment) -> @scope.attachments[@scope.attachments.length] = attachment @.updateAttachmentsCounters() + @scope.$emit("attachment:create") onEditAttachment: (attachment) -> @.updateAttachmentsCounters() + @scope.$emit("attachment:edit") onDeleteAttachment: (attachment) -> index = @scope.attachments.indexOf(attachment) @scope.attachments.splice(index, 1) @.updateAttachmentsCounters() + @scope.$emit("attachment:delete") taiga.AttachmentsMixin = AttachmentsMixin diff --git a/app/coffee/modules/issues/detail.coffee b/app/coffee/modules/issues/detail.coffee index ac8d8cdc..03be5443 100644 --- a/app/coffee/modules/issues/detail.coffee +++ b/app/coffee/modules/issues/detail.coffee @@ -61,6 +61,10 @@ class IssueDetailController extends mixOf(taiga.Controller, taiga.PageMixin, tai promise.then null, -> console.log "FAIL" #TODO + @scope.$on "attachment:create", @loadHistory + @scope.$on "attachment:edit", @loadHistory + @scope.$on "attachment:delete", @loadHistory + loadProject: -> return @rs.projects.get(@scope.projectId).then (project) => @scope.project = project @@ -88,7 +92,7 @@ class IssueDetailController extends mixOf(taiga.Controller, taiga.PageMixin, tai @scope.previousUrl = "/project/#{projSlug}/issue/#{prev.ref}" if prev.id? @scope.nextUrl = "/project/#{projSlug}/issue/#{next.ref}" if next.id? - loadHistory: -> + loadHistory: => return @rs.issues.history(@scope.issueId).then (history) => _.each history.results, (historyResult) -> #If description was modified take only the description_html field diff --git a/app/coffee/modules/tasks/detail.coffee b/app/coffee/modules/tasks/detail.coffee index 2822d51e..99373497 100644 --- a/app/coffee/modules/tasks/detail.coffee +++ b/app/coffee/modules/tasks/detail.coffee @@ -58,6 +58,10 @@ class TaskDetailController extends mixOf(taiga.Controller, taiga.PageMixin, taig promise.then null, -> console.log "FAIL" #TODO + @scope.$on "attachment:create", @loadHistory + @scope.$on "attachment:edit", @loadHistory + @scope.$on "attachment:delete", @loadHistory + loadProject: -> return @rs.projects.get(@scope.projectId).then (project) => @scope.project = project @@ -79,7 +83,7 @@ class TaskDetailController extends mixOf(taiga.Controller, taiga.PageMixin, taig @scope.previousUrl = "/project/#{projSlug}/task/#{prev.ref}" if prev.id? @scope.nextUrl = "/project/#{projSlug}/task/#{next.ref}" if next.id? - loadHistory: -> + loadHistory: => return @rs.tasks.history(@scope.taskId).then (history) => _.each history.results, (historyResult) -> #If description was modified take only the description_html field diff --git a/app/coffee/modules/userstories/detail.coffee b/app/coffee/modules/userstories/detail.coffee index 8dc8ee4d..0ec3552c 100644 --- a/app/coffee/modules/userstories/detail.coffee +++ b/app/coffee/modules/userstories/detail.coffee @@ -59,6 +59,10 @@ class UserStoryDetailController extends mixOf(taiga.Controller, taiga.PageMixin, promise.then null, -> console.log "FAIL" #TODO + @scope.$on "attachment:create", @loadHistory + @scope.$on "attachment:edit", @loadHistory + @scope.$on "attachment:delete", @loadHistory + loadProject: -> return @rs.projects.get(@scope.projectId).then (project) => @scope.project = project @@ -87,7 +91,7 @@ class UserStoryDetailController extends mixOf(taiga.Controller, taiga.PageMixin, return @rs.tasks.list(@scope.projectId, null, @scope.usId).then (tasks) => @scope.tasks = tasks - loadHistory: -> + loadHistory: => return @rs.userstories.history(@scope.usId).then (history) => _.each history.results, (historyResult) -> #If description was modified take only the description_html field