From a81ffef253dd8aaee47c18cc9ee6f61d9b974dde Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Wed, 9 Jul 2014 09:53:00 +0200 Subject: [PATCH] Modifying assigned to from taskboard --- app/coffee/modules/issues/detail.coffee | 14 ++++++----- app/coffee/modules/issues/lightboxes.coffee | 24 +++++++++++-------- app/coffee/modules/taskboard/main.coffee | 7 ++++++ app/partials/issues-detail-edit.jade | 4 ++-- app/partials/issues-detail.jade | 2 +- app/partials/taskboard.jade | 2 ++ .../views/components/taskboard-task.jade | 2 +- .../views/modules/lightbox-assigned-to.jade | 4 ++-- .../views/modules/lightbox_users.jade | 4 ++-- app/styles/layout/us-detail.scss | 1 - 10 files changed, 39 insertions(+), 25 deletions(-) diff --git a/app/coffee/modules/issues/detail.coffee b/app/coffee/modules/issues/detail.coffee index 7777134d..83b756e9 100644 --- a/app/coffee/modules/issues/detail.coffee +++ b/app/coffee/modules/issues/detail.coffee @@ -351,15 +351,19 @@ AssignedToDirective = ($rootscope, $confirm) -> link = ($scope, $el, $attrs, $model) -> editable = $attrs.editable? - $scope.$watch $attrs.ngModel, (assignedToId) -> + renderAssignedTo = (issue) -> + assignedToId = issue?.assigned_to assignedTo = null assignedTo = $scope.usersById[assignedToId] if assignedToId? html = template({assignedTo: assignedTo, editable:editable}) $el.html(html) + $scope.$watch $attrs.ngModel, (issue) -> + renderAssignedTo(issue) + $el.on "click", ".user-assigned", (event) -> event.preventDefault() - $rootscope.$broadcast("assigned-to:add") + $rootscope.$broadcast("assigned-to:add", $model.$modelValue) $el.on "click", ".icon-delete", (event) -> event.preventDefault() @@ -368,10 +372,8 @@ AssignedToDirective = ($rootscope, $confirm) -> $confirm.ask(title, subtitle).then => $model.$setViewValue(null) - $scope.$on "assigned-to:added", (ctx, user) -> - $scope.$apply -> - $model.$setViewValue(user.id) - + $scope.$on "assigned-to:added", (ctx, issue) -> + renderAssignedTo(issue) return {link:link, require:"ngModel"} diff --git a/app/coffee/modules/issues/lightboxes.coffee b/app/coffee/modules/issues/lightboxes.coffee index d7c61b83..f9801b61 100644 --- a/app/coffee/modules/issues/lightboxes.coffee +++ b/app/coffee/modules/issues/lightboxes.coffee @@ -48,11 +48,11 @@ module.directive("tgLbCreateIssue", [ AddWatcherDirective = () -> link = ($scope, $el, $attrs) -> - $scope.watcherSearch = {} + $scope.usersSearch = {} $scope.$on "watcher:add", -> $el.removeClass("hidden") $scope.$apply -> - $scope.watcherSearch = {} + $scope.usersSearch = {} $scope.$on "$destroy", -> $el.off() @@ -73,14 +73,16 @@ AddWatcherDirective = () -> module.directive("tgLbAddWatcher", AddWatcherDirective) -AddAssignedToDirective = () -> +EditAssignedToDirective = () -> link = ($scope, $el, $attrs) -> - $scope.watcherSearch = {} - $scope.$on "assigned-to:add", -> + $scope.usersSearch = {} + editingElement = null + + $scope.$on "assigned-to:add", (ctx, element) -> + editingElement = element $el.removeClass("hidden") $el.find("input").focus() - $scope.$apply -> - $scope.watcherSearch = {} + $scope.usersSearch = {} $scope.$on "$destroy", -> $el.off() @@ -92,10 +94,12 @@ AddAssignedToDirective = () -> $el.on "click", ".watcher-single", (event) -> event.preventDefault() target = angular.element(event.currentTarget) - watcher = target.scope().user + if editingElement? + editingElement.assigned_to = target.scope().user.id + $el.addClass("hidden") - $scope.$broadcast("assigned-to:added", watcher) + $scope.$broadcast("assigned-to:added", editingElement) return {link:link} -module.directive("tgLbAddAssignedTo", AddAssignedToDirective) +module.directive("tgLbEditAssignedTo", EditAssignedToDirective) diff --git a/app/coffee/modules/taskboard/main.coffee b/app/coffee/modules/taskboard/main.coffee index 0d8f8a00..fbe9b59b 100644 --- a/app/coffee/modules/taskboard/main.coffee +++ b/app/coffee/modules/taskboard/main.coffee @@ -58,6 +58,10 @@ class TaskboardController extends mixOf(taiga.Controller, taiga.PageMixin) @.loadTaskboard() @scope.$on "taskform:edit:success", => @.loadTaskboard() + @scope.$on "assigned-to:added", (ctx, task) => + @scope.$apply( + @repo.save(task) + ) loadSprintStats: -> return @rs.sprints.stats(@scope.projectId, @scope.sprintId).then (stats) => @@ -145,6 +149,9 @@ class TaskboardController extends mixOf(taiga.Controller, taiga.PageMixin) editTask: (task) -> @rootscope.$broadcast("taskform:edit", task) + editTaskAssignedTo: (task) -> + @rootscope.$broadcast("assigned-to:add", task) + module.controller("TaskboardController", TaskboardController) diff --git a/app/partials/issues-detail-edit.jade b/app/partials/issues-detail-edit.jade index 7bc3cd6a..27fca6e2 100644 --- a/app/partials/issues-detail-edit.jade +++ b/app/partials/issues-detail-edit.jade @@ -32,7 +32,7 @@ block content 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") + section.us-assigned-to(tg-assigned-to, ng-model="issue", editable="true") section.watchers(tg-watchers, ng-model="issue.watchers", editable="true") section.us-detail-settings @@ -50,7 +50,7 @@ block content div.lightbox.lightbox_block.hidden(tg-lb-block, title="Blocking issue", ng-model="issue") include views/modules/lightbox_block - div.lightbox.lightbox_select_user.hidden(tg-lb-add-assigned-to) + div.lightbox.lightbox_select_user.hidden(tg-lb-edit-assigned-to) include views/modules/lightbox-assigned-to div.lightbox.lightbox_select_user.hidden(tg-lb-add-watcher) diff --git a/app/partials/issues-detail.jade b/app/partials/issues-detail.jade index 5b26bc19..c8f6ec61 100644 --- a/app/partials/issues-detail.jade +++ b/app/partials/issues-detail.jade @@ -47,7 +47,7 @@ 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.assigned_to") + section.us-assigned-to(tg-assigned-to, ng-model="issue") section.watchers(tg-watchers, ng-model="issue.watchers") section.us-detail-settings diff --git a/app/partials/taskboard.jade b/app/partials/taskboard.jade index 21fdfe8e..10c7a001 100644 --- a/app/partials/taskboard.jade +++ b/app/partials/taskboard.jade @@ -23,3 +23,5 @@ block content include views/modules/lightbox_add-edit-task div.lightbox.lightbox_add-bulk.hidden(tg-lb-create-bulk-tasks) include views/modules/lightbox_add-task-bulk + div.lightbox.lightbox_select_user.hidden(tg-lb-edit-assigned-to) + include views/modules/lightbox-assigned-to diff --git a/app/partials/views/components/taskboard-task.jade b/app/partials/views/components/taskboard-task.jade index 90dc3e2c..fbe7c3b6 100644 --- a/app/partials/views/components/taskboard-task.jade +++ b/app/partials/views/components/taskboard-task.jade @@ -2,7 +2,7 @@ div.taskboard-tagline a.taskboard-tag(ng-repeat="tag in task.tags" href="" title="{{ tag }}") div.taskboard-task-inner figure.avatar - a(href="", title="See {{ usersById[task.assigned_to].username }}'s profile") + a(ng-click="ctrl.editTaskAssignedTo(task)", href="", title="See {{ usersById[task.assigned_to].username }}'s profile") img.avatar(src="{{ usersById[task.assigned_to].photo }}", alt="{{ usersById[task.assigned_to].username }}'s avatar") figcaption {{ usersById[task.assigned_to].full_name_display }} diff --git a/app/partials/views/modules/lightbox-assigned-to.jade b/app/partials/views/modules/lightbox-assigned-to.jade index c6e44d9d..a2126cc6 100644 --- a/app/partials/views/modules/lightbox-assigned-to.jade +++ b/app/partials/views/modules/lightbox-assigned-to.jade @@ -3,10 +3,10 @@ a.close(href="", title="close") form h2.title Select assigned to fieldset - input(type="text", data-maxlength="500", placeholder="Search for users", ng-model="watcherSearch.$") + input(type="text", data-maxlength="500", placeholder="Search for users", ng-model="usersSearch.$") div.watchers - div.watcher-single(ng-repeat="user in users|filter:watcherSearch:strict|limitTo:5 track by user.id") + div.watcher-single(ng-repeat="user in users|filter:usersSearch:strict|limitTo:5 track by user.id") div.watcher-avatar a.avatar(href="", title="Assigned to") img(tg-bo-src="user.photo", tg-bo-alt="user.photo") diff --git a/app/partials/views/modules/lightbox_users.jade b/app/partials/views/modules/lightbox_users.jade index ebbd845f..11cc5a33 100644 --- a/app/partials/views/modules/lightbox_users.jade +++ b/app/partials/views/modules/lightbox_users.jade @@ -3,10 +3,10 @@ a.close(href="", title="close") form h2.title Add watchers fieldset - input(type="text", data-maxlength="500", placeholder="Search for users", ng-model="watcherSearch.$") + input(type="text", data-maxlength="500", placeholder="Search for users", ng-model="usersSearch.$") div.watchers - div.watcher-single(ng-repeat="user in users|filter:watcherSearch:strict|limitTo:5 track by user.id") + div.watcher-single(ng-repeat="user in users|filter:usersSearch:strict|limitTo:5 track by user.id") div.watcher-avatar a.avatar(href="", title="Assigned to") img(tg-bo-src="user.photo", tg-bo-alt="user.photo") diff --git a/app/styles/layout/us-detail.scss b/app/styles/layout/us-detail.scss index a530f251..5fa9f463 100644 --- a/app/styles/layout/us-detail.scss +++ b/app/styles/layout/us-detail.scss @@ -201,7 +201,6 @@ @include clearfix(); @include transition(background .2s ease-in); background: darken($whitish, 5%); - cursor: pointer; margin-bottom: .5rem; padding: .5rem; &:last-child {