comments in timelines

stable
Juanfran 2015-04-08 09:37:10 +02:00
parent 80fa5b7db3
commit 2c1de83d85
8 changed files with 264 additions and 89 deletions

View File

@ -58,6 +58,7 @@ urls = {
"create-project": "/create-project"
"profile": "/:user"
"user-profile": "profile/:username"
"project": "/project/:project"
"project-backlog": "/project/:project/backlog"

View File

@ -194,6 +194,21 @@ class RepositoryService extends taiga.Service
result.paginatedBy = parseInt(headers["x-paginated-by"], 10)
return result
queryOnePaginatedRaw: (name, id, params, options={}) ->
url = @urls.resolve(name)
url = "#{url}/#{id}" if id
httpOptions = _.merge({headers: {}}, options)
return @http.get(url, params, httpOptions).then (data) =>
headers = data.headers()
result = {}
result.data = data.data
result.count = parseInt(headers["x-pagination-count"], 10)
result.current = parseInt(headers["x-pagination-current"] or 1, 10)
result.paginatedBy = parseInt(headers["x-paginated-by"], 10)
return result
resolve: (options) ->
params = {}
params.project = options.pslug if options.pslug?

View File

@ -0,0 +1,45 @@
###
# 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/backlog/main.coffee
###
taiga = @.taiga
mixOf = @.taiga.mixOf
class ProfileTimelineController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.FiltersMixin)
@.$inject = [
"$scope",
"$tgResources",
"$tgAuth"
]
constructor: (@scope, @rs, @auth) ->
promise = @.loadTimeline()
promise.then null, @.onInitialDataError.bind(@)
loadTimeline: () ->
user = @auth.getUser()
return @rs.timeline.profile(user.id).then (result) =>
@scope.result = result
console.log @scope.result.data
angular.module("taigaProfile")
.controller("ProfileTimeline", ProfileTimelineController)

View File

@ -0,0 +1,58 @@
TimelineItemDirective = ($tgTemplate, $compile, $navUrls) ->
parseEventType = (event_type) ->
event_type = event_type.split(".")
return {
section: event_type[0],
obj: event_type[1],
type: event_type[2]
}
getUrl = (timeline, event) ->
url = {
"issue": "project-issues-detail",
"wiki": "project-wiki-page",
"task": "project-tasks-detail",
"userstories": "project-userstories-detail"
}
params = {project: timeline.data.project.slug, ref: timeline.data[event.obj].ref}
return $navUrls.resolve(url[event.obj], params)
getTemplate = (timeline, event) ->
template = ""
if event.type == 'change'
if timeline.data.comment.length
template = "profile/timeline/comment-timeline.html"
return $tgTemplate.get(template)
link = ($scope, $el, $attrs) ->
event = parseEventType($scope.timeline.event_type)
template = getTemplate($scope.timeline, event)
if !template
return ""
obj = $scope.timeline.data[event.obj]
$scope.timeline.subject = obj.subject
$scope.timeline.ref = obj.ref
$scope.timeline.type = event.obj
$scope.timeline.created_formated = moment($scope.timeline.created).fromNow()
$scope.timeline.detail_url = getUrl($scope.timeline, event)
$el.html(template)
$compile($el.contents())($scope)
return {
link: link
scope: {
timeline: "=tgTimelineItem"
}
}
angular.module("taigaProfile")
.directive("tgTimelineItem", ["$tgTemplate", "$compile", "$tgNavUrls", TimelineItemDirective])

View File

