Check permissions in move-to-sprint component

stable
Daniel García 2018-11-19 18:12:27 +01:00 committed by Alex Hermida
parent b554572331
commit 7a80fbbac2
6 changed files with 50 additions and 24 deletions

View File

@ -1401,6 +1401,7 @@
"TITLE_ACTION_MOVE_UNFINISHED": "Move unfinished items to another sprint", "TITLE_ACTION_MOVE_UNFINISHED": "Move unfinished items to another sprint",
"TITLE_MOVE_UNFINISHED": "Move unfinished items to another open sprint", "TITLE_MOVE_UNFINISHED": "Move unfinished items to another open sprint",
"MOVE_TO_OPEN_SPRINT": "Move to open sprint", "MOVE_TO_OPEN_SPRINT": "Move to open sprint",
"NO_OPEN_SPRINTS": "There are no other open sprints. Please create one first.",
"SELECT_DESTINATION_PLACEHOLDER": "Select destination", "SELECT_DESTINATION_PLACEHOLDER": "Select destination",
"UNFINISHED_USER_STORIES_COUNT": "{total, plural, one{<strong>#</strong> unfinished user story} other{<strong>#</strong> unfinished user stories}}", "UNFINISHED_USER_STORIES_COUNT": "{total, plural, one{<strong>#</strong> unfinished user story} other{<strong>#</strong> unfinished user stories}}",
"UNFINISHED_UNASSIGNED_TASKS_COUNT": "{total, plural, one{<strong>#</strong> unfinished unnasigned task} other{<strong>#</strong> unfinished unnasigned tasks}}", "UNFINISHED_UNASSIGNED_TASKS_COUNT": "{total, plural, one{<strong>#</strong> unfinished unnasigned task} other{<strong>#</strong> unfinished unnasigned tasks}}",

View File

@ -69,7 +69,7 @@ class MoveToSprintLightboxController
_loadSprints: () -> _loadSprints: () ->
@rs.sprints.list(@.projectId, {closed: false}).then (data) => @rs.sprints.list(@.projectId, {closed: false}).then (data) =>
@.sprints = data.milestones @.sprints = _.filter(data.milestones, (x) => x.id != @.sprint.id)
updateSelected: (itemType, value) -> updateSelected: (itemType, value) ->
@.typesSelected[itemType] = value @.typesSelected[itemType] = value

View File

@ -13,6 +13,7 @@ tg-lightbox-close
ng-checked="vm.typesSelected['uss']" ng-checked="vm.typesSelected['uss']"
ng-model="vm.typesSelected['uss']" ng-model="vm.typesSelected['uss']"
ng-change="vm.updateSelected('uss', vm.typesSelected['uss'])" ng-change="vm.updateSelected('uss', vm.typesSelected['uss'])"
ng-disabled="!vm.sprints.length"
) )
div div
span.check-text.check-yes(translate="COMMON.YES") span.check-text.check-yes(translate="COMMON.YES")
@ -26,6 +27,7 @@ tg-lightbox-close
ng-checked="vm.typesSelected['tasks']" ng-checked="vm.typesSelected['tasks']"
ng-model="vm.typesSelected['tasks']" ng-model="vm.typesSelected['tasks']"
ng-change="vm.updateSelected('tasks', vm.typesSelected['tasks'])" ng-change="vm.updateSelected('tasks', vm.typesSelected['tasks'])"
ng-disabled="!vm.sprints.length"
) )
div div
span.check-text.check-yes(translate="COMMON.YES") span.check-text.check-yes(translate="COMMON.YES")
@ -39,17 +41,20 @@ tg-lightbox-close
ng-checked="vm.typesSelected['issues']" ng-checked="vm.typesSelected['issues']"
ng-model="vm.typesSelected['issues']" ng-model="vm.typesSelected['issues']"
ng-change="vm.updateSelected('issues', vm.typesSelected['issues'])" ng-change="vm.updateSelected('issues', vm.typesSelected['issues'])"
ng-disabled="!vm.sprints.length"
) )
div div
span.check-text.check-yes(translate="COMMON.YES") span.check-text.check-yes(translate="COMMON.YES")
span.check-text.check-no(translate="COMMON.NO") span.check-text.check-no(translate="COMMON.NO")
.move-to-sprint-controls .move-to-sprint-controls
p(ng-if="!vm.sprints.length") {{ 'TASKBOARD.MOVE_TO_SPRINT.NO_OPEN_SPRINTS'|translate }}
div(ng-if="vm.sprints.length > 0")
fieldset fieldset
label {{ 'TASKBOARD.MOVE_TO_SPRINT.MOVE_TO_OPEN_SPRINT'|translate }} label {{ 'TASKBOARD.MOVE_TO_SPRINT.MOVE_TO_OPEN_SPRINT'|translate }}
select.sprint-select( select.sprint-select(
ng-model="vm.selectedSprintId" ng-model="vm.selectedSprintId"
ng-options="s.id as s.name for s in vm.sprints|filter: { id: '!' + vm.sprint.id }" ng-options="s.id as s.name for s in vm.sprints"
id="sprint-selector-dropdown" id="sprint-selector-dropdown"
autofocus autofocus
) )

