manages focus for assignments/discussion page menus
fixes CNVS-12718 test plan: - in a course with 2+ assignment groups - once with 1 assignment each, once with 2+ each - with draft state on - on assignment index page - using keyboard navigation for everything - click 'move to' for an assignment, close the dialog - verify that focus is directed to the settings cog for that assignment - repeat for an assignment group - click 'delete' for an assignment, click cancel - verify that focus is directed to the settings cog - click 'delete' for an assignment, click ok - for groups with 1 assignment: verify that focus goes to parent assignment group - for groups with 2+ assignments: verify that focus goes to previous assignment in list - for first assignment in list: verify that focus goes to parent assignment group - with draft state on - on discussion index page - repeat 'move to' and 'delete' verifications from above Change-Id: I0940b5eed70cecb628c25c597b8439598d096d24 Reviewed-on: https://gerrit.instructure.com/35120 Reviewed-by: Cameron Sutter <csutter@instructure.com> QA-Review: Amber Taniuchi <amber@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> Product-Review: Aaron Cannon <acannon@instructure.com>
This commit is contained in:
parent
608b0896e2
commit
ab7eddaa6b
|
@ -59,6 +59,7 @@ define [
|
|||
@moveItemView = new MoveDialogView
|
||||
model: @model
|
||||
nested: true
|
||||
closeTarget: @$el.find('a[id=manage_link]')
|
||||
saveURL: -> @model.collection.reorderURL()
|
||||
super
|
||||
|
||||
|
@ -88,7 +89,11 @@ define [
|
|||
# Returns nothing.
|
||||
onDelete: (e) =>
|
||||
e.preventDefault()
|
||||
@delete() if confirm(@messages.confirm)
|
||||
if confirm(@messages.confirm)
|
||||
@goToPrevItem()
|
||||
@delete()
|
||||
else
|
||||
@$el.find('a[id=manage_link]').focus()
|
||||
|
||||
# Public: Delete the model and update the server.
|
||||
#
|
||||
|
@ -97,6 +102,20 @@ define [
|
|||
@model.destroy()
|
||||
@$el.remove()
|
||||
|
||||
goToPrevItem: =>
|
||||
if @previousDiscussionInGroup()?
|
||||
$('#' + @previousDiscussionInGroup().id + '_discussion_content').attr("tabindex",-1).focus()
|
||||
else if @model.get('pinned')
|
||||
$('.pinned&.discussion-list').attr("tabindex",-1).focus()
|
||||
else if @model.get('locked')
|
||||
$('.locked&.discussion-list').attr("tabindex",-1).focus()
|
||||
else
|
||||
$('.open&.discussion-list').attr("tabindex",-1).focus()
|
||||
|
||||
previousDiscussionInGroup: =>
|
||||
current_index = @model.collection.models.indexOf(@model)
|
||||
@model.collection.models[current_index - 1]
|
||||
|
||||
# Public: Pin or unpin the model and update it on the server.
|
||||
#
|
||||
# e - Event object.
|
||||
|
|
|
@ -46,6 +46,11 @@ define [
|
|||
# required if @nested
|
||||
@optionProperty 'childKey'
|
||||
|
||||
# {jQuery selector}
|
||||
# link to focus on after dialog is closed
|
||||
# without taking any action
|
||||
@optionProperty 'closeTarget'
|
||||
|
||||
# {string or function}
|
||||
# url to post to when saving the form
|
||||
#
|
||||
|
@ -104,6 +109,7 @@ define [
|
|||
@listView?.remove()
|
||||
@parentListView = @listView = null
|
||||
@dialog.option "close", null
|
||||
@closeTarget?.focus()
|
||||
|
||||
#lookup new collection, and set it on
|
||||
#the nested view
|
||||
|
|
|
@ -120,6 +120,7 @@ define [
|
|||
model: @model
|
||||
@moveGroupView = new MoveDialogView
|
||||
model: @model
|
||||
closeTarget: @$el.find('a[id*=manage_link]')
|
||||
saveURL: -> ENV.URLS.sort_url
|
||||
|
||||
initCache: ->
|
||||
|
|
|
@ -76,6 +76,7 @@ define [
|
|||
parentLabelText: @messages.ag_move_label
|
||||
parentKey: 'assignment_group_id'
|
||||
childKey: 'assignments'
|
||||
closeTarget: @$el.find('a[id*=manage_link]')
|
||||
saveURL: -> "#{ENV.URLS.assignment_sort_base_url}/#{@parentListView.value()}/reorder"
|
||||
|
||||
@dateDueColumnView = new DateDueColumnView(model: @model)
|
||||
|
@ -158,7 +159,14 @@ define [
|
|||
|
||||
onDelete: (e) =>
|
||||
e.preventDefault()
|
||||
@delete() if confirm(@messages.confirm)
|
||||
return @$el.find('a[id*=manage_link]').focus() unless confirm(@messages.confirm)
|
||||
if @previousAssignmentInGroup()?
|
||||
@focusOnAssignment(@previousAssignmentInGroup())
|
||||
@delete()
|
||||
else
|
||||
id = @model.attributes.assignment_group_id
|
||||
@delete()
|
||||
@focusOnGroupByID(id)
|
||||
|
||||
delete: ->
|
||||
@model.destroy()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div class="discussion-content">
|
||||
<div class="discussion-content" id="{{id}}_discussion_content">
|
||||
<div class="discussion-row{{#if ENV.permissions.publish}} {{#if published}}discussion-published{{else}}discussion-unpublished{{/if}}{{/if}}">
|
||||
{{#if permissions.moderate}}
|
||||
<div class="draggable-handle">
|
||||
|
@ -85,7 +85,7 @@
|
|||
|
||||
<div class="discussion-actions" role="application">
|
||||
{{#if permissions.delete}}
|
||||
<a href="#" class="al-trigger" role="button">
|
||||
<a href="#" class="al-trigger" role="button" id="manage_link">
|
||||
<i class="icon-settings"></i><i class="icon-mini-arrow-down"></i>
|
||||
<span class="screenreader-only">{{#t "manage"}}Manage{{/t}}</span>
|
||||
</a>
|
||||
|
|
|
@ -169,6 +169,7 @@ define [
|
|||
test 'asks for confirmation before deleting an assignment', ->
|
||||
view = createView(@model)
|
||||
|
||||
group_stub = sinon.stub(view, 'visibleAssignments', -> [])
|
||||
confirm_stub = sinon.stub(window, "confirm", -> true )
|
||||
delete_spy = sinon.spy view, "delete"
|
||||
|
||||
|
@ -179,6 +180,7 @@ define [
|
|||
|
||||
confirm_stub.restore()
|
||||
delete_spy.restore()
|
||||
group_stub.restore()
|
||||
|
||||
test "delete destroys model", ->
|
||||
old_asset_string = ENV.context_asset_string
|
||||
|
@ -277,6 +279,7 @@ define [
|
|||
@server.respond()
|
||||
|
||||
equal @model.get('published'), true
|
||||
@server.restore()
|
||||
|
||||
test "correctly displays module's name", ->
|
||||
mods = genModules(1)
|
||||
|
|
|
@ -120,6 +120,7 @@ define [
|
|||
|
||||
teardown: ->
|
||||
view.remove()
|
||||
server.restore()
|
||||
|
||||
test 'AddAppView: render', ->
|
||||
equal $.trim($('.ui-dialog-title:visible').text()), "Add App",
|
||||
|
|
Loading…
Reference in New Issue