Add sorting to task comments

This commit is contained in:
Anton 2024-05-09 12:08:33 +02:00
parent 74ce54f832
commit b3e4b14800
2 changed files with 11 additions and 2 deletions

View file

@ -174,7 +174,7 @@ export default {
columns.push({
field: 'comments',
headerName: this.i18n.t('experiments.table.column.comments_html'),
sortable: false,
sortable: true,
cellRenderer: CommentsRenderer,
notSelectable: true
});

View file

@ -49,7 +49,8 @@ module Lists
designated: 'designated',
results: 'results',
tags: 'tags',
signatures: 'signatures'
signatures: 'signatures',
comments: 'comments'
}
end
@ -83,6 +84,14 @@ module Lists
@records = @records.order(:my_module_status_id)
when 'status_DESC'
@records = @records.order(my_module_status_id: :desc)
when 'comments_ASC'
@records = @records.left_joins(:task_comments)
.group('my_modules.id')
.order(Arel.sql('COUNT(DISTINCT comments.id) ASC'))
when 'comments_DESC'
@records = @records.left_joins(:task_comments)
.group('my_modules.id')
.order(Arel.sql('COUNT(DISTINCT comments.id) DESC'))
when 'designated_ASC'
@records = @records.left_joins(:user_my_modules)
.group('my_modules.id')