Check permissions in move-to-sprint component
parent
b554572331
commit
7a80fbbac2
|
@ -1401,6 +1401,7 @@
|
|||
"TITLE_ACTION_MOVE_UNFINISHED": "Move unfinished items to another sprint",
|
||||
"TITLE_MOVE_UNFINISHED": "Move unfinished items to another 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",
|
||||
"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}}",
|
||||
|
|
|
@ -69,7 +69,7 @@ class MoveToSprintLightboxController
|
|||
|
||||
_loadSprints: () ->
|
||||
@rs.sprints.list(@.projectId, {closed: false}).then (data) =>
|
||||
@.sprints = data.milestones
|
||||
@.sprints = _.filter(data.milestones, (x) => x.id != @.sprint.id)
|
||||
|
||||
updateSelected: (itemType, value) ->
|
||||
@.typesSelected[itemType] = value
|
||||
|
|
|
@ -13,6 +13,7 @@ tg-lightbox-close
|
|||
ng-checked="vm.typesSelected['uss']"
|
||||
ng-model="vm.typesSelected['uss']"
|
||||
ng-change="vm.updateSelected('uss', vm.typesSelected['uss'])"
|
||||
ng-disabled="!vm.sprints.length"
|
||||
)
|
||||
div
|
||||
span.check-text.check-yes(translate="COMMON.YES")
|
||||
|
@ -26,6 +27,7 @@ tg-lightbox-close
|
|||
ng-checked="vm.typesSelected['tasks']"
|
||||
ng-model="vm.typesSelected['tasks']"
|
||||
ng-change="vm.updateSelected('tasks', vm.typesSelected['tasks'])"
|
||||
ng-disabled="!vm.sprints.length"
|
||||
)
|
||||
div
|
||||
span.check-text.check-yes(translate="COMMON.YES")
|
||||
|
@ -39,17 +41,20 @@ tg-lightbox-close
|
|||
ng-checked="vm.typesSelected['issues']"
|
||||
ng-model="vm.typesSelected['issues']"
|
||||
ng-change="vm.updateSelected('issues', vm.typesSelected['issues'])"
|
||||
ng-disabled="!vm.sprints.length"
|
||||
)
|
||||
div
|
||||
span.check-text.check-yes(translate="COMMON.YES")
|
||||
span.check-text.check-no(translate="COMMON.NO")
|
||||
|
||||
.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
|
||||
label {{ 'TASKBOARD.MOVE_TO_SPRINT.MOVE_TO_OPEN_SPRINT'|translate }}
|
||||
select.sprint-select(
|
||||
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"
|
||||
autofocus
|
||||
)
|
||||
|
|
|
@ -22,6 +22,10 @@
|
|||
}
|
||||
}
|
||||
.move-to-sprint-controls {
|
||||
p {
|
||||
margin-bottom: 2.5em;
|
||||
text-align: center;
|
||||
}
|
||||
.sprint-select {
|
||||
margin-top: .5em;
|
||||
}
|
||||
|
|
|
@ -23,9 +23,15 @@ class MoveToSprintController
|
|||
@.$inject = [
|
||||
'$scope'
|
||||
'tgLightboxFactory'
|
||||
'tgProjectService'
|
||||
]
|
||||
|
||||
constructor: (@scope, @lightboxFactory) ->
|
||||
constructor: (
|
||||
@scope
|
||||
@lightboxFactory
|
||||
@projectService
|
||||
) ->
|
||||
@.permissions = @projectService.project.get('my_permissions')
|
||||
@.hasOpenItems = false
|
||||
@.disabled = false
|
||||
@.openItems = {
|
||||
|
@ -58,7 +64,7 @@ class MoveToSprintController
|
|||
})
|
||||
|
||||
getOpenUss: () ->
|
||||
return if !@.uss
|
||||
return if !@.uss or @.permissions.indexOf("modify_us") == -1
|
||||
@.openItems.uss = []
|
||||
@.uss.map (us) =>
|
||||
if us.is_closed is false
|
||||
|
@ -69,7 +75,7 @@ class MoveToSprintController
|
|||
@.hasOpenItems = @checkOpenItems()
|
||||
|
||||
getOpenUnassignedTasks: () ->
|
||||
return if !@.unnasignedTasks
|
||||
return if !@.unnasignedTasks or @.permissions.indexOf("modify_task") == -1
|
||||
@.openItems.tasks = []
|
||||
@.unnasignedTasks.map (column) => column.map (task) =>
|
||||
if task.get('model').get('is_closed') is false
|
||||
|
@ -80,7 +86,7 @@ class MoveToSprintController
|
|||
@.hasOpenItems = @checkOpenItems()
|
||||
|
||||
getOpenIssues: () ->
|
||||
return if !@.issues
|
||||
return if !@.issues or @.permissions.indexOf("modify_issue") == -1
|
||||
@.openItems.issues = []
|
||||
@.issues.map (issue) =>
|
||||
if issue.get('status').get('is_closed') is false
|
||||
|
|
|
@ -31,10 +31,20 @@ describe "MoveToSprint", ->
|
|||
|
||||
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 = () ->
|
||||
module ($provide) ->
|
||||
provide = $provide
|
||||
_mockTgLightboxFactory()
|
||||
_mockTgProjectService()
|
||||
return null
|
||||
|
||||
_inject = ->
|
||||
|
|
Loading…
Reference in New Issue