diff --git a/app/coffee/modules/common.coffee b/app/coffee/modules/common.coffee
index 51853f07..798628b0 100644
--- a/app/coffee/modules/common.coffee
+++ b/app/coffee/modules/common.coffee
@@ -26,276 +26,6 @@ typeIsArray = @.taiga.typeIsArray
module = angular.module("taigaCommon", [])
-
-#############################################################################
-## Change (comment and history mode) directive
-#############################################################################
-
-ChangesDirective = ->
- containerTemplate = _.template("""
-
- <% if (showMoreEnabled){ %>
-
- <% } %>
-
- """) # TODO: i18n
- commentBaseTemplate = _.template("""
-
- """)
- changeBaseTemplate = _.template("""
-
- """)
- standardChangeFromToTemplate = _.template("""
-
-
- <%- name %>
-
-
-
- from
- <%= from %>
-
-
- to
- <%= to %>
-
-
-
- """) # TODO: i18n
- descriptionChangeTemplate = _.template("""
-
- """)
- pointsChangeTemplate = _.template("""
- <% _.each(points, function(point, name) { %>
-
-
- <%- name %> points
-
-
-
- from
- <%= point[0] %>
-
-
- to
- <%= point[1] %>
-
-
-
- <% }); %>
- """) # TODO: i18n
- attachmentTemplate = _.template("""
-
-
- <%- name %>
-
-
- <%- description %>
-
-
- """)
- link = ($scope, $el, $attrs, $model) ->
- $.uncollapsedEntries = null
- countChanges = (comment) ->
- return _.keys(comment.values_diff).length
-
- buildChangesText = (comment) ->
- size = countChanges(comment)
- if size == 1
- return "Made #{size} change" # TODO: i18n
- return "Made #{size} changes" # TODO: i18n
-
- renderEntries = (change, parentDomNode) ->
- _.each change.values_diff, (modification, name) ->
- if name == "description"
- parentDomNode.append(descriptionChangeTemplate({
- name: name
- diff: modification[1]
- }))
- else if name == "points"
- parentDomNode.append(pointsChangeTemplate({
- points: modification
- }))
- else if name == "attachments"
- _.each modification, (attachmentChanges, attachmentType) ->
- if attachmentType == "new"
- _.each attachmentChanges, (attachmentChange) ->
- parentDomNode.append(attachmentTemplate({
- name: "New attachment" # TODO: i18n
- description: attachmentChange.filename
- }))
- else if attachmentType == "deleted" # TODO: i18n
- _.each attachmentChanges, (attachmentChange) ->
- parentDomNode.append(attachmentTemplate({
- name: "Deleted attachment"
- description: attachmentChange.filename
- }))
- else
- name = "Updated attachment"
- _.each attachmentChanges, (attachmentChange) ->
- parentDomNode.append(attachmentTemplate({
- name: "Updated attachment" # TODO: i18n
- description: attachmentChange[0].filename
- }))
- else if name == "assigned_to"
- parentDomNode.append(standardChangeFromToTemplate({
- name: name
- from: prettyPrintModification(modification[0]) ? "Unassigned" # TODO: i18n
- to: prettyPrintModification(modification[1]) ? "Unassigned" # TODO: i18n
- }))
- else
- parentDomNode.append(standardChangeFromToTemplate({
- name: name
- from: prettyPrintModification(modification[0])
- to: prettyPrintModification(modification[1])
- }))
-
- renderComment = (comment, containerDomNode, hidden) ->
- html = commentBaseTemplate({
- avatar: getUserAvatar(comment.user.pk)
- userFullName: getUserFullName(comment.user.pk)
- creationDate: moment(comment.created_at).format("DD MMM YYYY HH:mm")
- comment: comment.comment_html
- changesText: buildChangesText(comment)
- hasChanges: countChanges(comment) > 0
- hidden: hidden
- })
- entryDomNode = $(html)
- activityContentDom = entryDomNode.find(".comment-content .us-activity")
- renderEntries(comment, activityContentDom)
- containerDomNode.append(entryDomNode)
-
- renderChange = (change, containerDomNode, hidden) ->
- html = changeBaseTemplate({
- avatar: getUserAvatar(change.user.pk)
- userFullName: getUserFullName(change.user.pk)
- creationDate: moment(change.created_at).format("DD MMM YYYY HH:mm")
- comment: change.comment_html
- hidden: hidden
- })
- entryDomNode = $(html)
- activityContentDom = entryDomNode.find(".activity-content")
- renderEntries(change, activityContentDom)
- containerDomNode.append(entryDomNode)
-
- getUserFullName = (userId) ->
- return $scope.usersById[userId]?.full_name_display
-
- getUserAvatar = (userId) ->
- return $scope.usersById[userId]?.photo
-
- prettyPrintModification = (value) ->
- if typeIsArray(value)
- if value.length == 0
- #TODO i18n
- return "None" # TODO: i18n
- return value.join(", ")
-
- if value == ""
- #TODO i18n
- return "None" # TODO: i18n
-
- return value
-
- $scope.$watch $attrs.ngModel, (changes) ->
- if not changes?
- return
-
- showMoreEnabled = $.uncollapsedEntries == null and changes.length > 2
- howManyMore = changes.length - 2
- html = containerTemplate({
- showMoreEnabled: showMoreEnabled
- howManyMore: howManyMore
- })
-
- containerDomNode = $(html)
- _.each changes, (change, index) ->
- hidden = showMoreEnabled and index < howManyMore
- if $attrs.mode == "comment"
- renderComment(change, containerDomNode, hidden)
- else
- renderChange(change, containerDomNode, hidden)
-
- $el.html(containerDomNode)
-
- $el.on "click", ".activity-title", (event) ->
- event.preventDefault()
- $el.find(".activity-inner").toggleClass("active")
-
- $el.on "click", ".show-more", (event) ->
- event.preventDefault()
- target = angular.element(event.currentTarget)
- target.hide()
- $el.find(".entry.hidden").removeClass("hidden")
- $.uncollapsedEntries = true
-
- $scope.$on "$destroy", ->
- $el.off()
-
- return {link:link, require:"ngModel"}
-
-module.directive("tgChanges", ChangesDirective)
-
-
#############################################################################
## Permission directive, hide elements when necessary
#############################################################################