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