add aria-sort on sortable column
This commit is contained in:
parent
6b1ecde852
commit
9065e57e62
2 changed files with 19 additions and 2 deletions
|
@ -340,6 +340,22 @@ class ProcedurePresentation < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def sortable?(field)
|
||||
sort['table'] == field['table'] && sort['column'] == field['column']
|
||||
end
|
||||
|
||||
def aria_sort(order, field)
|
||||
if sortable?(field)
|
||||
if order == 'asc'
|
||||
{ "aria-sort": "ascending" }
|
||||
elsif order == 'desc'
|
||||
{ "aria-sort": "descending" }
|
||||
end
|
||||
else
|
||||
{}
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def field_id(field)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
%th{ class: classname }
|
||||
%th{ @procedure_presentation.aria_sort(@procedure_presentation.sort['order'], field), class: classname }
|
||||
|
||||
= link_to update_sort_instructeur_procedure_path(@procedure, table: field['table'], column: field['column'], order: @procedure_presentation.opposite_order_for(field['table'], field['column'])) do
|
||||
- if @procedure_presentation.sort['table'] == field['table'] && @procedure_presentation.sort['column'] == field['column']
|
||||
- if @procedure_presentation.sortable?(field)
|
||||
- if @procedure_presentation.sort['order'] == 'asc'
|
||||
#{field['label']} ↑
|
||||
- else
|
||||
|
|
Loading…
Add table
Reference in a new issue