diff --git a/app/coffee/modules/common/custom-field-values.coffee b/app/coffee/modules/common/custom-field-values.coffee index bb8c4042..dd3e661b 100644 --- a/app/coffee/modules/common/custom-field-values.coffee +++ b/app/coffee/modules/common/custom-field-values.coffee @@ -59,6 +59,8 @@ class CustomAttributesValuesController extends taiga.Controller updateAttributeValue: (attributeValue) -> onSuccess = => + @rootscope.$broadcast("custom-attributes-values:edit") + onError = (response) => @confirm.notify("error") return @q.reject() diff --git a/app/coffee/modules/common/history.coffee b/app/coffee/modules/common/history.coffee index 0f7651b8..fcd1d961 100644 --- a/app/coffee/modules/common/history.coffee +++ b/app/coffee/modules/common/history.coffee @@ -173,6 +173,34 @@ HistoryDirective = ($log, $loading, $qqueue, $template, $confirm) -> return _.flatten(attachments).join("\n") + renderCustomAttributesEntry = (value) -> + customAttributes = _.map value, (changes, type) -> + if type == "new" + return _.map changes, (change) -> + return templateChangeGeneric({ + name: change.name, + from: formatChange(""), + to: formatChange(change.value) + }) + else if type == "deleted" + return _.map changes, (change) -> + # TODO: i18n + return templateChangeDiff({ + name: "deleted custom attribute", + diff: change.name + }) + else + return _.map changes, (change) -> + customAttrsChanges = _.map change.changes, (values) -> + return templateChangeGeneric({ + name: change.name + from: formatChange(values[0]) + to: formatChange(values[1]) + }) + return _.flatten(customAttrsChanges).join("\n") + + return _.flatten(customAttributes).join("\n") + renderChangeEntry = (field, value) -> if field == "description" return templateChangeDiff({name: getHumanizedFieldName("description"), diff: value[1]}) @@ -182,6 +210,8 @@ HistoryDirective = ($log, $loading, $qqueue, $template, $confirm) -> return templateChangePoints({points: value}) else if field == "attachments" return renderAttachmentEntry(value) + else if field == "custom_attributes" + return renderCustomAttributesEntry(value) else if field in ["tags", "watchers"] name = getHumanizedFieldName(field) removed = _.difference(value[0], value[1]) diff --git a/app/coffee/modules/issues/detail.coffee b/app/coffee/modules/issues/detail.coffee index eea923dc..2be4c7d7 100644 --- a/app/coffee/modules/issues/detail.coffee +++ b/app/coffee/modules/issues/detail.coffee @@ -85,6 +85,9 @@ class IssueDetailController extends mixOf(taiga.Controller, taiga.PageMixin) @rootscope.$broadcast("history:reload") @.loadIssue() + @scope.$on "custom-attributes-values:edit", => + @rootscope.$broadcast("history:reload") + initializeOnDeleteGoToUrl: -> ctx = {project: @scope.project.slug} if @scope.project.is_issues_activated diff --git a/app/coffee/modules/tasks/detail.coffee b/app/coffee/modules/tasks/detail.coffee index 1dd56d59..353fbaff 100644 --- a/app/coffee/modules/tasks/detail.coffee +++ b/app/coffee/modules/tasks/detail.coffee @@ -71,6 +71,8 @@ class TaskDetailController extends mixOf(taiga.Controller, taiga.PageMixin) @rootscope.$broadcast("history:reload") @scope.$on "attachment:delete", => @rootscope.$broadcast("history:reload") + @scope.$on "custom-attributes-values:edit", => + @rootscope.$broadcast("history:reload") initializeOnDeleteGoToUrl: -> ctx = {project: @scope.project.slug} diff --git a/app/coffee/modules/userstories/detail.coffee b/app/coffee/modules/userstories/detail.coffee index 6db4ccac..7347f72d 100644 --- a/app/coffee/modules/userstories/detail.coffee +++ b/app/coffee/modules/userstories/detail.coffee @@ -80,6 +80,9 @@ class UserStoryDetailController extends mixOf(taiga.Controller, taiga.PageMixin) @scope.$on "attachment:delete", => @rootscope.$broadcast("history:reload") + @scope.$on "custom-attributes-values:edit", => + @rootscope.$broadcast("history:reload") + initializeOnDeleteGoToUrl: -> ctx = {project: @scope.project.slug} @scope.onDeleteGoToUrl = @navUrls.resolve("project", ctx)