Repaired unassignment in lighboxes

stable
Miguel Gonzalez 2018-08-31 11:57:42 +02:00 committed by Alex Hermida
parent 39f06a09ee
commit 4ef16b84cf
1 changed files with 19 additions and 4 deletions

View File

@ -19,7 +19,7 @@
AssignedUsersInlineDirective = ($rootscope, $confirm, $repo, $loading, $modelTransform, $template AssignedUsersInlineDirective = ($rootscope, $confirm, $repo, $loading, $modelTransform, $template
$translate, $compile, $currentUserService, avatarService, $userListService) -> $translate, $compile, $currentUserService, avatarService, $userListService) ->
link = ($scope, $el, $attrs, $ctrl) -> link = ($scope, $el, $attrs, $model) ->
currentAssignedIds = [] currentAssignedIds = []
currentAssignedTo = null currentAssignedTo = null
@ -67,8 +67,8 @@ $translate, $compile, $currentUserService, avatarService, $userListService) ->
currentAssignedTo = null currentAssignedTo = null
else if currentAssignedIds.indexOf(currentAssignedTo) == -1 || !currentAssignedTo else if currentAssignedIds.indexOf(currentAssignedTo) == -1 || !currentAssignedTo
currentAssignedTo = currentAssignedIds[0] currentAssignedTo = currentAssignedIds[0]
$attr.ngModel.setAttr('assigned_users', currentAssignedIds) $model.$modelValue.setAttr('assigned_users', currentAssignedIds)
$attr.ngModel.assigned_to = currentAssignedTo $model.$modelValue.assigned_to = currentAssignedTo
$el.on "click", ".users-dropdown", (event) -> $el.on "click", ".users-dropdown", (event) ->
event.preventDefault() event.preventDefault()
@ -83,6 +83,19 @@ $translate, $compile, $currentUserService, avatarService, $userListService) ->
applyToModel() applyToModel()
$scope.usersSearch = null $scope.usersSearch = null
$scope.unassign = (user) ->
assignedUserId = user.id
title = $translate.instant("COMMON.ASSIGNED_USERS.TITLE_LIGHTBOX_DELETE_ASSIGNED")
message = $scope.usersById[assignedUserId].full_name_display
$confirm.askOnDelete(title, message).then (askResponse) ->
users = $model.$modelValue.assigned_users
users.splice(users.indexOf(assignedUserId), 1)
renderUsers()
applyToModel()
askResponse.finish()
$el.on "click", ".users-search", (event) -> $el.on "click", ".users-search", (event) ->
event.stopPropagation() event.stopPropagation()
@ -100,6 +113,7 @@ $translate, $compile, $currentUserService, avatarService, $userListService) ->
currentAssignedIds.push(target.data("user-id")) currentAssignedIds.push(target.data("user-id"))
else else
currentAssignedIds.splice(index, 1) currentAssignedIds.splice(index, 1)
applyToModel()
renderUsers() renderUsers()
$el.find(".pop-users").popover().close() $el.find(".pop-users").popover().close()
$scope.usersSearch = null $scope.usersSearch = null
@ -121,7 +135,8 @@ $translate, $compile, $currentUserService, avatarService, $userListService) ->
return { return {
scope: true, scope: true,
link:link, link:link,
templateUrl: "common/components/assigned-users-inline.html" templateUrl: "common/components/assigned-users-inline.html",
require:"ngModel"
} }
angular.module('taigaComponents').directive("tgAssignedUsersInline", ["$rootScope", "$tgConfirm", angular.module('taigaComponents').directive("tgAssignedUsersInline", ["$rootScope", "$tgConfirm",