rename profile-timeline to user-timeline
parent
280a209008
commit
b6d04a70b7
|
@ -392,9 +392,11 @@ modules = [
|
||||||
"taigaPlugins",
|
"taigaPlugins",
|
||||||
"taigaIntegrations",
|
"taigaIntegrations",
|
||||||
"taigaComponents",
|
"taigaComponents",
|
||||||
|
# new modules
|
||||||
"taigaProfile",
|
"taigaProfile",
|
||||||
"taigaHome",
|
"taigaHome",
|
||||||
"taigaPage",
|
"taigaPage",
|
||||||
|
"taigaUserTimeline",
|
||||||
|
|
||||||
# template cache
|
# template cache
|
||||||
"templates",
|
"templates",
|
||||||
|
|
|
@ -195,7 +195,6 @@ module.run([
|
||||||
"$tgWebhooksResourcesProvider",
|
"$tgWebhooksResourcesProvider",
|
||||||
"$tgWebhookLogsResourcesProvider",
|
"$tgWebhookLogsResourcesProvider",
|
||||||
"$tgLocalesResourcesProvider",
|
"$tgLocalesResourcesProvider",
|
||||||
"$tgTimelineResourcesProvider",
|
|
||||||
"$tgUsersResourcesProvider",
|
"$tgUsersResourcesProvider",
|
||||||
initResources
|
initResources
|
||||||
])
|
])
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
###
|
|
||||||
# Copyright (C) 2014 Andrey Antukh <niwi@niwi.be>
|
|
||||||
# Copyright (C) 2014 Jesús Espino Garcia <jespinog@gmail.com>
|
|
||||||
# Copyright (C) 2014 David Barragán Merino <bameda@dbarragan.com>
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Affero General Public License as
|
|
||||||
# published by the Free Software Foundation, either version 3 of the
|
|
||||||
# License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Affero General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
# File: modules/resources/timeline.coffee
|
|
||||||
###
|
|
||||||
|
|
||||||
taiga = @.taiga
|
|
||||||
|
|
||||||
resourceProvider = ($repo) ->
|
|
||||||
service = {}
|
|
||||||
|
|
||||||
service.profile = (userId, page) ->
|
|
||||||
params = {
|
|
||||||
page: page
|
|
||||||
}
|
|
||||||
|
|
||||||
return $repo.queryOnePaginatedRaw("timeline-profile", userId, params)
|
|
||||||
|
|
||||||
return (instance) ->
|
|
||||||
instance.timeline = service
|
|
||||||
|
|
||||||
|
|
||||||
module = angular.module("taigaResources")
|
|
||||||
module.factory("$tgTimelineResourcesProvider", ["$tgRepo", resourceProvider])
|
|
|
@ -1,13 +0,0 @@
|
||||||
ProfileTimelineItemDirective = () ->
|
|
||||||
return {
|
|
||||||
controllerAs: "vm"
|
|
||||||
controller: "ProfileTimelineItem"
|
|
||||||
bindToController: true
|
|
||||||
templateUrl: "profile/profile-timeline-item/profile-timeline-item.html"
|
|
||||||
scope: {
|
|
||||||
timeline: "=tgProfileTimelineItem"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
angular.module("taigaProfile")
|
|
||||||
.directive("tgProfileTimelineItem", ProfileTimelineItemDirective)
|
|
|
@ -1,9 +0,0 @@
|
||||||
ProfileTimelineDirective = ->
|
|
||||||
return {
|
|
||||||
templateUrl: "profile/profile-timeline/profile-timeline.html",
|
|
||||||
controller: "ProfileTimeline",
|
|
||||||
controllerAs: "vm",
|
|
||||||
scope: {}
|
|
||||||
}
|
|
||||||
|
|
||||||
angular.module("taigaProfile").directive("tgProfileTimeline", ProfileTimelineDirective)
|
|
|
@ -1,57 +0,0 @@
|
||||||
taiga = @.taiga
|
|
||||||
|
|
||||||
class ProfileTimelineService extends taiga.Service
|
|
||||||
@.$inject = ["$tgResources"]
|
|
||||||
|
|
||||||
constructor: (@rs) ->
|
|
||||||
|
|
||||||
_valid_fields: [
|
|
||||||
'status',
|
|
||||||
'subject',
|
|
||||||
'description',
|
|
||||||
'assigned_to',
|
|
||||||
'points',
|
|
||||||
'severity',
|
|
||||||
'priority',
|
|
||||||
'type',
|
|
||||||
'attachments',
|
|
||||||
'milestone',
|
|
||||||
'is_blocked',
|
|
||||||
'is_iocaine',
|
|
||||||
'content_diff',
|
|
||||||
'name',
|
|
||||||
'estimated_finish',
|
|
||||||
'estimated_start'
|
|
||||||
]
|
|
||||||
|
|
||||||
_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)
|
|
||||||
|
|
||||||
if values && values.length
|
|
||||||
if !@._isValidField(values)
|
|
||||||
return false
|
|
||||||
else if values[0] == 'attachments' &&
|
|
||||||
timeline.data.values_diff.attachments.new.length == 0
|
|
||||||
return false
|
|
||||||
|
|
||||||
if !@._isValidEvent(timeline.event_type)
|
|
||||||
return false
|
|
||||||
|
|
||||||
return true
|
|
||||||
|
|
||||||
getTimeline: (userId, page) ->
|
|
||||||
return @rs.timeline.profile(userId, page)
|
|
||||||
.then (result) =>
|
|
||||||
newTimelineList = _.filter result.data, @._filterValidTimelineItems
|
|
||||||
|
|
||||||
return Immutable.fromJS(newTimelineList)
|
|
||||||
|
|
||||||
|
|
||||||
angular.module("taigaProjects").service("tgProfileTimelineService", ProfileTimelineService)
|
|
|
@ -4,7 +4,7 @@ div.profile.centered
|
||||||
div.main
|
div.main
|
||||||
div.timeline-wrapper(tg-profile-tabs)
|
div.timeline-wrapper(tg-profile-tabs)
|
||||||
div(tg-profile-tab="activity", tab-title="{{'USER.PROFILE.ACTIVITY_TAB' | translate}}", tab-icon="icon-timeline", tab-active)
|
div(tg-profile-tab="activity", tab-title="{{'USER.PROFILE.ACTIVITY_TAB' | translate}}", tab-icon="icon-timeline", tab-active)
|
||||||
div(tg-profile-timeline)
|
div(tg-user-timeline)
|
||||||
|
|
||||||
div(tg-profile-tab="projects", tab-title="{{'USER.PROFILE.PROJECTS_TAB' | translate}}", tab-icon="icon-project")
|
div(tg-profile-tab="projects", tab-title="{{'USER.PROFILE.PROJECTS_TAB' | translate}}", tab-icon="icon-project")
|
||||||
div(tg-profile-projects)
|
div(tg-profile-projects)
|
||||||
|
|
|
@ -37,6 +37,17 @@ Resource = (urlsService, http) ->
|
||||||
.then (result) ->
|
.then (result) ->
|
||||||
return Immutable.fromJS(result.data)
|
return Immutable.fromJS(result.data)
|
||||||
|
|
||||||
|
service.getTimeline = (userId, page) ->
|
||||||
|
params = {
|
||||||
|
page: page
|
||||||
|
}
|
||||||
|
|
||||||
|
url = urlsService.resolve("timeline-profile")
|
||||||
|
url = "#{url}/#{userId}"
|
||||||
|
|
||||||
|
return http.get(url, params).then (result) =>
|
||||||
|
return Immutable.fromJS(result.data)
|
||||||
|
|
||||||
return () ->
|
return () ->
|
||||||
return {"users": service}
|
return {"users": service}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
ProfileTimelineAttachmentDirective = (template, $compile) ->
|
UserTimelineAttachmentDirective = (template, $compile) ->
|
||||||
validFileExtensions = [".jpg", ".jpeg", ".bmp", ".gif", ".png"]
|
validFileExtensions = [".jpg", ".jpeg", ".bmp", ".gif", ".png"]
|
||||||
|
|
||||||
isImage = (url) ->
|
isImage = (url) ->
|
||||||
|
@ -11,9 +11,9 @@ ProfileTimelineAttachmentDirective = (template, $compile) ->
|
||||||
is_image = isImage(scope.attachment.url)
|
is_image = isImage(scope.attachment.url)
|
||||||
|
|
||||||
if is_image
|
if is_image
|
||||||
templateHtml = template.get("profile/profile-timeline-attachment/profile-timeline-attachment-image.html")
|
templateHtml = template.get("user-timeline/user-timeline-attachment/user-timeline-attachment-image.html")
|
||||||
else
|
else
|
||||||
templateHtml = template.get("profile/profile-timeline-attachment/profile-timeline-attachment.html")
|
templateHtml = template.get("user-timeline/user-timeline-attachment/user-timeline-attachment.html")
|
||||||
|
|
||||||
el.html(templateHtml)
|
el.html(templateHtml)
|
||||||
$compile(el.contents())(scope)
|
$compile(el.contents())(scope)
|
||||||
|
@ -23,14 +23,14 @@ ProfileTimelineAttachmentDirective = (template, $compile) ->
|
||||||
return {
|
return {
|
||||||
link: link
|
link: link
|
||||||
scope: {
|
scope: {
|
||||||
attachment: "=tgProfileTimelineAttachment"
|
attachment: "=tgUserTimelineAttachment"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileTimelineAttachmentDirective.$inject = [
|
UserTimelineAttachmentDirective.$inject = [
|
||||||
"$tgTemplate",
|
"$tgTemplate",
|
||||||
"$compile"
|
"$compile"
|
||||||
]
|
]
|
||||||
|
|
||||||
angular.module("taigaProfile")
|
angular.module("taigaUserTimeline")
|
||||||
.directive("tgProfileTimelineAttachment", ProfileTimelineAttachmentDirective)
|
.directive("tgUserTimelineAttachment", UserTimelineAttachmentDirective)
|
|
@ -1,7 +1,7 @@
|
||||||
describe "profileTimelineAttachmentDirective", () ->
|
describe "userTimelineAttachmentDirective", () ->
|
||||||
element = scope = compile = provide = null
|
element = scope = compile = provide = null
|
||||||
mockTgTemplate = null
|
mockTgTemplate = null
|
||||||
template = "<div tg-profile-timeline-attachment='attachment'></div>"
|
template = "<div tg-user-timeline-attachment='attachment'></div>"
|
||||||
|
|
||||||
_mockTgTemplate= () ->
|
_mockTgTemplate= () ->
|
||||||
mockTgTemplate = {
|
mockTgTemplate = {
|
||||||
|
@ -23,7 +23,7 @@ describe "profileTimelineAttachmentDirective", () ->
|
||||||
return elm
|
return elm
|
||||||
|
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
module "taigaProfile"
|
module "taigaUserTimeline"
|
||||||
|
|
||||||
_mocks()
|
_mocks()
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ describe "profileTimelineAttachmentDirective", () ->
|
||||||
}
|
}
|
||||||
|
|
||||||
mockTgTemplate.get
|
mockTgTemplate.get
|
||||||
.withArgs("profile/profile-timeline-attachment/profile-timeline-attachment-image.html")
|
.withArgs("user-timeline/user-timeline-attachment/user-timeline-attachment-image.html")
|
||||||
.returns("<div id='image'></div>")
|
.returns("<div id='image'></div>")
|
||||||
|
|
||||||
elm = createDirective()
|
elm = createDirective()
|
||||||
|
@ -50,7 +50,7 @@ describe "profileTimelineAttachmentDirective", () ->
|
||||||
}
|
}
|
||||||
|
|
||||||
mockTgTemplate.get
|
mockTgTemplate.get
|
||||||
.withArgs("profile/profile-timeline-attachment/profile-timeline-attachment.html")
|
.withArgs("user-timeline/user-timeline-attachment/user-timeline-attachment.html")
|
||||||
.returns("<div id='file'></div>")
|
.returns("<div id='file'></div>")
|
||||||
|
|
||||||
elm = createDirective()
|
elm = createDirective()
|
|
@ -1,4 +1,4 @@
|
||||||
class ProfileTimelineItemTitle
|
class UserTimelineItemTitle
|
||||||
@.$inject = [
|
@.$inject = [
|
||||||
"$translate"
|
"$translate"
|
||||||
]
|
]
|
||||||
|
@ -87,5 +87,5 @@ class ProfileTimelineItemTitle
|
||||||
getTitle: (timeline, event, type) ->
|
getTitle: (timeline, event, type) ->
|
||||||
return @translate.instant(type.key, @._getParams(timeline, event, type))
|
return @translate.instant(type.key, @._getParams(timeline, event, type))
|
||||||
|
|
||||||
angular.module("taigaProfile")
|
angular.module("taigaUserTimeline")
|
||||||
.service("tgProfileTimelineItemTitle", ProfileTimelineItemTitle)
|
.service("tgUserTimelineItemTitle", UserTimelineItemTitle)
|
|
@ -1,4 +1,4 @@
|
||||||
describe "tgProfileTimelineItemTitle", ->
|
describe "tgUserTimelineItemTitle", ->
|
||||||
mySvc = null
|
mySvc = null
|
||||||
mockTranslate = null
|
mockTranslate = null
|
||||||
timeline = event = type = null
|
timeline = event = type = null
|
||||||
|
@ -20,15 +20,15 @@ describe "tgProfileTimelineItemTitle", ->
|
||||||
_mockTranslate()
|
_mockTranslate()
|
||||||
|
|
||||||
_inject = ->
|
_inject = ->
|
||||||
inject (_tgProfileTimelineItemTitle_) ->
|
inject (_tgUserTimelineItemTitle_) ->
|
||||||
mySvc = _tgProfileTimelineItemTitle_
|
mySvc = _tgUserTimelineItemTitle_
|
||||||
|
|
||||||
_setup = ->
|
_setup = ->
|
||||||
_mocks()
|
_mocks()
|
||||||
_inject()
|
_inject()
|
||||||
|
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
module "taigaProfile"
|
module "taigaUserTimeline"
|
||||||
_setup()
|
_setup()
|
||||||
|
|
||||||
it "title with username", () ->
|
it "title with username", () ->
|
|
@ -150,8 +150,8 @@ timelineType = (timeline, event) ->
|
||||||
return _.find types, (obj) ->
|
return _.find types, (obj) ->
|
||||||
return obj.check(timeline, event, field_name)
|
return obj.check(timeline, event, field_name)
|
||||||
|
|
||||||
class ProfileTimelineType
|
class UserTimelineType
|
||||||
getType: (timeline, event) -> timelineType(timeline, event)
|
getType: (timeline, event) -> timelineType(timeline, event)
|
||||||
|
|
||||||
angular.module("taigaProfile")
|
angular.module("taigaUserTimeline")
|
||||||
.service("tgProfileTimelineItemType", ProfileTimelineType)
|
.service("tgUserTimelineItemType", UserTimelineType)
|
|
@ -1,4 +1,4 @@
|
||||||
describe "tgProfileTimelineItemType", ->
|
describe "tgUserTimelineItemType", ->
|
||||||
mySvc = null
|
mySvc = null
|
||||||
|
|
||||||
_provide = (callback) ->
|
_provide = (callback) ->
|
||||||
|
@ -7,14 +7,14 @@ describe "tgProfileTimelineItemType", ->
|
||||||
return null
|
return null
|
||||||
|
|
||||||
_inject = ->
|
_inject = ->
|
||||||
inject (_tgProfileTimelineItemType_) ->
|
inject (_tgUserTimelineItemType_) ->
|
||||||
mySvc = _tgProfileTimelineItemType_
|
mySvc = _tgUserTimelineItemType_
|
||||||
|
|
||||||
_setup = ->
|
_setup = ->
|
||||||
_inject()
|
_inject()
|
||||||
|
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
module "taigaProfile"
|
module "taigaUserTimeline"
|
||||||
_setup()
|
_setup()
|
||||||
|
|
||||||
it "get the timeline type", () ->
|
it "get the timeline type", () ->
|
|
@ -1,21 +1,21 @@
|
||||||
class ProfileTimelineItemController
|
class UserTimelineItemController
|
||||||
@.$inject = [
|
@.$inject = [
|
||||||
"$sce",
|
"$sce",
|
||||||
"tgProfileTimelineItemType",
|
"tgUserTimelineItemType",
|
||||||
"tgProfileTimelineItemTitle"
|
"tgUserTimelineItemTitle"
|
||||||
]
|
]
|
||||||
|
|
||||||
constructor: (@sce, @profileTimelineItemType, @profileTimelineItemTitle) ->
|
constructor: (@sce, @userTimelineItemType, @userTimelineItemTitle) ->
|
||||||
timeline = @.timeline.toJS()
|
timeline = @.timeline.toJS()
|
||||||
event = @.parseEventType(timeline.event_type)
|
event = @.parseEventType(timeline.event_type)
|
||||||
type = @profileTimelineItemType.getType(timeline, event)
|
type = @userTimelineItemType.getType(timeline, event)
|
||||||
|
|
||||||
@.activity = {}
|
@.activity = {}
|
||||||
|
|
||||||
@.activity.user = timeline.data.user
|
@.activity.user = timeline.data.user
|
||||||
@.activity.project = timeline.data.project
|
@.activity.project = timeline.data.project
|
||||||
@.activity.sprint = timeline.data.milestone
|
@.activity.sprint = timeline.data.milestone
|
||||||
@.activity.title = @profileTimelineItemTitle.getTitle(timeline, event, type)
|
@.activity.title = @userTimelineItemTitle.getTitle(timeline, event, type)
|
||||||
@.activity.created_formated = moment(timeline.created).fromNow()
|
@.activity.created_formated = moment(timeline.created).fromNow()
|
||||||
@.activity.obj = @.getObject(timeline, event)
|
@.activity.obj = @.getObject(timeline, event)
|
||||||
|
|
||||||
|
@ -41,5 +41,5 @@ class ProfileTimelineItemController
|
||||||
if timeline.data[event.obj]
|
if timeline.data[event.obj]
|
||||||
return timeline.data[event.obj]
|
return timeline.data[event.obj]
|
||||||
|
|
||||||
angular.module("taigaProfile")
|
angular.module("taigaUserTimeline")
|
||||||
.controller("ProfileTimelineItem", ProfileTimelineItemController)
|
.controller("UserTimelineItem", UserTimelineItemController)
|
|
@ -1,12 +1,12 @@
|
||||||
describe "ProfileTimelineItemController", ->
|
describe "UserTimelineItemController", ->
|
||||||
controller = scope = provide = null
|
controller = scope = provide = null
|
||||||
timeline = event = null
|
timeline = event = null
|
||||||
mockTgProfileTimelineItemType = null
|
mockTgUserTimelineItemType = null
|
||||||
mockTgProfileTimelineItemTitle = null
|
mockTgUserTimelineItemTitle = null
|
||||||
mockType = null
|
mockType = null
|
||||||
|
|
||||||
_mockTgProfileTimelineItemType = () ->
|
_mockTgUserTimelineItemType = () ->
|
||||||
mockTgProfileTimelineItemType = {
|
mockTgUserTimelineItemType = {
|
||||||
getType: sinon.stub()
|
getType: sinon.stub()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,24 +15,24 @@ describe "ProfileTimelineItemController", ->
|
||||||
member: sinon.stub()
|
member: sinon.stub()
|
||||||
}
|
}
|
||||||
|
|
||||||
mockTgProfileTimelineItemType.getType.withArgs(timeline).returns(mockType)
|
mockTgUserTimelineItemType.getType.withArgs(timeline).returns(mockType)
|
||||||
|
|
||||||
provide.value "tgProfileTimelineItemType", mockTgProfileTimelineItemType
|
provide.value "tgUserTimelineItemType", mockTgUserTimelineItemType
|
||||||
|
|
||||||
_mockTgProfileTimelineItemTitle = () ->
|
_mockTgUserTimelineItemTitle = () ->
|
||||||
mockTgProfileTimelineItemTitle = {
|
mockTgUserTimelineItemTitle = {
|
||||||
getTitle: sinon.stub()
|
getTitle: sinon.stub()
|
||||||
}
|
}
|
||||||
|
|
||||||
mockTgProfileTimelineItemTitle.getTitle.withArgs(timeline, event, mockType).returns("fakeTitle")
|
mockTgUserTimelineItemTitle.getTitle.withArgs(timeline, event, mockType).returns("fakeTitle")
|
||||||
|
|
||||||
provide.value "tgProfileTimelineItemTitle", mockTgProfileTimelineItemTitle
|
provide.value "tgUserTimelineItemTitle", mockTgUserTimelineItemTitle
|
||||||
|
|
||||||
_mocks = () ->
|
_mocks = () ->
|
||||||
module ($provide) ->
|
module ($provide) ->
|
||||||
provide = $provide
|
provide = $provide
|
||||||
_mockTgProfileTimelineItemType()
|
_mockTgUserTimelineItemType()
|
||||||
_mockTgProfileTimelineItemTitle()
|
_mockTgUserTimelineItemTitle()
|
||||||
|
|
||||||
return null
|
return null
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ describe "ProfileTimelineItemController", ->
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
module "taigaProfile"
|
module "taigaUserTimeline"
|
||||||
|
|
||||||
_setup()
|
_setup()
|
||||||
_mocks()
|
_mocks()
|
||||||
|
@ -73,7 +73,7 @@ describe "ProfileTimelineItemController", ->
|
||||||
timeline = scope.vm.timeline
|
timeline = scope.vm.timeline
|
||||||
timeline_immutable = Immutable.fromJS(timeline)
|
timeline_immutable = Immutable.fromJS(timeline)
|
||||||
|
|
||||||
myCtrl = controller("ProfileTimelineItem", {$scope: scope}, {timeline: timeline_immutable})
|
myCtrl = controller("UserTimelineItem", {$scope: scope}, {timeline: timeline_immutable})
|
||||||
|
|
||||||
expect(myCtrl.activity.user).to.be.equal(timeline.data.user)
|
expect(myCtrl.activity.user).to.be.equal(timeline.data.user)
|
||||||
expect(myCtrl.activity.project).to.be.equal(timeline.data.project)
|
expect(myCtrl.activity.project).to.be.equal(timeline.data.project)
|
||||||
|
@ -97,7 +97,7 @@ describe "ProfileTimelineItemController", ->
|
||||||
|
|
||||||
timeline_immutable = Immutable.fromJS(timeline)
|
timeline_immutable = Immutable.fromJS(timeline)
|
||||||
|
|
||||||
myCtrl = controller("ProfileTimelineItem", {$scope: scope}, {timeline: timeline_immutable})
|
myCtrl = controller("UserTimelineItem", {$scope: scope}, {timeline: timeline_immutable})
|
||||||
|
|
||||||
expect(myCtrl.activity.description).to.be.an('object') # $sce.trustAsHtml
|
expect(myCtrl.activity.description).to.be.an('object') # $sce.trustAsHtml
|
||||||
expect(myCtrl.activity.member).to.be.equal(member)
|
expect(myCtrl.activity.member).to.be.equal(member)
|
|
@ -0,0 +1,13 @@
|
||||||
|
UserTimelineItemDirective = () ->
|
||||||
|
return {
|
||||||
|
controllerAs: "vm"
|
||||||
|
controller: "UserTimelineItem"
|
||||||
|
bindToController: true
|
||||||
|
templateUrl: "user-timeline/user-timeline-item/user-timeline-item.html"
|
||||||
|
scope: {
|
||||||
|
timeline: "=tgUserTimelineItem"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
angular.module("taigaUserTimeline")
|
||||||
|
.directive("tgUserTimelineItem", UserTimelineItemDirective)
|
|
@ -19,4 +19,4 @@ div.activity-item
|
||||||
p {{::vm.activity.member.role.name}}
|
p {{::vm.activity.member.role.name}}
|
||||||
|
|
||||||
div(ng-repeat="attachment in vm.activity.attachments")
|
div(ng-repeat="attachment in vm.activity.attachments")
|
||||||
div(tg-profile-timeline-attachment="attachment")
|
div(tg-user-timeline-attachment="attachment")
|
|
@ -0,0 +1 @@
|
||||||
|
angular.module("taigaUserTimeline", [])
|
|
@ -23,13 +23,13 @@ taiga = @.taiga
|
||||||
|
|
||||||
mixOf = @.taiga.mixOf
|
mixOf = @.taiga.mixOf
|
||||||
|
|
||||||
class ProfileTimelineController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.FiltersMixin)
|
class UserTimelineController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.FiltersMixin)
|
||||||
@.$inject = [
|
@.$inject = [
|
||||||
"$tgAuth",
|
"$tgAuth",
|
||||||
"tgProfileTimelineService"
|
"tgUserTimelineService"
|
||||||
]
|
]
|
||||||
|
|
||||||
constructor: (@auth, @profileTimelineService) ->
|
constructor: (@auth, @userTimelineService) ->
|
||||||
@.timelineList = Immutable.List()
|
@.timelineList = Immutable.List()
|
||||||
@.page = 1
|
@.page = 1
|
||||||
@.loadingData = false
|
@.loadingData = false
|
||||||
|
@ -39,12 +39,12 @@ class ProfileTimelineController extends mixOf(taiga.Controller, taiga.PageMixin,
|
||||||
|
|
||||||
@.loadingData = true
|
@.loadingData = true
|
||||||
|
|
||||||
@profileTimelineService
|
@userTimelineService
|
||||||
.getTimeline(user.id, @.page)
|
.getTimeline(user.id, @.page)
|
||||||
.then (newTimelineList) =>
|
.then (newTimelineList) =>
|
||||||
@.timelineList = @.timelineList.concat(newTimelineList)
|
@.timelineList = @.timelineList.concat(newTimelineList)
|
||||||
@.page++
|
@.page++
|
||||||
@.loadingData = false
|
@.loadingData = false
|
||||||
|
|
||||||
angular.module("taigaProfile")
|
angular.module("taigaUserTimeline")
|
||||||
.controller("ProfileTimeline", ProfileTimelineController)
|
.controller("UserTimeline", UserTimelineController)
|
|
@ -1,16 +1,16 @@
|
||||||
describe "ProfileTimelineController", ->
|
describe "UserTimelineController", ->
|
||||||
myCtrl = scope = $q = provide = null
|
myCtrl = scope = $q = provide = null
|
||||||
|
|
||||||
mocks = {}
|
mocks = {}
|
||||||
|
|
||||||
mockUser = {id: 3}
|
mockUser = {id: 3}
|
||||||
|
|
||||||
_mockProfileTimeline = () ->
|
_mockUserTimeline = () ->
|
||||||
mocks.profileTimelineService = {
|
mocks.userTimelineService = {
|
||||||
getTimeline: sinon.stub()
|
getTimeline: sinon.stub()
|
||||||
}
|
}
|
||||||
|
|
||||||
provide.value "tgProfileTimelineService", mocks.profileTimelineService
|
provide.value "tgUserTimelineService", mocks.userTimelineService
|
||||||
|
|
||||||
_mockTgAuth = () ->
|
_mockTgAuth = () ->
|
||||||
provide.value "$tgAuth", {
|
provide.value "$tgAuth", {
|
||||||
|
@ -21,19 +21,19 @@ describe "ProfileTimelineController", ->
|
||||||
_mocks = () ->
|
_mocks = () ->
|
||||||
module ($provide) ->
|
module ($provide) ->
|
||||||
provide = $provide
|
provide = $provide
|
||||||
_mockProfileTimeline()
|
_mockUserTimeline()
|
||||||
_mockTgAuth()
|
_mockTgAuth()
|
||||||
|
|
||||||
return null
|
return null
|
||||||
|
|
||||||
|
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
module "taigaProfile"
|
module "taigaUserTimeline"
|
||||||
_mocks()
|
_mocks()
|
||||||
|
|
||||||
inject ($controller, _$q_) ->
|
inject ($controller, _$q_) ->
|
||||||
$q = _$q_
|
$q = _$q_
|
||||||
myCtrl = $controller "ProfileTimeline"
|
myCtrl = $controller "UserTimeline"
|
||||||
|
|
||||||
it "timelineList should be an array", () ->
|
it "timelineList should be an array", () ->
|
||||||
expect(myCtrl.timelineList.toJS()).is.an("array")
|
expect(myCtrl.timelineList.toJS()).is.an("array")
|
||||||
|
@ -54,14 +54,12 @@ describe "ProfileTimelineController", ->
|
||||||
|
|
||||||
thenStub = sinon.stub()
|
thenStub = sinon.stub()
|
||||||
|
|
||||||
profileStub = sinon.stub()
|
mocks.userTimelineService.getTimeline = sinon.stub()
|
||||||
.withArgs(mockUser.id, myCtrl.page)
|
.withArgs(mockUser.id, myCtrl.page)
|
||||||
.returns({
|
.returns({
|
||||||
then: thenStub
|
then: thenStub
|
||||||
})
|
})
|
||||||
|
|
||||||
mocks.profileTimelineService.getTimeline = profileStub
|
|
||||||
|
|
||||||
it "the loadingData variable must be true during the timeline load", () ->
|
it "the loadingData variable must be true during the timeline load", () ->
|
||||||
expect(myCtrl.loadingData).to.be.false
|
expect(myCtrl.loadingData).to.be.false
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
UserTimelineDirective = ->
|
||||||
|
return {
|
||||||
|
templateUrl: "user-timeline/user-timeline/user-timeline.html",
|
||||||
|
controller: "UserTimeline",
|
||||||
|
controllerAs: "vm",
|
||||||
|
scope: {}
|
||||||
|
}
|
||||||
|
|
||||||
|
angular.module("taigaProfile").directive("tgUserTimeline", UserTimelineDirective)
|
|
@ -1,3 +1,3 @@
|
||||||
section.profile-timeline
|
section.profile-timeline
|
||||||
div(infinite-scroll="vm.loadTimeline()", infinite-scroll-distance="3", infinite-scroll-disabled="vm.loadingData")
|
div(infinite-scroll="vm.loadTimeline()", infinite-scroll-distance="3", infinite-scroll-disabled="vm.loadingData")
|
||||||
div(tg-repeat="timeline in vm.timelineList", tg-profile-timeline-item="timeline")
|
div(tg-repeat="timeline in vm.timelineList", tg-user-timeline-item="timeline")
|
|
@ -0,0 +1,58 @@
|
||||||
|
taiga = @.taiga
|
||||||
|
|
||||||
|
class UserTimelineService extends taiga.Service
|
||||||
|
@.$inject = ["tgResources"]
|
||||||
|
|
||||||
|
constructor: (@rs) ->
|
||||||
|
|
||||||
|
_valid_fields: [
|
||||||
|
'status',
|
||||||
|
'subject',
|
||||||
|
'description',
|
||||||
|
'assigned_to',
|
||||||
|
'points',
|
||||||
|
'severity',
|
||||||
|
'priority',
|
||||||
|
'type',
|
||||||
|
'attachments',
|
||||||
|
'milestone',
|
||||||
|
'is_blocked',
|
||||||
|
'is_iocaine',
|
||||||
|
'content_diff',
|
||||||
|
'name',
|
||||||
|
'estimated_finish',
|
||||||
|
'estimated_start'
|
||||||
|
]
|
||||||
|
|
||||||
|
_isValidField: (values) ->
|
||||||
|
return _.some values, (value) => @._valid_fields.indexOf(value) != -1
|
||||||
|
|
||||||
|
_isValidEvent: (event) ->
|
||||||
|
return event.split(".").slice(-1)[0] != 'delete'
|
||||||
|
|
||||||
|
_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 !@._isValidEvent(timeline.get('event_type'))
|
||||||
|
return false
|
||||||
|
|
||||||
|
return true
|
||||||
|
|
||||||
|
getTimeline: (userId, page) ->
|
||||||
|
return @rs.users.getTimeline(userId, page)
|
||||||
|
.then (result) =>
|
||||||
|
return result.filter (timeline) => @._filterValidTimelineItems(timeline)
|
||||||
|
|
||||||
|
angular.module("taigaUserTimeline").service("tgUserTimelineService", UserTimelineService)
|
|
@ -1,18 +1,18 @@
|
||||||
describe "tgProfileTimelineService", ->
|
describe "tgUserTimelineService", ->
|
||||||
provide = null
|
provide = null
|
||||||
$q = null
|
$q = null
|
||||||
$rootScope = null
|
$rootScope = null
|
||||||
profileTimelineService = null
|
userTimelineService = null
|
||||||
mocks = {}
|
mocks = {}
|
||||||
|
|
||||||
_mockResources = () ->
|
_mockResources = () ->
|
||||||
mocks.resources = {}
|
mocks.resources = {}
|
||||||
|
|
||||||
mocks.resources.timeline = {
|
mocks.resources.users = {
|
||||||
profile: sinon.stub()
|
getTimeline: sinon.stub()
|
||||||
}
|
}
|
||||||
|
|
||||||
provide.value "$tgResources", mocks.resources
|
provide.value "tgResources", mocks.resources
|
||||||
|
|
||||||
_mocks = () ->
|
_mocks = () ->
|
||||||
module ($provide) ->
|
module ($provide) ->
|
||||||
|
@ -25,20 +25,19 @@ describe "tgProfileTimelineService", ->
|
||||||
_mocks()
|
_mocks()
|
||||||
|
|
||||||
_inject = (callback) ->
|
_inject = (callback) ->
|
||||||
inject (_tgProfileTimelineService_, _$q_, _$rootScope_) ->
|
inject (_tgUserTimelineService_, _$q_, _$rootScope_) ->
|
||||||
profileTimelineService = _tgProfileTimelineService_
|
userTimelineService = _tgUserTimelineService_
|
||||||
$q = _$q_
|
$q = _$q_
|
||||||
$rootScope = _$rootScope_
|
$rootScope = _$rootScope_
|
||||||
callback() if callback
|
callback() if callback
|
||||||
|
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
module "taigaProjects"
|
module "taigaUserTimeline"
|
||||||
_setup()
|
_setup()
|
||||||
_inject()
|
_inject()
|
||||||
|
|
||||||
it "filter invalid timeline items", (done) ->
|
it "filter invalid timeline items", (done) ->
|
||||||
valid_items = {
|
valid_items = [
|
||||||
data: [
|
|
||||||
{ # valid item
|
{ # valid item
|
||||||
event_type: "xx.tt.create",
|
event_type: "xx.tt.create",
|
||||||
data: {
|
data: {
|
||||||
|
@ -104,26 +103,25 @@ describe "tgProfileTimelineService", ->
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
|
||||||
|
|
||||||
userId = 3
|
userId = 3
|
||||||
page = 2
|
page = 2
|
||||||
|
|
||||||
mocks.resources.timeline.profile = (_userId_, _page_) ->
|
mocks.resources.users.getTimeline = (_userId_, _page_) ->
|
||||||
expect(_userId_).to.be.equal(userId)
|
expect(_userId_).to.be.equal(userId)
|
||||||
expect(_page_).to.be.equal(page)
|
expect(_page_).to.be.equal(page)
|
||||||
|
|
||||||
return $q (resolve, reject) ->
|
return $q (resolve, reject) ->
|
||||||
resolve(valid_items)
|
resolve(Immutable.fromJS(valid_items))
|
||||||
|
|
||||||
profileTimelineService.getTimeline(userId, page)
|
userTimelineService.getTimeline(userId, page)
|
||||||
.then (_items_) ->
|
.then (_items_) ->
|
||||||
items = _items_.toJS()
|
items = _items_.toJS()
|
||||||
|
|
||||||
expect(items).to.have.length(3)
|
expect(items).to.have.length(3)
|
||||||
expect(items[0]).to.be.eql(valid_items.data[0])
|
expect(items[0]).to.be.eql(valid_items[0])
|
||||||
expect(items[1]).to.be.eql(valid_items.data[3])
|
expect(items[1]).to.be.eql(valid_items[3])
|
||||||
expect(items[2]).to.be.eql(valid_items.data[5])
|
expect(items[2]).to.be.eql(valid_items[5])
|
||||||
|
|
||||||
done()
|
done()
|
||||||
|
|
Loading…
Reference in New Issue