Move assigned to lightbox directive to commons.
parent
2ef0a69679
commit
38c0fc1e10
|
@ -195,3 +195,75 @@ module.directive("tgLbCreateBulkUserstories", [
|
||||||
"$rootScope",
|
"$rootScope",
|
||||||
CreateBulkUserstoriesDirective
|
CreateBulkUserstoriesDirective
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
#############################################################################
|
||||||
|
## AssignedTo Lightbox Directive
|
||||||
|
#############################################################################
|
||||||
|
|
||||||
|
AssignedToLightboxDirective = ->
|
||||||
|
link = ($scope, $el, $attrs) ->
|
||||||
|
editingElement = null
|
||||||
|
|
||||||
|
updateScopeFilteringUsers = (searchingText) ->
|
||||||
|
console.log "updateScopeFilteringUsers", searchingText
|
||||||
|
usersById = _.clone($scope.usersById, false)
|
||||||
|
# Exclude selected user
|
||||||
|
if $scope.selectedUser?
|
||||||
|
delete usersById[$scope.selectedUser.id]
|
||||||
|
|
||||||
|
# Filter text
|
||||||
|
usersById = _.filter usersById, (user) ->
|
||||||
|
return _.contains(user.full_name_display.toUpperCase(), searchingText.toUpperCase())
|
||||||
|
|
||||||
|
# Return max of 5 elements
|
||||||
|
users = _.map(usersById, (user) -> user)
|
||||||
|
$scope.AssignedToUsersSearch = searchingText
|
||||||
|
$scope.filteringUsers = users.length > 5
|
||||||
|
$scope.filteredUsers = _.first(users, 5)
|
||||||
|
|
||||||
|
$scope.$on "assigned-to:add", (ctx, element) ->
|
||||||
|
editingElement = element
|
||||||
|
assignedToId = editingElement?.assigned_to
|
||||||
|
|
||||||
|
$scope.selectedUser = null
|
||||||
|
$scope.selectedUser = $scope.usersById[assignedToId] if assignedToId?
|
||||||
|
updateScopeFilteringUsers("")
|
||||||
|
|
||||||
|
$el.removeClass("hidden")
|
||||||
|
$el.find("input").focus()
|
||||||
|
|
||||||
|
$scope.$watch "AssignedToUsersSearch", (searchingText) ->
|
||||||
|
updateScopeFilteringUsers(searchingText)
|
||||||
|
|
||||||
|
$el.on "click", ".watcher-single", (event) ->
|
||||||
|
event.preventDefault()
|
||||||
|
target = angular.element(event.currentTarget)
|
||||||
|
if editingElement?
|
||||||
|
user = target.scope().user
|
||||||
|
editingElement.assigned_to = user.id
|
||||||
|
|
||||||
|
$el.addClass("hidden")
|
||||||
|
$scope.$broadcast("assigned-to:added", editingElement)
|
||||||
|
|
||||||
|
$el.on "click", ".remove-assigned-to", (event) ->
|
||||||
|
event.preventDefault()
|
||||||
|
event.stopPropagation()
|
||||||
|
|
||||||
|
if editingElement?
|
||||||
|
editingElement.assigned_to = null
|
||||||
|
|
||||||
|
$el.addClass("hidden")
|
||||||
|
$scope.$broadcast("assigned-to:added", editingElement)
|
||||||
|
|
||||||
|
$el.on "click", ".close", (event) ->
|
||||||
|
event.preventDefault()
|
||||||
|
$el.addClass("hidden")
|
||||||
|
|
||||||
|
$scope.$on "$destroy", ->
|
||||||
|
$el.off()
|
||||||
|
|
||||||
|
return {link:link}
|
||||||
|
|
||||||
|
|
||||||
|
module.directive("tgLbAssignedto", AssignedToLightboxDirective)
|
||||||
|
|
|
@ -153,75 +153,3 @@ AddWatcherDirective = ->
|
||||||
return {link:link}
|
return {link:link}
|
||||||
|
|
||||||
module.directive("tgLbAddWatcher", AddWatcherDirective)
|
module.directive("tgLbAddWatcher", AddWatcherDirective)
|
||||||
|
|
||||||
#############################################################################
|
|
||||||
## AssignedTo Lightbox Directive
|
|
||||||
#############################################################################
|
|
||||||
|
|
||||||
# FIXME: rename to: AssignedToLightboxDirective/tgLbAssignedto
|
|
||||||
|
|
||||||
EditAssignedToDirective = ->
|
|
||||||
link = ($scope, $el, $attrs) ->
|
|
||||||
editingElement = null
|
|
||||||
|
|
||||||
updateScopeFilteringUsers = (searchingText) ->
|
|
||||||
console.log "updateScopeFilteringUsers", searchingText
|
|
||||||
usersById = _.clone($scope.usersById, false)
|
|
||||||
# Exclude selected user
|
|
||||||
if $scope.selectedUser?
|
|
||||||
delete usersById[$scope.selectedUser.id]
|
|
||||||
|
|
||||||
# Filter text
|
|
||||||
usersById = _.filter usersById, (user) ->
|
|
||||||
return _.contains(user.full_name_display.toUpperCase(), searchingText.toUpperCase())
|
|
||||||
|
|
||||||
# Return max of 5 elements
|
|
||||||
users = _.map(usersById, (user) -> user)
|
|
||||||
$scope.AssignedToUsersSearch = searchingText
|
|
||||||
$scope.filteringUsers = users.length > 5
|
|
||||||
$scope.filteredUsers = _.first(users, 5)
|
|
||||||
|
|
||||||
$scope.$on "assigned-to:add", (ctx, element) ->
|
|
||||||
editingElement = element
|
|
||||||
assignedToId = editingElement?.assigned_to
|
|
||||||
|
|
||||||
$scope.selectedUser = null
|
|
||||||
$scope.selectedUser = $scope.usersById[assignedToId] if assignedToId?
|
|
||||||
updateScopeFilteringUsers("")
|
|
||||||
|
|
||||||
$el.removeClass("hidden")
|
|
||||||
$el.find("input").focus()
|
|
||||||
|
|
||||||
$scope.$watch "AssignedToUsersSearch", (searchingText) ->
|
|
||||||
updateScopeFilteringUsers(searchingText)
|
|
||||||
|
|
||||||
$el.on "click", ".watcher-single", (event) ->
|
|
||||||
event.preventDefault()
|
|
||||||
target = angular.element(event.currentTarget)
|
|
||||||
if editingElement?
|
|
||||||
user = target.scope().user
|
|
||||||
editingElement.assigned_to = user.id
|
|
||||||
|
|
||||||
$el.addClass("hidden")
|
|
||||||
$scope.$broadcast("assigned-to:added", editingElement)
|
|
||||||
|
|
||||||
$el.on "click", ".remove-assigned-to", (event) ->
|
|
||||||
event.preventDefault()
|
|
||||||
event.stopPropagation()
|
|
||||||
|
|
||||||
if editingElement?
|
|
||||||
editingElement.assigned_to = null
|
|
||||||
|
|
||||||
$el.addClass("hidden")
|
|
||||||
$scope.$broadcast("assigned-to:added", editingElement)
|
|
||||||
|
|
||||||
$el.on "click", ".close", (event) ->
|
|
||||||
event.preventDefault()
|
|
||||||
$el.addClass("hidden")
|
|
||||||
|
|
||||||
$scope.$on "$destroy", ->
|
|
||||||
$el.off()
|
|
||||||
|
|
||||||
return {link:link}
|
|
||||||
|
|
||||||
module.directive("tgLbEditAssignedTo", EditAssignedToDirective)
|
|
||||||
|
|
|
@ -41,7 +41,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-edit-assigned-to)
|
div.lightbox.lightbox_select_user.hidden(tg-lb-assignedto)
|
||||||
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)
|
||||||
|
|
|
@ -45,7 +45,7 @@ block content
|
||||||
div.lightbox.lightbox_block.hidden(tg-lb-block, title="Blocking task", ng-model="task")
|
div.lightbox.lightbox_block.hidden(tg-lb-block, title="Blocking task", ng-model="task")
|
||||||
include views/modules/lightbox_block
|
include views/modules/lightbox_block
|
||||||
|
|
||||||
div.lightbox.lightbox_select_user.hidden(tg-lb-edit-assigned-to)
|
div.lightbox.lightbox_select_user.hidden(tg-lb-assignedto)
|
||||||
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)
|
||||||
|
|
|
@ -23,5 +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)
|
div.lightbox.lightbox_select_user.hidden(tg-lb-assignedto)
|
||||||
include views/modules/lightbox-assigned-to
|
include views/modules/lightbox-assigned-to
|
||||||
|
|
|
@ -48,7 +48,7 @@ block content
|
||||||
div.lightbox.lightbox_block.hidden(tg-lb-block, title="Blocking issue", ng-model="us")
|
div.lightbox.lightbox_block.hidden(tg-lb-block, title="Blocking issue", ng-model="us")
|
||||||
include views/modules/lightbox_block
|
include views/modules/lightbox_block
|
||||||
|
|
||||||
div.lightbox.lightbox_select_user.hidden(tg-lb-edit-assigned-to)
|
div.lightbox.lightbox_select_user.hidden(tg-lb-assignedto)
|
||||||
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)
|
||||||
|
|
Loading…
Reference in New Issue