Merge pull request #528 from taigaio/remove-task-milestone-timeline-event
remove the task milestone modification event from timelinestable
commit
e1d36a82c3
|
@ -6,6 +6,7 @@ class UserTimelineItemController
|
|||
|
||||
constructor: (@userTimelineItemType, @userTimelineItemTitle) ->
|
||||
timeline = @.timeline.toJS()
|
||||
|
||||
event = @.parseEventType(timeline.event_type)
|
||||
type = @userTimelineItemType.getType(timeline, event)
|
||||
|
||||
|
|
|
@ -5,6 +5,48 @@ class UserTimelineService extends taiga.Service
|
|||
|
||||
constructor: (@rs) ->
|
||||
|
||||
_invalid: [
|
||||
{# Items with only invalid fields
|
||||
check: (timeline) ->
|
||||
values_diff = timeline.get("data").get("values_diff")
|
||||
|
||||
if values_diff
|
||||
values = Object.keys(values_diff.toJS())
|
||||
|
||||
if values && values.length
|
||||
if _.every(values, (value) => @._valid_fields.indexOf(value) == -1)
|
||||
return true
|
||||
else if values[0] == 'attachments' &&
|
||||
values_diff.get('attachments').get('new').size == 0
|
||||
return true
|
||||
|
||||
return false
|
||||
},
|
||||
{# Deleted
|
||||
check: (timeline) ->
|
||||
event = timeline.get('event_type').split(".")
|
||||
return event[2] == 'delete'
|
||||
},
|
||||
{# Project change
|
||||
check: (timeline) ->
|
||||
event = timeline.get('event_type').split(".")
|
||||
return event[1] == 'project' && event[2] == 'change'
|
||||
},
|
||||
{# Comment deleted
|
||||
check: (timeline) ->
|
||||
return !!timeline.get("data").get("comment_deleted")
|
||||
},
|
||||
{# Task milestone
|
||||
check: (timeline) ->
|
||||
event = timeline.get('event_type').split(".")
|
||||
|
||||
if event[1] == "task" && event[2] == "change"
|
||||
return timeline.get("data").get("values_diff").get("milestone")
|
||||
|
||||
return false
|
||||
}
|
||||
]
|
||||
|
||||
_valid_fields: [
|
||||
'status',
|
||||
'subject',
|
||||
|
@ -24,50 +66,26 @@ class UserTimelineService extends taiga.Service
|
|||
'estimated_start'
|
||||
]
|
||||
|
||||
_isValidField: (values) ->
|
||||
return _.some values, (value) => @._valid_fields.indexOf(value) != -1
|
||||
|
||||
_isValidEvent: (event) ->
|
||||
event = event.split(".")
|
||||
|
||||
return event[2] != 'delete' && !(event[1] == 'project' && event[2] == 'change')
|
||||
|
||||
_filterValidTimelineItems: (timeline) ->
|
||||
if timeline.get("data")
|
||||
values = []
|
||||
values_diff = timeline.get("data").get("values_diff")
|
||||
|
||||
if values_diff
|
||||
values = Object.keys(values_diff.toJS())
|
||||
|
||||
if values && values.length
|
||||
if !@._isValidField(values)
|
||||
return false
|
||||
else if values[0] == 'attachments' &&
|
||||
values_diff.get('attachments').get('new').size == 0
|
||||
return false
|
||||
|
||||
if timeline.get("data").get("comment_deleted")
|
||||
return false
|
||||
|
||||
if !@._isValidEvent(timeline.get('event_type'))
|
||||
return false
|
||||
|
||||
return true
|
||||
_isInValidTimeline: (timeline) ->
|
||||
return _.some @._invalid, (invalid) =>
|
||||
return invalid.check.call(this, timeline)
|
||||
|
||||
getProfileTimeline: (userId, page) ->
|
||||
return @rs.users.getProfileTimeline(userId, page)
|
||||
.then (result) =>
|
||||
return result.filter (timeline) => @._filterValidTimelineItems(timeline)
|
||||
return result.filterNot (timeline) =>
|
||||
return @._isInValidTimeline(timeline)
|
||||
|
||||
getUserTimeline: (userId, page) ->
|
||||
return @rs.users.getUserTimeline(userId, page)
|
||||
.then (result) =>
|
||||
return result.filter (timeline) => @._filterValidTimelineItems(timeline)
|
||||
return result.filterNot (timeline) =>
|
||||
return @._isInValidTimeline(timeline)
|
||||
|
||||
getProjectTimeline: (projectId, page) ->
|
||||
return @rs.projects.getTimeline(projectId, page)
|
||||
.then (result) =>
|
||||
return result.filter (timeline) => @._filterValidTimelineItems(timeline)
|
||||
return result.filterNot (timeline) =>
|
||||
return @._isInValidTimeline(timeline)
|
||||
|
||||
angular.module("taigaUserTimeline").service("tgUserTimelineService", UserTimelineService)
|
||||
|
|
|
@ -122,6 +122,22 @@ describe "tgUserTimelineService", ->
|
|||
"subject": "xx"
|
||||
}
|
||||
}
|
||||
},
|
||||
{ # valid item
|
||||
event_type: "xx.task.change",
|
||||
data: {
|
||||
values_diff: {
|
||||
"name": "xx"
|
||||
}
|
||||
}
|
||||
},
|
||||
{ # invalid item
|
||||
event_type: "xx.task.change",
|
||||
data: {
|
||||
values_diff: {
|
||||
"milestone": "xx"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
|
@ -140,10 +156,11 @@ describe "tgUserTimelineService", ->
|
|||
.then (_items_) ->
|
||||
items = _items_.toJS()
|
||||
|
||||
expect(items).to.have.length(3)
|
||||
expect(items).to.have.length(4)
|
||||
expect(items[0]).to.be.eql(valid_items[0])
|
||||
expect(items[1]).to.be.eql(valid_items[3])
|
||||
expect(items[2]).to.be.eql(valid_items[5])
|
||||
expect(items[3]).to.be.eql(valid_items[9])
|
||||
|
||||
done()
|
||||
|
||||
|
@ -164,10 +181,11 @@ describe "tgUserTimelineService", ->
|
|||
.then (_items_) ->
|
||||
items = _items_.toJS()
|
||||
|
||||
expect(items).to.have.length(3)
|
||||
expect(items).to.have.length(4)
|
||||
expect(items[0]).to.be.eql(valid_items[0])
|
||||
expect(items[1]).to.be.eql(valid_items[3])
|
||||
expect(items[2]).to.be.eql(valid_items[5])
|
||||
expect(items[3]).to.be.eql(valid_items[9])
|
||||
|
||||
done()
|
||||
|
||||
|
@ -188,11 +206,11 @@ describe "tgUserTimelineService", ->
|
|||
.then (_items_) ->
|
||||
items = _items_.toJS()
|
||||
|
||||
expect(items).to.have.length(3)
|
||||
expect(items).to.have.length(4)
|
||||
expect(items[0]).to.be.eql(valid_items[0])
|
||||
expect(items[1]).to.be.eql(valid_items[3])
|
||||
expect(items[2]).to.be.eql(valid_items[5])
|
||||
|
||||
expect(items[3]).to.be.eql(valid_items[9])
|
||||
done()
|
||||
|
||||
$rootScope.$apply()
|
||||
|
|
Loading…
Reference in New Issue