Disable sorttable on tables without rows

Otherwise, the first element of the table body is being fetched which might result in an error for empty tables.

Fixes CODEOCEAN-JZ
This commit is contained in:
Sebastian Serth
2023-03-14 18:27:38 +01:00
parent 1c5eb09138
commit a99da79550
11 changed files with 12 additions and 12 deletions

View File

@ -1,7 +1,7 @@
h1 = ErrorTemplateAttribute.model_name.human(count: 2)
.table-responsive
table.sortable.table
table.table class="#{@error_template_attributes.present? ? 'sortable' : ''}"
thead
tr
th

View File

@ -1,7 +1,7 @@
h1 = ErrorTemplate.model_name.human(count: 2)
.table-responsive
table.sortable.table
table.table class="#{@error_templates.present? ? 'sortable' : ''}"
thead
tr
th = t('activerecord.attributes.error_template.name')

View File

@ -13,7 +13,7 @@ h2.mt-4
= t 'error_templates.attributes'
.table-responsive
table.sortable.table
table.table class="#{@error_templates.error_template_attributes.present? ? 'sortable' : ''}"
thead
tr
th

View File

@ -1,7 +1,7 @@
h1 = @execution_environment
.table-responsive
table.table.table-striped.sortable
table.table.table-striped class="#{@execution_environment.present? ? 'sortable' : ''}"
thead
tr
- ['.exercise', '.users', '.score', '.maximum_score', '.stddev_score', '.percentage_correct', '.runs', '.worktime', '.stddev_worktime'].each do |title|

View File

@ -28,7 +28,7 @@ h1 = @exercise_collection
h4.mt-4 = t('activerecord.attributes.exercise_collections.exercises')
.table-responsive#exercise-list
table.table.sortable
table.table class="#{@exercise_collection.items.present? ? 'sortable' : ''}"
thead
tr
th = '#'

View File

@ -61,8 +61,9 @@ h1 = @exercise
- if !policy(@exercise).detailed_statistics?
- submissions = submissions.final
- if submissions.any?
- users = symbol.to_s.classify.constantize.where(id: submissions.joins(symbol).group(:user_id).select(:user_id).distinct)
.table-responsive
table.table.table-striped.sortable
table.table.table-striped class="#{users.present? ? 'sortable' : ''}"
thead
tr
th.header = t('.user')
@ -71,7 +72,6 @@ h1 = @exercise
th.header = t('.runs') if policy(@exercise).detailed_statistics?
th.header = t('.worktime') if policy(@exercise).detailed_statistics?
tbody
- users = symbol.to_s.classify.constantize.where(id: submissions.joins(symbol).group(:user_id).select(:user_id).distinct)
- users.each do |user|
- if user_statistics[user.class.name][user.id] then us = user_statistics[user.class.name][user.id] else us = {"maximum_score" => nil, "runs" => nil}
- label = "#{user.displayname}"

View File

@ -7,7 +7,7 @@ h1 = t('.title')
- if submissions.any?
.table-responsive
table.table.table-striped.sortable
table.table.table-striped class="#{exercises.present? ? 'sortable' : ''}"
thead
tr
th.header = t('.exercise')

View File

@ -17,7 +17,7 @@ h1 = RequestForComment.model_name.human(count: 2)
{ class: 'form-control', multiple: true, "data-placeholder": t('request_for_comments.index.study_groups.placeholder') })
.table-responsive
table.table.sortable.mt-4
table.table.mt-4 class="#{@request_for_comments.present? ? 'sortable' : ''}"
thead
tr
th

View File

@ -6,7 +6,7 @@
h3 = t('activerecord.attributes.study_group.members')
.table-responsive
table.sortable.table
table.table class="#{@members.present? ? 'sortable' : ''}"
thead
tr
th = t('activerecord.attributes.exercise.selection')

View File

@ -12,7 +12,7 @@ h1
h2.mt-4 = t('activerecord.attributes.study_group.members')
.table-responsive
table.sortable.table
table.table class="#{@study_group.users.present? ? 'sortable' : ''}"
thead
tr
th = t('navigation.sections.users')

View File

@ -1,7 +1,7 @@
h1 = Tip.model_name.human(count: 2)
.table-responsive
table.sortable.table
table.table class="#{@tips.present? ? 'sortable' : ''}"
thead
tr
th = t('activerecord.attributes.tip.title')