@ -36,6 +36,8 @@ urls = {
"users-change-password": "/users/change_password"
"users-change-email": "/users/change_email"
"users-cancel-account": "/users/cancel"
"contacts": "/users/%s/contacts"
"stats": "/users/%s/stats"
# User - Notification
"notify-policies": "/notify-policies"
@ -58,6 +60,7 @@ urls = {
"projects": "/projects"
"project-templates": "/project-templates"
"project-modules": "/projects/%s/modules"
"bulk-update-projects-order": "/projects/bulk_update_order"
# Project Values - Choises
"userstory-statuses": "/userstory-statuses"
@ -125,6 +128,10 @@ urls = {
"tasks-csv": "/tasks/csv?uuid=%s"
"issues-csv": "/issues/csv?uuid=%s"
# Timeline
"timeline-profile": "/timeline/profile"
"timeline-project": "/timeline/project"
# Search
"search": "/search"
@ -183,5 +190,6 @@ module.run([
"$tgWebhooksResourcesProvider",
"$tgWebhookLogsResourcesProvider",
"$tgLocalesResourcesProvider",
"$tgTimelineResourcesProvider",
initResources
])

View File

@ -0,0 +1,35 @@
###
# 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) ->
return $repo.queryOnePaginatedRaw("timeline-profile", userId)
return (instance) ->
instance.timeline = service
module = angular.module("taigaResources")
module.factory("$tgTimelineResourcesProvider", ["$tgRepo", resourceProvider])

View File

@ -1,94 +1,95 @@
section.profile-timeline
- for (var x = 0; x < 3; x++)
// Simple message for favorites, updates, etc.
div.activity-simple
span.activity-date Yesterday 12.30h
div.activity-info
div.profile-contact-picture
a(href="", title="{{ user.nickname }}")
img(src="https://s3.amazonaws.com/uifaces/faces/twitter/gerrenlamson/128.jpg", alt="{{ user.nickname }}")
p
a(href="", title="See {{ user.nickname }} profile") Jesús Espino
span has updated the status of the US
a(href="", title="See #{{ us.id }}{{ us.title }}") #23 Web comercial/Ayuda from "UX" to "UX Done"
section.profile-timeline(ng-controller="ProfileTimeline as ctrl")
div(ng-repeat="timeline in result.data", tg-timeline-item="timeline")
// - for (var x = 0; x < 3; x++)
// // Simple message for favorites, updates, etc.
// div.activity-simple)
// span.activity-date Yesterday 12.30h
// div.activity-info
// div.profile-contact-picture
// a(href="", title="{{ user.nickname }}")
// img(src="https://s3.amazonaws.com/uifaces/faces/twitter/gerrenlamson/128.jpg", alt="{{ user.nickname }}")
// p
// a(href="", title="See {{ user.nickname }} profile") Jesús Espino
// span has updated the status of the US
// a(href="", title="See #{{ us.id }}{{ us.title }}") #23 Web comercial/Ayuda from "UX" to "UX Done"
// Added comment in us, task or issue.
div.activity-comment
span.activity-date 3 days ago
div.activity-info
div.profile-contact-picture
a(href="", title="{{ user.nickname }}")
img(src="https://s3.amazonaws.com/uifaces/faces/twitter/tonystubblebine/128.jpg", alt="{{ user.nickname }}")
p
a(href="", title="See {{ user.nickname }} profile") JuanFrancisco Alcántara
span has commented in the task
a(href="", title="See #{{ us.id }}{{ us.title }}") #15 Revisar el contraste de los grises
div.activity-comment-quote
p "He subido a GitLab unos wireframes. Echadle un vistazo por favor, a ver si falta algo o tenéis al"
// // Added comment in us, task or issue.
// div.activity-comment
// span.activity-date 3 days ago
// div.activity-info
// div.profile-contact-picture
// a(href="", title="{{ user.nickname }}")
// img(src="https://s3.amazonaws.com/uifaces/faces/twitter/tonystubblebine/128.jpg", alt="{{ user.nickname }}")
// p
// a(href="", title="See {{ user.nickname }} profile") JuanFrancisco Alcántara
// span has commented in the task
// a(href="", title="See #{{ us.id }}{{ us.title }}") #15 Revisar el contraste de los grises
// div.activity-comment-quote
// p "He subido a GitLab unos wireframes. Echadle un vistazo por favor, a ver si falta algo o tenéis al"
// Added attachment type image in us, task or issue.
div.activity-image
span.activity-date 5 days ago
div.activity-info
div.profile-contact-picture
a(href="", title="{{ user.nickname }}")
img(src="https://s3.amazonaws.com/uifaces/faces/twitter/jina/128.jpg", alt="{{ user.nickname }}")
p
a(href="", title="See {{ user.nickname }} profile") Alejandro Alonso
span has uploaded an image in the US
a(href="", title="See #{{ us.id }}{{ us.title }}") US #23 Web comercial/Ayuda
div.activity-comment-attachment
p "Eh! Look at this amazing Taiga picture!"
img(src="https://ununsplash.imgix.net/photo-1423753623104-718aaace6772?q=75&fm=jpg&w=1080&fit=max&s=f655534aa0fe8bae35c687e80a2ed399", alt="{{ attachment.name }}")
// // Added attachment type image in us, task or issue.
// div.activity-image
// span.activity-date 5 days ago
// div.activity-info
// div.profile-contact-picture
// a(href="", title="{{ user.nickname }}")
// img(src="https://s3.amazonaws.com/uifaces/faces/twitter/jina/128.jpg", alt="{{ user.nickname }}")
// p
// a(href="", title="See {{ user.nickname }} profile") Alejandro Alonso
// span has uploaded an image in the US
// a(href="", title="See #{{ us.id }}{{ us.title }}") US #23 Web comercial/Ayuda
// div.activity-comment-attachment
// p "Eh! Look at this amazing Taiga picture!"
// img(src="https://ununsplash.imgix.net/photo-1423753623104-718aaace6772?q=75&fm=jpg&w=1080&fit=max&s=f655534aa0fe8bae35c687e80a2ed399", alt="{{ attachment.name }}")
// Multiple update message, etc.
div.activity-notification
span.activity-date 6 days ago
div.activity-info
div.profile-contact-picture
a(href="", title="{{ user.nickname }}")
img(src="https://s3.amazonaws.com/uifaces/faces/twitter/idiot/128.jpg", alt="{{ user.nickname }}")
p
a(href="", title="See {{ user.nickname }} profile") Jesús Espino
span closed
ul.activity-notification-list
li
a(href="", title="See #{{ us.id }}{{ us.title }}") US #23 Web comercial/Ayuda
li
a(href="", title="See #{{ us.id }}{{ us.title }}") #2156 Search Page UX is hardly understandable
li
a(href="", title="See #{{ us.id }}{{ us.title }}") #456 Search for users
li
a(href="", title="See #{{ us.id }}{{ us.title }}") #2140 Las notificaciones de cambios están fallando
// // Multiple update message, etc.
// div.activity-notification
// span.activity-date 6 days ago
// div.activity-info
// div.profile-contact-picture
// a(href="", title="{{ user.nickname }}")
// img(src="https://s3.amazonaws.com/uifaces/faces/twitter/idiot/128.jpg", alt="{{ user.nickname }}")
// p
// a(href="", title="See {{ user.nickname }} profile") Jesús Espino
// span closed
// ul.activity-notification-list
// li
// a(href="", title="See #{{ us.id }}{{ us.title }}") US #23 Web comercial/Ayuda
// li
// a(href="", title="See #{{ us.id }}{{ us.title }}") #2156 Search Page UX is hardly understandable
// li
// a(href="", title="See #{{ us.id }}{{ us.title }}") #456 Search for users
// li
// a(href="", title="See #{{ us.id }}{{ us.title }}") #2140 Las notificaciones de cambios están fallando
// Added attachment type image in us, task or issue.
div.activity-member
span.activity-date a week ago
div.activity-info
div.profile-contact-picture
a(href="", title="{{ organization.nickname }}")
img(src="https://s3.amazonaws.com/uifaces/faces/twitter/tofslie/128.jpg", alt="{{ organization.nickname }}")
p
a(href="", title="See {{ organization.nickname }} profile") Mozilla
span has a new member
div.activity-member-view
div.profile-member-picture
img(src="https://s3.amazonaws.com/uifaces/faces/twitter/BillSKenney/128.jpg", alt="{{ organization.nickname }}")
div.activity-member-info
a(href="", title="See {{ user.nickname }} profile")
span Andrés González
p Back-end developer & Stake
// // Added attachment type image in us, task or issue.
// div.activity-member
// span.activity-date a week ago
// div.activity-info
// div.profile-contact-picture
// a(href="", title="{{ organization.nickname }}")
// img(src="https://s3.amazonaws.com/uifaces/faces/twitter/tofslie/128.jpg", alt="{{ organization.nickname }}")
// p
// a(href="", title="See {{ organization.nickname }} profile") Mozilla
// span has a new member
// div.activity-member-view
// div.profile-member-picture
// img(src="https://s3.amazonaws.com/uifaces/faces/twitter/BillSKenney/128.jpg", alt="{{ organization.nickname }}")
// div.activity-member-info
// a(href="", title="See {{ user.nickname }} profile")
// span Andrés González
// p Back-end developer & Stake
// Added comment in us, task or issue.
div.activity-project
span.activity-date a week ago
div.activity-info
div.profile-contact-picture
a(href="", title="{{ organization.nickname }}")
img(src="https://s3.amazonaws.com/uifaces/faces/twitter/ekvium/128.jpg", alt="{{ organization.nickname }}")
p
a(href="", title="See {{ user.nickname }} profile") Redhat
span has a new project
a(href="", title="See {{ project.name }}") Nanatubos
div.activity-comment-quote
p We plan to build a hundred of so called "telehubs" so people from all over the world can immediately relocate their physical self at any other telehub in microseconds.
// // Added comment in us, task or issue.
// div.activity-project
// span.activity-date a week ago
// div.activity-info
// div.profile-contact-picture
// a(href="", title="{{ organization.nickname }}")
// img(src="https://s3.amazonaws.com/uifaces/faces/twitter/ekvium/128.jpg", alt="{{ organization.nickname }}")
// p
// a(href="", title="See {{ user.nickname }} profile") Redhat
// span has a new project
// a(href="", title="See {{ project.name }}") Nanatubos
// div.activity-comment-quote
// p We plan to build a hundred of so called "telehubs" so people from all over the world can immediately relocate their physical self at any other telehub in microseconds.

View File

@ -0,0 +1,12 @@
div.activity-comment
span.activity-date {{::timeline.created_formated}}
div.activity-info
div.profile-contact-picture
a(tg-nav="user-profile:username=timeline.data.user.username", title="{{::timeline.data.user.name }}")
img(ng-src="{{::timeline.data.user.photo}}", alt="{{::timeline.data.user.name}}")
p
a(tg-nav="user-profile:username=timeline.data.user.username", title="See {{::timeline.data.user.name }} profile") {{::timeline.data.user.name}}
span has commented in the {{::timeline.type }}
a(href="{{::timeline.detail_url}}", title="See #{{::timeline.ref}} {{::timeline.subject}}") \#{{::timeline.ref}} {{::timeline.subject}}
div.activity-comment-quote
p "{{::timeline.data.comment}}"