taiga-front/app/modules/user-timeline/user-timeline/user-timeline.controller.co...

62 lines
2.2 KiB
CoffeeScript

###
# Copyright (C) 2014-2017 Andrey Antukh <niwi@niwi.nz>
# Copyright (C) 2014-2017 Jesús Espino Garcia <jespinog@gmail.com>
# Copyright (C) 2014-2017 David Barragán Merino <bameda@dbarragan.com>
# Copyright (C) 2014-2017 Alejandro Alonso <alejandro.alonso@kaleidos.net>
# Copyright (C) 2014-2017 Juan Francisco Alcántara <juanfran.alcantara@kaleidos.net>
# Copyright (C) 2014-2017 Xavi Julian <xavier.julian@kaleidos.net>
#
# 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/profile/profile-timeline/profile-timeline.controller.coffee
###
taiga = @.taiga
mixOf = @.taiga.mixOf
class UserTimelineController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.FiltersMixin)
@.$inject = [
"tgUserTimelineService"
]
constructor: (@userTimelineService) ->
@.timelineList = Immutable.List()
@.scrollDisabled = false
@.timeline = null
if @.projectId
@.timeline = @userTimelineService.getProjectTimeline(@.projectId)
else if @.currentUser
@.timeline = @userTimelineService.getProfileTimeline(@.user.get("id"))
else
@.timeline = @userTimelineService.getUserTimeline(@.user.get("id"))
loadTimeline: () ->
@.scrollDisabled = true
return @.timeline
.next()
.then (response) =>
@.timelineList = @.timelineList.concat(response.get("items"))
if response.get("next")
@.scrollDisabled = false
return @.timelineList
angular.module("taigaUserTimeline")
.controller("UserTimeline", UserTimelineController)