Modifying assigned to from taskboard

stable
Alejandro Alonso 2014-07-09 09:53:00 +02:00
parent 0eb7b5f68d
commit a81ffef253
10 changed files with 39 additions and 25 deletions

View File

@ -351,15 +351,19 @@ AssignedToDirective = ($rootscope, $confirm) ->
link = ($scope, $el, $attrs, $model) -> link = ($scope, $el, $attrs, $model) ->
editable = $attrs.editable? editable = $attrs.editable?
$scope.$watch $attrs.ngModel, (assignedToId) -> renderAssignedTo = (issue) ->
assignedToId = issue?.assigned_to
assignedTo = null assignedTo = null
assignedTo = $scope.usersById[assignedToId] if assignedToId? assignedTo = $scope.usersById[assignedToId] if assignedToId?
html = template({assignedTo: assignedTo, editable:editable}) html = template({assignedTo: assignedTo, editable:editable})
$el.html(html) $el.html(html)
$scope.$watch $attrs.ngModel, (issue) ->
renderAssignedTo(issue)
$el.on "click", ".user-assigned", (event) -> $el.on "click", ".user-assigned", (event) ->
event.preventDefault() event.preventDefault()
$rootscope.$broadcast("assigned-to:add") $rootscope.$broadcast("assigned-to:add", $model.$modelValue)
$el.on "click", ".icon-delete", (event) -> $el.on "click", ".icon-delete", (event) ->
event.preventDefault() event.preventDefault()
@ -368,10 +372,8 @@ AssignedToDirective = ($rootscope, $confirm) ->
$confirm.ask(title, subtitle).then => $confirm.ask(title, subtitle).then =>
$model.$setViewValue(null) $model.$setViewValue(null)
$scope.$on "assigned-to:added", (ctx, user) -> $scope.$on "assigned-to:added", (ctx, issue) ->
$scope.$apply -> renderAssignedTo(issue)
$model.$setViewValue(user.id)
return {link:link, require:"ngModel"} return {link:link, require:"ngModel"}

View File

