From 581c4995184ebc4fbef1ce5583ee05bb28a1790c Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Tue, 19 Aug 2014 11:19:47 +0200 Subject: [PATCH] Adding basic created by --- app/coffee/modules/common/components.coffee | 42 +++++++++++++++++++++ app/partials/issues-detail.jade | 1 + app/partials/task-detail.jade | 1 + app/partials/us-detail.jade | 1 + app/styles/components/created-by.scss | 40 ++++++++++++++++++++ app/styles/main.scss | 1 + 6 files changed, 86 insertions(+) create mode 100644 app/styles/components/created-by.scss diff --git a/app/coffee/modules/common/components.coffee b/app/coffee/modules/common/components.coffee index 2887c111..57e4611b 100644 --- a/app/coffee/modules/common/components.coffee +++ b/app/coffee/modules/common/components.coffee @@ -260,6 +260,48 @@ AssignedToDirective = ($rootscope, $confirm) -> module.directive("tgAssignedTo", ["$rootScope", "$tgConfirm", AssignedToDirective]) + +############################################################################# +## Created by directive +############################################################################# + +CreatedByDirective = -> + # TODO: i18n + template = _.template(""" +
+ <%- owner.full_name_display %> +
+ +
+ Created by + + <%- owner.full_name_display %> + + <%- date %> +
+ """) + + link = ($scope, $el, $attrs, $model) -> + renderAssignedTo = (instance) -> + ownerId = instance?.owner + owner = null + owner = $scope.usersById[ownerId] + date = moment(instance.created_date).format("DD MMM YYYY HH:mm") + html = template({owner: owner, date: date}) + $el.html(html) + + $scope.$watch $attrs.ngModel, (instance) -> + renderAssignedTo(instance) + + return { + link:link, + require:"ngModel" + } + + +module.directive("tgCreatedBy", CreatedByDirective) + + ############################################################################# ## Common list directives ############################################################################# diff --git a/app/partials/issues-detail.jade b/app/partials/issues-detail.jade index 2600ee66..02f6ec7a 100644 --- a/app/partials/issues-detail.jade +++ b/app/partials/issues-detail.jade @@ -50,4 +50,5 @@ block content sidebar.menu-secondary.sidebar section.us-status(tg-issue-status, ng-model="issue") section.us-assigned-to(tg-assigned-to, ng-model="issue") + section.us-created-by(tg-created-by, ng-model="issue") section.watchers(tg-watchers, ng-model="issue") diff --git a/app/partials/task-detail.jade b/app/partials/task-detail.jade index ef3942a6..83229c63 100644 --- a/app/partials/task-detail.jade +++ b/app/partials/task-detail.jade @@ -50,6 +50,7 @@ block content sidebar.menu-secondary.sidebar section.us-status(tg-task-status, ng-model="task") section.us-assigned-to(tg-assigned-to, ng-model="task") + section.us-created-by(tg-created-by, ng-model="task") section.watchers(tg-watchers, ng-model="task") section.us-detail-settings diff --git a/app/partials/us-detail.jade b/app/partials/us-detail.jade index 0facea19..35f50a2b 100644 --- a/app/partials/us-detail.jade +++ b/app/partials/us-detail.jade @@ -52,6 +52,7 @@ block content sidebar.menu-secondary.sidebar section.us-status(tg-us-status-detail, ng-model="us") section.us-assigned-to(tg-assigned-to, ng-model="us") + section.us-created-by(tg-created-by, ng-model="us") section.watchers(tg-watchers, ng-model="us") section.us-detail-settings diff --git a/app/styles/components/created-by.scss b/app/styles/components/created-by.scss new file mode 100644 index 00000000..1af8e830 --- /dev/null +++ b/app/styles/components/created-by.scss @@ -0,0 +1,40 @@ +.us-created-by { + @include table-flex(); + margin-top: 2rem; + position: relative; + .user-avatar { + @include table-flex-child(1, 0); + img { + border-radius: 8%; + width: 100%; + } + } + .created-by { + @include table-flex-child(3, 0); + margin-left: 1rem; + margin-top: 5px; + .assigned-title { + @extend %small; + color: $gray-light; + display: block; + } + .user-assigned { + @extend %large; + color: $green-taiga; + cursor: default; + &.editable { + cursor: pointer; + } + } + .icon-delete { + color: $gray-light; + opacity: 1; + position: absolute; + right: 1rem; + top: 1rem; + &:hover { + color: $red; + } + } + } +} diff --git a/app/styles/main.scss b/app/styles/main.scss index 0aff9988..5461c6d1 100755 --- a/app/styles/main.scss +++ b/app/styles/main.scss @@ -39,6 +39,7 @@ $prefix-for-spec: true; @import 'components/watchers'; @import 'components/level'; @import 'components/assigned-to'; +@import 'components/created-by'; @import 'components/wysiwyg'; @import 'components/select-color'; @import 'components/loader';