screenreaders announce item count after search
fixes CNVS-21510 test plan: - with screenreader on - go to quizzes index - filter by title in the search box - the screenreader announces the new item count - go to assignment index - do the same Change-Id: I172e84cbf9fd3f0de49f6faf76d7336eb622d2c8 Reviewed-on: https://gerrit.instructure.com/69858 Tested-by: Jenkins Reviewed-by: Matt Berns <mberns@instructure.com> QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com> Product-Review: Aaron Cannon <acannon@instructure.com>
This commit is contained in:
parent
772cffbae6
commit
7539016828
|
@ -207,17 +207,19 @@ define [
|
|||
|
||||
search: (regex, gradingPeriod) ->
|
||||
@resetBorders()
|
||||
assignmentCount = @collection.reduce( (count, as) =>
|
||||
count++ if as.search(regex, gradingPeriod)
|
||||
count
|
||||
, 0)
|
||||
|
||||
atleastone = false
|
||||
@collection.each (as) =>
|
||||
atleastone = true if as.search(regex, gradingPeriod)
|
||||
atleastone = assignmentCount > 0
|
||||
if atleastone
|
||||
@show()
|
||||
@expand(false)
|
||||
@borderFix()
|
||||
else
|
||||
@hide()
|
||||
atleastone
|
||||
assignmentCount
|
||||
|
||||
endSearch: ->
|
||||
@resetBorders()
|
||||
|
|
|
@ -9,6 +9,7 @@ define [
|
|||
'jst/assignments/NoAssignmentsSearch'
|
||||
'compiled/views/assignments/AssignmentKeyBindingsMixin'
|
||||
'compiled/userSettings'
|
||||
'compiled/jquery.rails_flash_notifications'
|
||||
], (I18n, KeyboardNavDialog, keyboardNavTemplate, $, _, Backbone, template, NoAssignments, AssignmentKeyBindingsMixin, userSettings) ->
|
||||
|
||||
class IndexView extends Backbone.View
|
||||
|
@ -90,9 +91,13 @@ define [
|
|||
else
|
||||
regex = new RegExp(@cleanSearchTerm(term), 'ig')
|
||||
#search
|
||||
atleastoneGroup = false
|
||||
@collection.each (group) =>
|
||||
atleastoneGroup = true if group.groupView.search(regex, gradingPeriod)
|
||||
matchingAssignmentCount = @collection.reduce( (runningTotal, group) ->
|
||||
additionalCount = group.groupView.search(regex, gradingPeriod)
|
||||
runningTotal + additionalCount
|
||||
, 0)
|
||||
|
||||
atleastoneGroup = matchingAssignmentCount > 0
|
||||
@alertForMatchingGroups(matchingAssignmentCount)
|
||||
|
||||
#add noAssignments placeholder
|
||||
if !atleastoneGroup
|
||||
|
@ -109,6 +114,15 @@ define [
|
|||
@noAssignments.remove()
|
||||
@noAssignments = null
|
||||
|
||||
alertForMatchingGroups: (numAssignments) ->
|
||||
msg = I18n.t({
|
||||
one: "1 assignment found."
|
||||
other: "%{count} assignments found."
|
||||
zero: "No matching assignments found."
|
||||
}, count: numAssignments
|
||||
)
|
||||
$.screenReaderFlashMessageExclusive(msg)
|
||||
|
||||
cleanSearchTerm: (text) ->
|
||||
text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&")
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
define [
|
||||
'i18n!quizzes'
|
||||
'jquery'
|
||||
'underscore'
|
||||
'Backbone'
|
||||
'compiled/views/quizzes/QuizItemGroupView'
|
||||
'jst/quizzes/IndexView'
|
||||
], ($, _, Backbone, QuizItemGroupView, template) ->
|
||||
'compiled/jquery.rails_flash_notifications'
|
||||
], (I18n, $, _, Backbone, QuizItemGroupView, template) ->
|
||||
|
||||
class IndexView extends Backbone.View
|
||||
template: template
|
||||
|
@ -37,8 +39,27 @@ define [
|
|||
|
||||
keyUpSearch: _.debounce ->
|
||||
@filterResults()
|
||||
@announceCount()
|
||||
, 200
|
||||
|
||||
filterResults: =>
|
||||
_.each @views(), (view) =>
|
||||
view.filterResults($('#searchTerm').val())
|
||||
|
||||
announceCount: =>
|
||||
searchTerm = $('#searchTerm').val()
|
||||
return if searchTerm == '' || searchTerm == null
|
||||
|
||||
matchingQuizCount = _.reduce(@views(), (runningCount, view) =>
|
||||
return runningCount + view.matchingCount(searchTerm)
|
||||
, 0)
|
||||
@announceMatchingQuizzes(matchingQuizCount)
|
||||
|
||||
announceMatchingQuizzes: (numQuizzes) ->
|
||||
msg = I18n.t({
|
||||
one: "1 quiz found."
|
||||
other: "%{count} quizzes found."
|
||||
zero: "No matching quizzes found."
|
||||
}, count: numQuizzes
|
||||
)
|
||||
$.screenReaderFlashMessageExclusive(msg)
|
||||
|
|
|
@ -32,9 +32,13 @@ define [
|
|||
if !!model.get('hidden') != hidden
|
||||
anyChanged = true
|
||||
model.set('hidden', hidden)
|
||||
|
||||
@render() if anyChanged
|
||||
|
||||
matchingCount: (term) =>
|
||||
_.select( @collection.models, (m) =>
|
||||
@filter(m, term)
|
||||
).length
|
||||
|
||||
filter: (model, term) =>
|
||||
return true unless term
|
||||
|
||||
|
|
Loading…
Reference in New Issue