US #55: Custom fields - Fix history of custom attributes values in detail pages

stable
David Barragán Merino 2015-03-04 12:20:21 +01:00
parent 910dac75b7
commit 82659f4809
5 changed files with 40 additions and 0 deletions

View File

@ -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()

View File

@ -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])

View File

@ -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

View File

@ -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}

View File

@ -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)