mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-09 06:04:46 +08:00
Merge pull request #7069 from G-Chubinidze/gc_SCI_101000
Implement sorting on all columns of tables revamped in v.1 [SCI-10100]
This commit is contained in:
commit
9666dd994f
9 changed files with 66 additions and 12 deletions
|
@ -128,7 +128,7 @@ export default {
|
|||
{
|
||||
field: 'updated_at',
|
||||
headerName: this.i18n.t('experiments.card.modified_date'),
|
||||
sortable: false
|
||||
sortable: true
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -144,13 +144,13 @@ export default {
|
|||
field: 'total_tasks',
|
||||
headerName: this.i18n.t('experiments.card.completed_task'),
|
||||
cellRenderer: CompletedTasksRenderer,
|
||||
sortable: false,
|
||||
sortable: true,
|
||||
minWidth: 120
|
||||
});
|
||||
columns.push({
|
||||
field: 'description',
|
||||
headerName: this.i18n.t('experiments.card.description'),
|
||||
sortable: false,
|
||||
sortable: true,
|
||||
cellStyle: { 'white-space': 'normal' },
|
||||
cellRenderer: DescriptionRenderer,
|
||||
autoHeight: true
|
||||
|
|
|
@ -126,18 +126,18 @@ export default {
|
|||
{
|
||||
field: 'results',
|
||||
headerName: this.i18n.t('experiments.table.column.results_html'),
|
||||
sortable: false,
|
||||
sortable: true,
|
||||
cellRenderer: this.resultsRenderer
|
||||
},
|
||||
{
|
||||
field: 'age',
|
||||
headerName: this.i18n.t('experiments.table.column.age_html'),
|
||||
sortable: false
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
headerName: this.i18n.t('experiments.table.column.status_html'),
|
||||
sortable: false,
|
||||
sortable: true,
|
||||
cellRenderer: this.statusRenderer
|
||||
}
|
||||
];
|
||||
|
@ -153,14 +153,14 @@ export default {
|
|||
columns.push({
|
||||
field: 'designated',
|
||||
headerName: this.i18n.t('experiments.table.column.assigned_html'),
|
||||
sortable: false,
|
||||
sortable: true,
|
||||
cellRenderer: DesignatedUsers,
|
||||
minWidth: 220
|
||||
});
|
||||
columns.push({
|
||||
field: 'tags',
|
||||
headerName: this.i18n.t('experiments.table.column.tags_html'),
|
||||
sortable: false,
|
||||
sortable: true,
|
||||
cellRenderer: TagsRenderer
|
||||
});
|
||||
columns.push({
|
||||
|
|
|
@ -128,6 +128,11 @@ export default {
|
|||
notSelectable: true,
|
||||
cellRenderer: this.nameRenderer
|
||||
},
|
||||
{
|
||||
field: 'code',
|
||||
headerName: this.i18n.t('libraries.index.table.id'),
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
field: 'nr_of_rows',
|
||||
headerName: this.i18n.t('libraries.index.table.number_of_items'),
|
||||
|
|
|
@ -5,7 +5,7 @@ module Lists
|
|||
include Canaid::Helpers::PermissionsHelper
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
attributes :name, :nr_of_rows, :shared, :shared_label, :ishared,
|
||||
attributes :name, :code, :nr_of_rows, :shared, :shared_label, :ishared,
|
||||
:team, :created_at, :created_by, :archived_on, :archived_by,
|
||||
:urls, :shared_read, :shared_write, :shareable_write
|
||||
|
||||
|
|
|
@ -75,7 +75,10 @@ module Lists
|
|||
created_at: 'experiments.created_at',
|
||||
name: 'experiments.name',
|
||||
code: 'experiments.id',
|
||||
archived_on: 'COALESCE(experiments.archived_on, projects.archived_on)'
|
||||
archived_on: 'COALESCE(experiments.archived_on, projects.archived_on)',
|
||||
updated_at: 'experiments.updated_at',
|
||||
total_tasks: 'task_count',
|
||||
description: 'experiments.description'
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -44,7 +44,13 @@ module Lists
|
|||
due_date: 'due_date',
|
||||
name: 'name',
|
||||
id: 'id',
|
||||
archived_on: 'archived_on'
|
||||
archived_on: 'archived_on',
|
||||
age: 'age',
|
||||
status: 'status',
|
||||
designated: 'designated',
|
||||
results: 'results',
|
||||
tags: 'tags',
|
||||
signatures: 'signatures'
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -70,6 +76,40 @@ module Lists
|
|||
@records = @records.order(Arel.sql('COALESCE(my_modules.archived_on, my_modules.archived_on) ASC'))
|
||||
when 'archived_on_DESC'
|
||||
@records = @records.order(Arel.sql('COALESCE(my_modules.archived_on, my_modules.archived_on) DESC'))
|
||||
when 'age_ASC'
|
||||
@records = @records.order(:created_at)
|
||||
when 'age_DESC'
|
||||
@records = @records.order(created_at: :desc)
|
||||
when 'status_ASC'
|
||||
@records = @records.order(:my_module_status_id)
|
||||
when 'status_DESC'
|
||||
@records = @records.order(my_module_status_id: :desc)
|
||||
when 'designated_ASC'
|
||||
@records = @records.left_joins(:user_my_modules)
|
||||
.group('my_modules.id')
|
||||
.order(Arel.sql('COUNT(DISTINCT user_my_modules.id) ASC'))
|
||||
when 'designated_DESC'
|
||||
@records = @records.left_joins(:user_my_modules)
|
||||
.group('my_modules.id')
|
||||
.order(Arel.sql('COUNT(DISTINCT user_my_modules.id) DESC'))
|
||||
when 'results_ASC'
|
||||
@records = @records.left_joins(:results)
|
||||
.group('my_modules.id')
|
||||
.order(Arel.sql('COUNT(DISTINCT results.id) ASC'))
|
||||
when 'results_DESC'
|
||||
@records = @records.left_joins(:results)
|
||||
.group('my_modules.id')
|
||||
.order(Arel.sql('COUNT(DISTINCT results.id) DESC'))
|
||||
when 'tags_ASC'
|
||||
@records = @records.left_joins(:tags)
|
||||
.group('my_modules.id')
|
||||
.order(Arel.sql('COUNT(DISTINCT tags.id) ASC'))
|
||||
when 'tags_DESC'
|
||||
@records = @records.left_joins(:tags)
|
||||
.group('my_modules.id')
|
||||
.order(Arel.sql('COUNT(DISTINCT tags.id) DESC'))
|
||||
else
|
||||
__send__("#{sortable_columns[order_params[:column].to_sym]}_sort", sort_direction(order_params))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -115,6 +115,10 @@ module Lists
|
|||
@records = @records.sort_by(&:archived_on)
|
||||
when 'archived_on_DESC'
|
||||
@records = @records.sort_by(&:archived_on).reverse!
|
||||
when 'users_ASC'
|
||||
@records = @records.sort_by { |project| project.users.count }
|
||||
when 'users_DESC'
|
||||
@records = @records.sort_by { |project| project.users.count }.reverse!
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -50,7 +50,8 @@ module Lists
|
|||
created_at: 'repositories.created_at',
|
||||
archived_on: 'repositories.archived_on',
|
||||
archived_by: 'archived_by_user',
|
||||
nr_of_rows: 'row_count'
|
||||
nr_of_rows: 'row_count',
|
||||
code: 'repositories.id'
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2539,6 +2539,7 @@ en:
|
|||
head_title_archived: "Archived Inventories"
|
||||
table:
|
||||
name: "Inventory name"
|
||||
id: "ID"
|
||||
number_of_items: "No. of items"
|
||||
shared: "Shared"
|
||||
ownership: "Owned by"
|
||||
|
|
Loading…
Reference in a new issue