From 19723d7360d6d488b81509a33b90869355250b86 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Mon, 7 Jul 2014 14:17:04 +0200 Subject: [PATCH] Including timeline --- app/coffee/modules/issues/detail.coffee | 20 +++++++- app/partials/issues-detail.jade | 4 +- app/partials/views/modules/activity.jade | 47 +++++++++---------- .../views/modules/comment-activity.jade | 9 ++-- app/partials/views/modules/comments.jade | 4 +- app/styles/modules/comments.scss | 17 +++---- 6 files changed, 60 insertions(+), 41 deletions(-) diff --git a/app/coffee/modules/issues/detail.coffee b/app/coffee/modules/issues/detail.coffee index 6171f8c3..d5186c75 100644 --- a/app/coffee/modules/issues/detail.coffee +++ b/app/coffee/modules/issues/detail.coffee @@ -99,8 +99,16 @@ class IssueDetailController extends mixOf(taiga.Controller, taiga.PageMixin) getUserAvatar: (userId) -> return @scope.usersById[userId]?.photo + countChanges: (comment) -> + return Object.keys(comment.values_diff).length + + getChangeText: (change) -> + if _.isArray(change) + return change.join(", ") + return change + buildChangesText: (comment) -> - size = Object.keys(comment.diff).length + size = @.countChanges(comment) #TODO: i18n if size == 1 return "Made #{size} change" @@ -140,6 +148,15 @@ IssueDirective = ($tgrepo, $log, $location) -> $tgrepo.save($scope.issue).then -> $location.path("/project/#{$scope.project.slug}/issues/#{$scope.issue.ref}") + $el.on "click", ".add-comment a.button-green", (event) -> + event.preventDefault() + $tgrepo.save($scope.issue).then -> + $ctrl.loadHistory() + + $el.on "click", ".us-activity-tabs li a", (event) -> + $el.find(".us-activity-tabs li a").toggleClass("active") + $el.find(".us-activity section").toggleClass("hidden") + return {link:link} module.directive("tgIssueDetail", ["$tgRepo", "$log", "$tgLocation", IssueDirective]) @@ -510,5 +527,4 @@ CommentDirective = () -> return {link:link} - module.directive("tgComment", CommentDirective) diff --git a/app/partials/issues-detail.jade b/app/partials/issues-detail.jade index 11cb34e1..163256a7 100644 --- a/app/partials/issues-detail.jade +++ b/app/partials/issues-detail.jade @@ -41,8 +41,10 @@ block content a(href="#") span.icon.icon-issues span.tab-title Activity + include views/modules/comments - // include views/modules/activity + include views/modules/activity + sidebar.menu-secondary.sidebar section.us-status(tg-issue-status, ng-model="issue") section.us-assigned-to(tg-assigned-to, ng-model="issue.assigned_to") diff --git a/app/partials/views/modules/activity.jade b/app/partials/views/modules/activity.jade index e60d3cda..448b910b 100644 --- a/app/partials/views/modules/activity.jade +++ b/app/partials/views/modules/activity.jade @@ -1,24 +1,23 @@ -div.us-activity - - for(var x = 0; x < 6; x++) - div.activity-single - div.activity-user - a.avatar(href="", title="User preferences") - img(src="http://thecodeplayer.com/u/uifaces/12.jpg", alt="username") - div.activity-content - div.activity-username - a.username(href="", title="User name") User Name - span.date 15 junio 2014 15:30h - - for(var y = 0; y < 2; y++) - div.activity-inner - div.activity-changed - span US status - div.activity-fromto - p - strong from
- Este es el título que tenía la historia - p - strong to
- Este es el título que tenía la historia modificado - a.more-activity(href="", title="show more comments") - span show previous activity - span.prev-activity-num (3 more) +section.us-activity.hidden + div.activity-single(tg-comment, ng-repeat="comment in comments") + div.activity-user + a.avatar(href="", tg-bo-title="ctrl.getUserFullName(comment.user.pk)") + img(tg-bo-src="ctrl.getUserAvatar(comment.user.pk)", tg-bo-alt="ctrl.getUserFullName(comment.user.pk)") + + div.activity-content + div.activity-username + a.username(href="TODO", tg-bo-title="ctrl.getUserFullName(comment.user.pk)" tg-bo-html="ctrl.getUserFullName(comment.user.pk)") + span.date {{ comment.created_at | date:'yyyy-MM-dd HH:mm' }} + + div.activity-inner(ng-repeat="(key, change) in comment.values_diff") + div.activity-changed + span(tg-bo-html="key") + div.activity-fromto + p + strong from
{{ ctrl.getChangeText(change[0]) }} + p + strong to
{{ ctrl.getChangeText(change[1]) }} + + //a.more-activity(href="", title="show more comments") + // span show previous activity + // span.prev-activity-num (3 more) diff --git a/app/partials/views/modules/comment-activity.jade b/app/partials/views/modules/comment-activity.jade index bdffb83b..68e09b72 100644 --- a/app/partials/views/modules/comment-activity.jade +++ b/app/partials/views/modules/comment-activity.jade @@ -1,13 +1,14 @@ div.us-activity - a.activity-title(href="", title="Show activity") + + a.activity-title(ng-show="ctrl.countChanges(comment)", href="", title="Show activity") span(tg-bo-html="ctrl.buildChangesText(comment)") span.icon.icon-arrow-up - div.activity-inner(ng-repeat="(key, change) in comment.diff") + div.activity-inner(ng-repeat="(key, change) in comment.values_diff") div.activity-changed span(tg-bo-html="key") div.activity-fromto p - strong from
{{ change[0] }} + strong from
{{ ctrl.getChangeText(change[0]) }} p - strong to
{{ change[1] }} + strong to
{{ ctrl.getChangeText(change[1]) }} diff --git a/app/partials/views/modules/comments.jade b/app/partials/views/modules/comments.jade index 819321b5..918dcf72 100644 --- a/app/partials/views/modules/comments.jade +++ b/app/partials/views/modules/comments.jade @@ -1,6 +1,6 @@ section.us-comments div.add-comment - textarea(placeholder="Write here a new commet") + textarea(placeholder="Write here a new commet", ng-model="issue.comment") a.button.button-green(href="", title="Comment") Comment div.comment-list div.comment-single(tg-comment, ng-repeat="comment in comments") @@ -13,7 +13,7 @@ section.us-comments include comment-activity p.comment {{ comment.comment }} p.date {{ comment.created_at | date:'yyyy-MM-dd HH:mm' }} - a.delete-comment.icon.icon-delete(href="", title="delete comment") + //a.delete-comment.icon.icon-delete(href="", title="delete comment") //a.more-comments(href="", title="show more comments") //span show previous comments diff --git a/app/styles/modules/comments.scss b/app/styles/modules/comments.scss index 1a6490b9..9e105757 100644 --- a/app/styles/modules/comments.scss +++ b/app/styles/modules/comments.scss @@ -2,17 +2,18 @@ @include clearfix; textarea { @include transition(height .3s ease-in); - &:focus { - @include transition(height .3s ease-in); - height: 6rem; - +a { - display: inline-block; - } - } + // &:focus { + // @include transition(height .3s ease-in); + // height: 6rem; + // +a { + // display: inline-block; + // } + // } } a { color: $white; - display: none; + // display: none; + display: inline-block; float: right; } }