Repair assign-to directives regressions
parent
eb68f1ada5
commit
28c0023310
|
@ -18,14 +18,15 @@
|
||||||
###
|
###
|
||||||
|
|
||||||
AssignedToInlineDirective = ($rootscope, $confirm, $repo, $loading, $modelTransform, $template
|
AssignedToInlineDirective = ($rootscope, $confirm, $repo, $loading, $modelTransform, $template
|
||||||
$translate, $compile, $currentUserService, avatarService) ->
|
$translate, $compile, $currentUserService, avatarService, $userListService) ->
|
||||||
link = ($scope, $el, $attrs, $ctrl) ->
|
link = ($scope, $el, $attr, $model) ->
|
||||||
isEditable = ->
|
isEditable = ->
|
||||||
return $scope.project?.my_permissions?.indexOf($attrs.requiredPerm) != -1
|
return $scope.project?.my_permissions?.indexOf($attr.requiredPerm) != -1
|
||||||
|
|
||||||
renderUserList = (text) ->
|
renderUserList = (text) ->
|
||||||
activeUsers = _.reject($scope.activeUsers, {"id": $scope.selected.id}) if $scope.selected?
|
selectedId = $model.$modelValue.assigned_to
|
||||||
users = $ctrl.getUserList(activeUsersactiveUsers, $scope.user.id, text)
|
users = $userListService.searchUsers(text)
|
||||||
|
users = _.reject(users, {"id": selectedId}) if selectedId
|
||||||
|
|
||||||
visibleUsers = _.slice(users, 0, 5)
|
visibleUsers = _.slice(users, 0, 5)
|
||||||
visibleUsers = _.map visibleUsers, (user) -> user.avatar = avatarService.getAvatar(user)
|
visibleUsers = _.map visibleUsers, (user) -> user.avatar = avatarService.getAvatar(user)
|
||||||
|
@ -58,16 +59,17 @@ $translate, $compile, $currentUserService, avatarService) ->
|
||||||
$el.on "click", ".users-dropdown", (event) ->
|
$el.on "click", ".users-dropdown", (event) ->
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
|
$scope.usersSearch = ""
|
||||||
renderUserList()
|
renderUserList()
|
||||||
$scope.$apply()
|
$scope.$apply()
|
||||||
$el.find(".pop-users").popover().open()
|
$el.find(".pop-users").popover().open()
|
||||||
|
|
||||||
$scope.selfAssign = () ->
|
$scope.selfAssign = () ->
|
||||||
$attr.ngModel.assigned_to = $currentUserService.getUser().get('id')
|
$model.$modelValue.assigned_to = $currentUserService.getUser().get('id')
|
||||||
renderUser($attr.ngModel)
|
renderUser($model.$modelValue)
|
||||||
|
|
||||||
$scope.unassign = () ->
|
$scope.unassign = () ->
|
||||||
$attr.ngModel.assigned_to = null
|
$model.$modelValue.assigned_to = null
|
||||||
renderUser()
|
renderUser()
|
||||||
|
|
||||||
$scope.$watch "usersSearch", (searchingText) ->
|
$scope.$watch "usersSearch", (searchingText) ->
|
||||||
|
@ -78,11 +80,11 @@ $translate, $compile, $currentUserService, avatarService) ->
|
||||||
$el.on "click", ".user-list-single", (event) ->
|
$el.on "click", ".user-list-single", (event) ->
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
target = angular.element(event.currentTarget)
|
target = angular.element(event.currentTarget)
|
||||||
$attr.ngModel.assigned_to = target.data("user-id")
|
$model.$modelValue.assigned_to = target.data("user-id")
|
||||||
renderUser($attr.ngModel)
|
renderUser($model.$modelValue)
|
||||||
$scope.$apply()
|
$scope.$apply()
|
||||||
|
|
||||||
$scope.$watch $attrs.ngModel, (instance) ->
|
$scope.$watch $attr.ngModel, (instance) ->
|
||||||
renderUser(instance)
|
renderUser(instance)
|
||||||
|
|
||||||
$scope.$on "isiocaine:changed", (ctx, instance) ->
|
$scope.$on "isiocaine:changed", (ctx, instance) ->
|
||||||
|
@ -94,8 +96,9 @@ $translate, $compile, $currentUserService, avatarService) ->
|
||||||
return {
|
return {
|
||||||
link:link,
|
link:link,
|
||||||
templateUrl: "common/components/assigned-to-inline.html"
|
templateUrl: "common/components/assigned-to-inline.html"
|
||||||
|
require:"ngModel"
|
||||||
}
|
}
|
||||||
|
|
||||||
angular.module('taigaComponents').directive("tgAssignedToInline", ["$rootScope", "$tgConfirm",
|
angular.module('taigaComponents').directive("tgAssignedToInline", ["$rootScope", "$tgConfirm",
|
||||||
"$tgRepo", "$tgLoading", "$tgQueueModelTransformation", "$tgTemplate", "$translate", "$compile",
|
"$tgRepo", "$tgLoading", "$tgQueueModelTransformation", "$tgTemplate", "$translate", "$compile",
|
||||||
"tgCurrentUserService", "tgAvatarService", AssignedToInlineDirective])
|
"tgCurrentUserService", "tgAvatarService", "tgUserListService", AssignedToInlineDirective])
|
||||||
|
|
|
@ -73,6 +73,7 @@ $translate, $compile, $currentUserService, avatarService, $userListService) ->
|
||||||
$el.on "click", ".users-dropdown", (event) ->
|
$el.on "click", ".users-dropdown", (event) ->
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
|
$scope.usersSearch = ""
|
||||||
renderUsersList()
|
renderUsersList()
|
||||||
$scope.$apply()
|
$scope.$apply()
|
||||||
$el.find(".pop-users").popover().open()
|
$el.find(".pop-users").popover().open()
|
||||||
|
@ -84,17 +85,10 @@ $translate, $compile, $currentUserService, avatarService, $userListService) ->
|
||||||
$scope.usersSearch = null
|
$scope.usersSearch = null
|
||||||
|
|
||||||
$scope.unassign = (user) ->
|
$scope.unassign = (user) ->
|
||||||
assignedUserId = user.id
|
userIndex = currentAssignedIds.indexOf(user.id)
|
||||||
|
currentAssignedIds.splice(userIndex, 1)
|
||||||
title = $translate.instant("COMMON.ASSIGNED_USERS.TITLE_LIGHTBOX_DELETE_ASSIGNED")
|
renderUsers()
|
||||||
message = $scope.usersById[assignedUserId].full_name_display
|
applyToModel()
|
||||||
|
|
||||||
$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()
|
||||||
|
|
Loading…
Reference in New Issue