ignore deleted items in timeline
parent
ee99e20c82
commit
7209c5f70b
|
@ -24,9 +24,12 @@ class ProfileTimelineService extends taiga.Service
|
|||
'estimated_start'
|
||||
]
|
||||
|
||||
_isValidField: (values) =>
|
||||
_isValidField: (values) ->
|
||||
return _.some values, (value) => @._valid_fields.indexOf(value) != -1
|
||||
|
||||
_isValidEvent: (event) ->
|
||||
return event.split(".").slice(-1)[0] != 'delete'
|
||||
|
||||
_filterValidTimelineItems: (timeline) =>
|
||||
if timeline.data.values_diff
|
||||
values = Object.keys(timeline.data.values_diff)
|
||||
|
@ -38,6 +41,9 @@ class ProfileTimelineService extends taiga.Service
|
|||
timeline.data.values_diff.attachments.new.length == 0
|
||||
return false
|
||||
|
||||
if !@._isValidEvent(timeline.event_type)
|
||||
return false
|
||||
|
||||
return true
|
||||
|
||||
getTimeline: (userId, page) ->
|
||||
|
|
|
@ -40,6 +40,7 @@ describe "tgProfileTimelineService", ->
|
|||
valid_items = {
|
||||
data: [
|
||||
{ # valid item
|
||||
event_type: "xx.tt.create",
|
||||
data: {
|
||||
values_diff: {
|
||||
"status": "xx",
|
||||
|
@ -48,6 +49,7 @@ describe "tgProfileTimelineService", ->
|
|||
}
|
||||
},
|
||||
{ # invalid item
|
||||
event_type: "xx.tt.create",
|
||||
data: {
|
||||
values_diff: {
|
||||
"fake": "xx"
|
||||
|
@ -55,6 +57,7 @@ describe "tgProfileTimelineService", ->
|
|||
}
|
||||
},
|
||||
{ # invalid item
|
||||
event_type: "xx.tt.create",
|
||||
data: {
|
||||
values_diff: {
|
||||
"fake2": "xx"
|
||||
|
@ -62,6 +65,7 @@ describe "tgProfileTimelineService", ->
|
|||
}
|
||||
},
|
||||
{ # valid item
|
||||
event_type: "xx.tt.create",
|
||||
data: {
|
||||
values_diff: {
|
||||
"fake2": "xx",
|
||||
|
@ -70,6 +74,7 @@ describe "tgProfileTimelineService", ->
|
|||
}
|
||||
},
|
||||
{ # invalid item
|
||||
event_type: "xx.tt.create",
|
||||
data: {
|
||||
values_diff: {
|
||||
attachments: {
|
||||
|
@ -79,6 +84,17 @@ describe "tgProfileTimelineService", ->
|
|||
}
|
||||
},
|
||||
{ # valid item
|
||||
event_type: "xx.tt.create",
|
||||
data: {
|
||||
values_diff: {
|
||||
attachments: {
|
||||
new: [1, 2]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{ # invalid item
|
||||
event_type: "xx.tt.delete",
|
||||
data: {
|
||||
values_diff: {
|
||||
attachments: {
|
||||
|
@ -104,6 +120,7 @@ describe "tgProfileTimelineService", ->
|
|||
.then (_items_) ->
|
||||
items = _items_.toJS()
|
||||
|
||||
expect(items).to.have.length(3)
|
||||
expect(items[0]).to.be.eql(valid_items.data[0])
|
||||
expect(items[1]).to.be.eql(valid_items.data[3])
|
||||
expect(items[2]).to.be.eql(valid_items.data[5])
|
||||
|
|
Loading…
Reference in New Issue