View File

@ -22,6 +22,10 @@
} }
} }
.move-to-sprint-controls { .move-to-sprint-controls {
p {
margin-bottom: 2.5em;
text-align: center;
}
.sprint-select { .sprint-select {
margin-top: .5em; margin-top: .5em;
} }

View File

@ -23,9 +23,15 @@ class MoveToSprintController
@.$inject = [ @.$inject = [
'$scope' '$scope'
'tgLightboxFactory' 'tgLightboxFactory'
'tgProjectService'
] ]
constructor: (@scope, @lightboxFactory) -> constructor: (
@scope
@lightboxFactory
@projectService
) ->
@.permissions = @projectService.project.get('my_permissions')
@.hasOpenItems = false @.hasOpenItems = false
@.disabled = false @.disabled = false
@.openItems = { @.openItems = {
@ -58,7 +64,7 @@ class MoveToSprintController
}) })
getOpenUss: () -> getOpenUss: () ->
return if !@.uss return if !@.uss or @.permissions.indexOf("modify_us") == -1
@.openItems.uss = [] @.openItems.uss = []
@.uss.map (us) => @.uss.map (us) =>
if us.is_closed is false if us.is_closed is false
@ -69,7 +75,7 @@ class MoveToSprintController
@.hasOpenItems = @checkOpenItems() @.hasOpenItems = @checkOpenItems()
getOpenUnassignedTasks: () -> getOpenUnassignedTasks: () ->
return if !@.unnasignedTasks return if !@.unnasignedTasks or @.permissions.indexOf("modify_task") == -1
@.openItems.tasks = [] @.openItems.tasks = []
@.unnasignedTasks.map (column) => column.map (task) => @.unnasignedTasks.map (column) => column.map (task) =>
if task.get('model').get('is_closed') is false if task.get('model').get('is_closed') is false
@ -80,7 +86,7 @@ class MoveToSprintController
@.hasOpenItems = @checkOpenItems() @.hasOpenItems = @checkOpenItems()
getOpenIssues: () -> getOpenIssues: () ->
return if !@.issues return if !@.issues or @.permissions.indexOf("modify_issue") == -1
@.openItems.issues = [] @.openItems.issues = []
@.issues.map (issue) => @.issues.map (issue) =>
if issue.get('status').get('is_closed') is false if issue.get('status').get('is_closed') is false

View File

@ -31,10 +31,20 @@ describe "MoveToSprint", ->
provide.value "tgLightboxFactory", mocks.tgLightboxFactory provide.value "tgLightboxFactory", mocks.tgLightboxFactory
_mockTgProjectService = () ->
mocks.tgProjectService = {
project: Immutable.fromJS({
my_permissions: ['modify_us', 'modify_task', 'modify_issue']
})
}
provide.value "tgProjectService", mocks.tgProjectService
_mocks = () -> _mocks = () ->
module ($provide) -> module ($provide) ->
provide = $provide provide = $provide
_mockTgLightboxFactory() _mockTgLightboxFactory()
_mockTgProjectService()
return null return null
_inject = -> _inject = ->