From c439ca7e3fc26ac1eead4999d0d9e730efd587dc Mon Sep 17 00:00:00 2001 From: Juanfran Date: Wed, 8 Apr 2015 12:39:41 +0200 Subject: [PATCH] attachment image --- .../timeline-attachment.directive.coffee | 27 +++ .../profile/timeline-item.directive.coffee | 2 + .../modules/profile/profile-timeline.jade | 176 +++++++++--------- .../profile/timeline/comment-timeline.jade | 2 +- .../timeline/timeline-attachment-image.jade | 3 + .../profile/timeline/timeline-attachment.jade | 12 ++ 6 files changed, 133 insertions(+), 89 deletions(-) create mode 100644 app/coffee/modules/profile/timeline-attachment.directive.coffee create mode 100644 app/partials/profile/timeline/timeline-attachment-image.jade create mode 100644 app/partials/profile/timeline/timeline-attachment.jade diff --git a/app/coffee/modules/profile/timeline-attachment.directive.coffee b/app/coffee/modules/profile/timeline-attachment.directive.coffee new file mode 100644 index 00000000..7bbe12fa --- /dev/null +++ b/app/coffee/modules/profile/timeline-attachment.directive.coffee @@ -0,0 +1,27 @@ +TimelineAttachmentDirective = ($tgTemplate, $compile) -> + validFileExtensions = [".jpg", ".jpeg", ".bmp", ".gif", ".png"] + + isImage = (url) -> + url = url.toLowerCase() + + return _.some validFileExtensions, (extension) => + return url.indexOf(extension, url - extension.length) != -1 + + link = ($scope, $el, $attrs) -> + is_image = isImage($scope.attachment.url) + + if is_image + template = $tgTemplate.get("profile/timeline/timeline-attachment-image.html") + + $el.html(template) + $compile($el.contents())($scope) + + return { + link: link + scope: { + attachment: "=tgTimelineAttachment" + } + } + +angular.module("taigaProfile") + .directive("tgTimelineAttachment", ["$tgTemplate", "$compile", TimelineAttachmentDirective]) diff --git a/app/coffee/modules/profile/timeline-item.directive.coffee b/app/coffee/modules/profile/timeline-item.directive.coffee index b6cb3e9c..6ac4726f 100644 --- a/app/coffee/modules/profile/timeline-item.directive.coffee +++ b/app/coffee/modules/profile/timeline-item.directive.coffee @@ -26,6 +26,8 @@ TimelineItemDirective = ($tgTemplate, $compile, $navUrls) -> if event.type == 'change' if timeline.data.comment.length template = "profile/timeline/comment-timeline.html" + else if timeline.data.values_diff.attachments + template = "profile/timeline/attachment-timeline.html" return $tgTemplate.get(template) diff --git a/app/partials/includes/modules/profile/profile-timeline.jade b/app/partials/includes/modules/profile/profile-timeline.jade index 9ee99a1f..4580cc0b 100644 --- a/app/partials/includes/modules/profile/profile-timeline.jade +++ b/app/partials/includes/modules/profile/profile-timeline.jade @@ -1,95 +1,95 @@ 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" + - 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. diff --git a/app/partials/profile/timeline/comment-timeline.jade b/app/partials/profile/timeline/comment-timeline.jade index 101aabca..13b8dc76 100644 --- a/app/partials/profile/timeline/comment-timeline.jade +++ b/app/partials/profile/timeline/comment-timeline.jade @@ -9,4 +9,4 @@ div.activity-comment 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}}" + p(ng-if="timeline.data.comment") "{{::timeline.data.comment}}" diff --git a/app/partials/profile/timeline/timeline-attachment-image.jade b/app/partials/profile/timeline/timeline-attachment-image.jade new file mode 100644 index 00000000..dbdaa186 --- /dev/null +++ b/app/partials/profile/timeline/timeline-attachment-image.jade @@ -0,0 +1,3 @@ +// timeline-attachment directive +div.activity-comment-attachment + img(ng-src="{{::attachment.url}}", alt="{{::attachment.filename}}") \ No newline at end of file diff --git a/app/partials/profile/timeline/timeline-attachment.jade b/app/partials/profile/timeline/timeline-attachment.jade new file mode 100644 index 00000000..94f92d5a --- /dev/null +++ b/app/partials/profile/timeline/timeline-attachment.jade @@ -0,0 +1,12 @@ +div.activity-image + 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 uploaded an image in the {{::timeline.type }} + a(href="{{::timeline.detail_url}}", title="See #{{::timeline.ref}} {{::timeline.subject}}") \#{{::timeline.ref}} {{::timeline.subject}} + div(ng-repeat="attachment in timeline.data.values_diff.attachments.new") + div(tg-timeline-attachment="attachment") \ No newline at end of file