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_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}}",
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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,29 +41,32 @@ 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
|
||||||
fieldset
|
p(ng-if="!vm.sprints.length") {{ 'TASKBOARD.MOVE_TO_SPRINT.NO_OPEN_SPRINTS'|translate }}
|
||||||
label {{ 'TASKBOARD.MOVE_TO_SPRINT.MOVE_TO_OPEN_SPRINT'|translate }}
|
div(ng-if="vm.sprints.length > 0")
|
||||||
select.sprint-select(
|
fieldset
|
||||||
ng-model="vm.selectedSprintId"
|
label {{ 'TASKBOARD.MOVE_TO_SPRINT.MOVE_TO_OPEN_SPRINT'|translate }}
|
||||||
ng-options="s.id as s.name for s in vm.sprints|filter: { id: '!' + vm.sprint.id }"
|
select.sprint-select(
|
||||||
id="sprint-selector-dropdown"
|
ng-model="vm.selectedSprintId"
|
||||||
autofocus
|
ng-options="s.id as s.name for s in vm.sprints"
|
||||||
|
id="sprint-selector-dropdown"
|
||||||
|
autofocus
|
||||||
|
)
|
||||||
|
option(
|
||||||
|
value=""
|
||||||
|
disabled
|
||||||
|
selected
|
||||||
|
translate="TASKBOARD.MOVE_TO_SPRINT.SELECT_DESTINATION_PLACEHOLDER"
|
||||||
|
)
|
||||||
|
button.button-green.move-button(
|
||||||
|
href=""
|
||||||
|
ng-click="vm.submit()"
|
||||||
|
translate="COMMON.SAVE"
|
||||||
|
ng-disabled="!(vm.selectedSprintId && vm.someSelected)"
|
||||||
)
|
)
|
||||||
option(
|
|
||||||
value=""
|
|
||||||
disabled
|
|
||||||
selected
|
|
||||||
translate="TASKBOARD.MOVE_TO_SPRINT.SELECT_DESTINATION_PLACEHOLDER"
|
|
||||||
)
|
|
||||||
button.button-green.move-button(
|
|
||||||
href=""
|
|
||||||
ng-click="vm.submit()"
|
|
||||||
translate="COMMON.SAVE"
|
|
||||||
ng-disabled="!(vm.selectedSprintId && vm.someSelected)"
|
|
||||||
)
|
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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 = ->
|
||||||
|
|
Loading…
Reference in New Issue