@ -48,11 +48,11 @@ module.directive("tgLbCreateIssue", [
AddWatcherDirective = () -> AddWatcherDirective = () ->
link = ($scope, $el, $attrs) -> link = ($scope, $el, $attrs) ->
$scope.watcherSearch = {} $scope.usersSearch = {}
$scope.$on "watcher:add", -> $scope.$on "watcher:add", ->
$el.removeClass("hidden") $el.removeClass("hidden")
$scope.$apply -> $scope.$apply ->
$scope.watcherSearch = {} $scope.usersSearch = {}
$scope.$on "$destroy", -> $scope.$on "$destroy", ->
$el.off() $el.off()
@ -73,14 +73,16 @@ AddWatcherDirective = () ->
module.directive("tgLbAddWatcher", AddWatcherDirective) module.directive("tgLbAddWatcher", AddWatcherDirective)
AddAssignedToDirective = () -> EditAssignedToDirective = () ->
link = ($scope, $el, $attrs) -> link = ($scope, $el, $attrs) ->
$scope.watcherSearch = {} $scope.usersSearch = {}
$scope.$on "assigned-to:add", -> editingElement = null
$scope.$on "assigned-to:add", (ctx, element) ->
editingElement = element
$el.removeClass("hidden") $el.removeClass("hidden")
$el.find("input").focus() $el.find("input").focus()
$scope.$apply -> $scope.usersSearch = {}
$scope.watcherSearch = {}
$scope.$on "$destroy", -> $scope.$on "$destroy", ->
$el.off() $el.off()
@ -92,10 +94,12 @@ AddAssignedToDirective = () ->
$el.on "click", ".watcher-single", (event) -> $el.on "click", ".watcher-single", (event) ->
event.preventDefault() event.preventDefault()
target = angular.element(event.currentTarget) target = angular.element(event.currentTarget)
watcher = target.scope().user if editingElement?
editingElement.assigned_to = target.scope().user.id
$el.addClass("hidden") $el.addClass("hidden")
$scope.$broadcast("assigned-to:added", watcher) $scope.$broadcast("assigned-to:added", editingElement)
return {link:link} return {link:link}
module.directive("tgLbAddAssignedTo", AddAssignedToDirective) module.directive("tgLbEditAssignedTo", EditAssignedToDirective)

View File

@ -58,6 +58,10 @@ class TaskboardController extends mixOf(taiga.Controller, taiga.PageMixin)
@.loadTaskboard() @.loadTaskboard()
@scope.$on "taskform:edit:success", => @scope.$on "taskform:edit:success", =>
@.loadTaskboard() @.loadTaskboard()
@scope.$on "assigned-to:added", (ctx, task) =>
@scope.$apply(
@repo.save(task)
)
loadSprintStats: -> loadSprintStats: ->
return @rs.sprints.stats(@scope.projectId, @scope.sprintId).then (stats) => return @rs.sprints.stats(@scope.projectId, @scope.sprintId).then (stats) =>
@ -145,6 +149,9 @@ class TaskboardController extends mixOf(taiga.Controller, taiga.PageMixin)
editTask: (task) -> editTask: (task) ->
@rootscope.$broadcast("taskform:edit", task) @rootscope.$broadcast("taskform:edit", task)
editTaskAssignedTo: (task) ->
@rootscope.$broadcast("assigned-to:add", task)
module.controller("TaskboardController", TaskboardController) module.controller("TaskboardController", TaskboardController)

View File

@ -32,7 +32,7 @@ block content
sidebar.menu-secondary.sidebar sidebar.menu-secondary.sidebar
section.us-status(tg-issue-status, ng-model="issue", editable="true") 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.watchers(tg-watchers, ng-model="issue.watchers", editable="true")
section.us-detail-settings section.us-detail-settings
@ -50,7 +50,7 @@ block content
div.lightbox.lightbox_block.hidden(tg-lb-block, title="Blocking issue", ng-model="issue") div.lightbox.lightbox_block.hidden(tg-lb-block, title="Blocking issue", ng-model="issue")
include views/modules/lightbox_block 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 include views/modules/lightbox-assigned-to
div.lightbox.lightbox_select_user.hidden(tg-lb-add-watcher) div.lightbox.lightbox_select_user.hidden(tg-lb-add-watcher)

View File

@ -47,7 +47,7 @@ block content
sidebar.menu-secondary.sidebar sidebar.menu-secondary.sidebar
section.us-status(tg-issue-status, ng-model="issue") 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.watchers(tg-watchers, ng-model="issue.watchers")
section.us-detail-settings section.us-detail-settings

View File

@ -23,3 +23,5 @@ block content
include views/modules/lightbox_add-edit-task include views/modules/lightbox_add-edit-task
div.lightbox.lightbox_add-bulk.hidden(tg-lb-create-bulk-tasks) div.lightbox.lightbox_add-bulk.hidden(tg-lb-create-bulk-tasks)
include views/modules/lightbox_add-task-bulk include views/modules/lightbox_add-task-bulk
div.lightbox.lightbox_select_user.hidden(tg-lb-edit-assigned-to)
include views/modules/lightbox-assigned-to

View File

@ -2,7 +2,7 @@ div.taskboard-tagline
a.taskboard-tag(ng-repeat="tag in task.tags" href="" title="{{ tag }}") a.taskboard-tag(ng-repeat="tag in task.tags" href="" title="{{ tag }}")
div.taskboard-task-inner div.taskboard-task-inner
figure.avatar 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 }}", img.avatar(src="{{ usersById[task.assigned_to].photo }}",
alt="{{ usersById[task.assigned_to].username }}'s avatar") alt="{{ usersById[task.assigned_to].username }}'s avatar")
figcaption {{ usersById[task.assigned_to].full_name_display }} figcaption {{ usersById[task.assigned_to].full_name_display }}

View File

@ -3,10 +3,10 @@ a.close(href="", title="close")
form form
h2.title Select assigned to h2.title Select assigned to
fieldset 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.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 div.watcher-avatar
a.avatar(href="", title="Assigned to") a.avatar(href="", title="Assigned to")
img(tg-bo-src="user.photo", tg-bo-alt="user.photo") img(tg-bo-src="user.photo", tg-bo-alt="user.photo")

View File

@ -3,10 +3,10 @@ a.close(href="", title="close")
form form
h2.title Add watchers h2.title Add watchers
fieldset 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.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 div.watcher-avatar
a.avatar(href="", title="Assigned to") a.avatar(href="", title="Assigned to")
img(tg-bo-src="user.photo", tg-bo-alt="user.photo") img(tg-bo-src="user.photo", tg-bo-alt="user.photo")

View File

@ -201,7 +201,6 @@
@include clearfix(); @include clearfix();
@include transition(background .2s ease-in); @include transition(background .2s ease-in);
background: darken($whitish, 5%); background: darken($whitish, 5%);
cursor: pointer;
margin-bottom: .5rem; margin-bottom: .5rem;
padding: .5rem; padding: .5rem;
&:last-child { &:last-child {