From 41c9689b7b42699fb9fa7e61d8340340993bf65b Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Fri, 4 Jul 2014 13:28:17 +0200 Subject: [PATCH] Basic history implementation --- app/coffee/modules/issues/detail.coffee | 12 +++++-- app/coffee/modules/resources/issues.coffee | 3 ++ app/partials/issues-detail-edit.jade | 13 +------- app/partials/issues-detail.jade | 4 +-- .../views/modules/comment-activity.jade | 2 +- app/partials/views/modules/comments.jade | 32 +++++++++---------- 6 files changed, 32 insertions(+), 34 deletions(-) diff --git a/app/coffee/modules/issues/detail.coffee b/app/coffee/modules/issues/detail.coffee index cb5ee826..d5f1b80c 100644 --- a/app/coffee/modules/issues/detail.coffee +++ b/app/coffee/modules/issues/detail.coffee @@ -69,7 +69,13 @@ class IssueDetailController extends mixOf(taiga.Controller, taiga.PageMixin) loadIssue: -> return @rs.issues.get(@scope.projectId, @scope.issueId).then (issue) => @scope.issue = issue - return issue + @scope.previousUrl = "/project/#{@scope.project.slug}/issues/#{@scope.issue.neighbors.previous.ref}" if @scope.issue.neighbors.previous.id? + @scope.nextUrl = "/project/#{@scope.project.slug}/issues/#{@scope.issue.neighbors.next.ref}" if @scope.issue.neighbors.next.id? + + loadHistory: -> + return @rs.issues.history(@scope.issueId).then (history) => + @scope.history = history.results + @scope.comments = _.filter(history.results, (historyEntry) -> historyEntry.comment != "") loadInitialData: -> params = { @@ -85,6 +91,7 @@ class IssueDetailController extends mixOf(taiga.Controller, taiga.PageMixin) return promise.then(=> @.loadProject()) .then(=> @.loadUsersAndRoles()) .then(=> @.loadIssue()) + .then(=> @.loadHistory()) block: -> @rootscope.$broadcast("block", @scope.issue) @@ -117,11 +124,10 @@ IssueDirective = ($tgrepo, $log, $location) -> $el.on "click", ".save-issue", (event) -> $tgrepo.save($scope.issue).then -> - console.log "TODO" + $location.path("/project/#{$scope.project.slug}/issues/#{$scope.issue.ref}") return {link:link} - module.directive("tgIssueDetail", ["$tgRepo", "$log", "$tgLocation", IssueDirective]) diff --git a/app/coffee/modules/resources/issues.coffee b/app/coffee/modules/resources/issues.coffee index f06ea9e3..f19d9c2c 100644 --- a/app/coffee/modules/resources/issues.coffee +++ b/app/coffee/modules/resources/issues.coffee @@ -39,6 +39,9 @@ resourceProvider = ($repo) -> service.filtersData = (projectId) -> return $repo.queryOneRaw("projects", "#{projectId}/issue_filters_data") + service.history = (issueId) -> + return $repo.queryOneRaw("history/issue", issueId) + return (instance) -> instance.issues = service diff --git a/app/partials/issues-detail-edit.jade b/app/partials/issues-detail-edit.jade index 0ac1dd5e..4777d260 100644 --- a/app/partials/issues-detail-edit.jade +++ b/app/partials/issues-detail-edit.jade @@ -28,19 +28,8 @@ block content textarea(placeholder="Write a description of your issue", ng-model="issue.description") // include views/modules/attachments - section.us-activity - ul.us-activity-tabs - li - a.active(href="#") - span.icon.icon-bulk - span.tab-title Comments + textarea(ng-model="issue.comment", placeholder="Write here a new commet") - li - a(href="#") - span.icon.icon-issues - span.tab-title Activity - include views/modules/comments - // include views/modules/activity sidebar.menu-secondary.sidebar section.us-status(tg-issue-status, ng-model="issue", editable="true") section.us-assigned-to(tg-assigned-to, ng-model="issue.assigned_to", editable="true") diff --git a/app/partials/issues-detail.jade b/app/partials/issues-detail.jade index e060753f..6367db12 100644 --- a/app/partials/issues-detail.jade +++ b/app/partials/issues-detail.jade @@ -17,8 +17,8 @@ block content span.us-number(tg-bo-html="issue.ref") span.us-name(ng-bind="issue.subject") div.issue-nav - a.icon.icon-arrow-left(href="", title="next issue") - a.icon.icon-arrow-right(href="", title="previous issue") + a.icon.icon-arrow-left(ng-show="nextUrl", href="{{ nextUrl }}", title="next issue") + a.icon.icon-arrow-right(ng-show="previousUrl",href="{{ previousUrl }}", title="previous issue") div.blocked-warning(ng-show="issue.is_blocked") span.icon.icon-warning diff --git a/app/partials/views/modules/comment-activity.jade b/app/partials/views/modules/comment-activity.jade index 2a146327..f74d43cd 100644 --- a/app/partials/views/modules/comment-activity.jade +++ b/app/partials/views/modules/comment-activity.jade @@ -1,6 +1,6 @@ div.us-activity a.activity-title(href="", title="Show activity") - span made 3 changes + span made {{ comment.diff }} changes span.icon.icon-arrow-up - for(var y = 0; y < 2; y++) div.activity-inner diff --git a/app/partials/views/modules/comments.jade b/app/partials/views/modules/comments.jade index 787e945a..e5b1592a 100644 --- a/app/partials/views/modules/comments.jade +++ b/app/partials/views/modules/comments.jade @@ -3,19 +3,19 @@ section.us-comments textarea(placeholder="Write here a new commet") a.button.button-green(href="", title="Comment") Comment div.comment-list - - for(var x = 0; x < 6; x++) - div.comment-single - div.comment-user - a.avatar(href="", title="User preferences") - img(src="http://thecodeplayer.com/u/uifaces/12.jpg", alt="username") - div.comment-content - a.username(href="", title="User name") User Name - //- includes module activity - include comment-activity - p.comment - Para un escenario en el cual ya están cargados en la DB la lista de usuarios para un Grupo o varios, tenemos que tener la posibilidad de lanzar a todos los miembros de un grupo y/o a un individuo en concreto, un mail. El mail lleva un bloque de texto (pendiende de que os lo pasemos) y también llevará un link que llevará a una pantalla donde ponga la pw que usará a partir de ese momento. Si elige su PW dentro de las reglas de PW establecidas (pendientes de decidir), el sistema le logará automáticamente. - p.date 15 junio 2014 15:30h - a.delete-comment.icon.icon-delete(href="", title="delete comment") - a.more-comments(href="", title="show more comments") - span show previous comments - span.prev-comments-num (3 more) + div.comment-single(ng-repeat="comment in comments") + div.comment-user + a.avatar(href="", title="User preferences") + img(src="http://thecodeplayer.com/u/uifaces/12.jpg", alt="username") + div.comment-content + a.username(href="", title="User name") User Name + //- includes module activity + include comment-activity + p.comment + {{ comment.comment }} + p.date 15 junio 2014 15:30h + a.delete-comment.icon.icon-delete(href="", title="delete comment") + + //a.more-comments(href="", title="show more comments") + //span show previous comments + //span.prev-comments-num (3 more)