From 28c00233102f3462f9b1fa5900df1748a17eec9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Wed, 19 Sep 2018 10:10:55 +0200 Subject: [PATCH 1/3] Repair assign-to directives regressions --- .../assigned-to-inline.directive.coffee | 27 ++++++++++--------- .../assigned-users-inline.directive.coffee | 16 ++++------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/app/modules/components/assigned/assigned-to-inline.directive.coffee b/app/modules/components/assigned/assigned-to-inline.directive.coffee index f791d436..c2b611d3 100644 --- a/app/modules/components/assigned/assigned-to-inline.directive.coffee +++ b/app/modules/components/assigned/assigned-to-inline.directive.coffee @@ -18,14 +18,15 @@ ### AssignedToInlineDirective = ($rootscope, $confirm, $repo, $loading, $modelTransform, $template -$translate, $compile, $currentUserService, avatarService) -> - link = ($scope, $el, $attrs, $ctrl) -> +$translate, $compile, $currentUserService, avatarService, $userListService) -> + link = ($scope, $el, $attr, $model) -> isEditable = -> - return $scope.project?.my_permissions?.indexOf($attrs.requiredPerm) != -1 + return $scope.project?.my_permissions?.indexOf($attr.requiredPerm) != -1 renderUserList = (text) -> - activeUsers = _.reject($scope.activeUsers, {"id": $scope.selected.id}) if $scope.selected? - users = $ctrl.getUserList(activeUsersactiveUsers, $scope.user.id, text) + selectedId = $model.$modelValue.assigned_to + users = $userListService.searchUsers(text) + users = _.reject(users, {"id": selectedId}) if selectedId visibleUsers = _.slice(users, 0, 5) visibleUsers = _.map visibleUsers, (user) -> user.avatar = avatarService.getAvatar(user) @@ -58,16 +59,17 @@ $translate, $compile, $currentUserService, avatarService) -> $el.on "click", ".users-dropdown", (event) -> event.preventDefault() event.stopPropagation() + $scope.usersSearch = "" renderUserList() $scope.$apply() $el.find(".pop-users").popover().open() $scope.selfAssign = () -> - $attr.ngModel.assigned_to = $currentUserService.getUser().get('id') - renderUser($attr.ngModel) + $model.$modelValue.assigned_to = $currentUserService.getUser().get('id') + renderUser($model.$modelValue) $scope.unassign = () -> - $attr.ngModel.assigned_to = null + $model.$modelValue.assigned_to = null renderUser() $scope.$watch "usersSearch", (searchingText) -> @@ -78,11 +80,11 @@ $translate, $compile, $currentUserService, avatarService) -> $el.on "click", ".user-list-single", (event) -> event.preventDefault() target = angular.element(event.currentTarget) - $attr.ngModel.assigned_to = target.data("user-id") - renderUser($attr.ngModel) + $model.$modelValue.assigned_to = target.data("user-id") + renderUser($model.$modelValue) $scope.$apply() - $scope.$watch $attrs.ngModel, (instance) -> + $scope.$watch $attr.ngModel, (instance) -> renderUser(instance) $scope.$on "isiocaine:changed", (ctx, instance) -> @@ -94,8 +96,9 @@ $translate, $compile, $currentUserService, avatarService) -> return { link:link, templateUrl: "common/components/assigned-to-inline.html" + require:"ngModel" } angular.module('taigaComponents').directive("tgAssignedToInline", ["$rootScope", "$tgConfirm", "$tgRepo", "$tgLoading", "$tgQueueModelTransformation", "$tgTemplate", "$translate", "$compile", -"tgCurrentUserService", "tgAvatarService", AssignedToInlineDirective]) +"tgCurrentUserService", "tgAvatarService", "tgUserListService", AssignedToInlineDirective]) diff --git a/app/modules/components/assigned/assigned-users-inline.directive.coffee b/app/modules/components/assigned/assigned-users-inline.directive.coffee index 975cbef1..d4a42c10 100644 --- a/app/modules/components/assigned/assigned-users-inline.directive.coffee +++ b/app/modules/components/assigned/assigned-users-inline.directive.coffee @@ -73,6 +73,7 @@ $translate, $compile, $currentUserService, avatarService, $userListService) -> $el.on "click", ".users-dropdown", (event) -> event.preventDefault() event.stopPropagation() + $scope.usersSearch = "" renderUsersList() $scope.$apply() $el.find(".pop-users").popover().open() @@ -84,17 +85,10 @@ $translate, $compile, $currentUserService, avatarService, $userListService) -> $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() + userIndex = currentAssignedIds.indexOf(user.id) + currentAssignedIds.splice(userIndex, 1) + renderUsers() + applyToModel() $el.on "click", ".users-search", (event) -> event.stopPropagation() From 27bd09125606482d63ece0c5a0ef7b481062661d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Wed, 19 Sep 2018 12:08:20 +0200 Subject: [PATCH 2/3] Rapaired assign to directive --- .../assigned-users-inline.directive.coffee | 27 ++++++------------- .../components/assigned-users-inline.jade | 1 + 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/app/modules/components/assigned/assigned-users-inline.directive.coffee b/app/modules/components/assigned/assigned-users-inline.directive.coffee index d4a42c10..7aad89fa 100644 --- a/app/modules/components/assigned/assigned-users-inline.directive.coffee +++ b/app/modules/components/assigned/assigned-users-inline.directive.coffee @@ -73,20 +73,24 @@ $translate, $compile, $currentUserService, avatarService, $userListService) -> $el.on "click", ".users-dropdown", (event) -> event.preventDefault() event.stopPropagation() - $scope.usersSearch = "" + $scope.usersSearch = null renderUsersList() $scope.$apply() $el.find(".pop-users").popover().open() + $scope.assign = (user) -> + currentAssignedIds.push(user.id) + renderUsers() + applyToModel() + $scope.selfAssign = () -> currentAssignedIds.push($currentUserService.getUser().get('id')) renderUsers() applyToModel() - $scope.usersSearch = null $scope.unassign = (user) -> - userIndex = currentAssignedIds.indexOf(user.id) - currentAssignedIds.splice(userIndex, 1) + index = currentAssignedIds.indexOf(user.id) + currentAssignedIds.splice(index, 1) renderUsers() applyToModel() @@ -98,21 +102,6 @@ $translate, $compile, $currentUserService, avatarService, $userListService) -> renderUsersList(searchingText) $el.find('input').focus() - $el.on "click", ".user-list-single", (event) -> - event.preventDefault() - event.stopPropagation() - target = angular.element(event.currentTarget) - index = currentAssignedIds.indexOf(target.data("user-id")) - if index == -1 - currentAssignedIds.push(target.data("user-id")) - else - currentAssignedIds.splice(index, 1) - applyToModel() - renderUsers() - $el.find(".pop-users").popover().close() - $scope.usersSearch = null - $scope.$apply() - $scope.$watch $attrs.ngModel, (item) -> return if not item? currentAssignedIds = [] diff --git a/app/partials/common/components/assigned-users-inline.jade b/app/partials/common/components/assigned-users-inline.jade index a730d833..1224012c 100644 --- a/app/partials/common/components/assigned-users-inline.jade +++ b/app/partials/common/components/assigned-users-inline.jade @@ -95,6 +95,7 @@ div.pop-users.popover(ng-class="{'multiple': assignedUsers.length > 0}") data-user-id="{{ user.id }}" title="{{ user.full_name_display }}" ng-repeat="user in users" + ng-click="assign(user)" ) img.user-list-avatar( style="background: {{user.avatar.bg }}" From 9f6462224f13eb5cd36c014ae34c258b4226e515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Hermida?= Date: Wed, 19 Sep 2018 12:53:47 +0200 Subject: [PATCH 3/3] Update change log --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc152ccd..2e34275f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## Unreleased +## 3.4.4 (2018-09-19) + +### Misc + +- Minor bug fixes. + ## 3.4.3 (2018-09-19) ### Misc