diff --git a/app/datatables/report_datatable.rb b/app/datatables/report_datatable.rb index d5e36c121..c4ef21891 100644 --- a/app/datatables/report_datatable.rb +++ b/app/datatables/report_datatable.rb @@ -41,6 +41,9 @@ class ReportDatatable < CustomDatatable records.left_joins(:pdf_file_attachment) .order(active_storage_attachments: sort_direction(order_params)) .order(pdf_file_status: sort_direction(order_params) == 'ASC' ? :desc : :asc) + when 'reports.code' + sort_by = "reports.id #{sort_direction(order_params)}" + records.order(sort_by) else sort_by = "#{sort_column(order_params)} #{sort_direction(order_params)}" records.order(sort_by) diff --git a/app/models/my_module.rb b/app/models/my_module.rb index 94e2f3540..8c9923409 100644 --- a/app/models/my_module.rb +++ b/app/models/my_module.rb @@ -2,9 +2,9 @@ class MyModule < ApplicationRecord ID_PREFIX = 'TA' - SEARCHABLE_ATTRIBUTES = ['my_modules.name', 'my_modules.description', PREFIXED_ID_SQL].freeze - include PrefixedIdModel + SEARCHABLE_ATTRIBUTES = ['my_modules.name', 'my_modules.description', PREFIXED_ID_SQL].freeze + include ArchivableModel include SearchableModel include SearchableByNameModel diff --git a/app/models/project.rb b/app/models/project.rb index 8a3915557..f321cc1b8 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -2,9 +2,9 @@ class Project < ApplicationRecord ID_PREFIX = 'PR' + include PrefixedIdModel SEARCHABLE_ATTRIBUTES = ['projects.name', PREFIXED_ID_SQL].freeze - include PrefixedIdModel include ArchivableModel include SearchableModel include SearchableByNameModel @@ -12,9 +12,6 @@ class Project < ApplicationRecord include PermissionCheckableModel include Assignable - ID_PREFIX = 'PR' - include PrefixedIdModel - enum visibility: { hidden: 0, visible: 1 } auto_strip_attributes :name, nullify: false diff --git a/app/models/protocol.rb b/app/models/protocol.rb index cfc8ce356..812cbf835 100644 --- a/app/models/protocol.rb +++ b/app/models/protocol.rb @@ -2,10 +2,10 @@ class Protocol < ApplicationRecord ID_PREFIX = 'PT' + include PrefixedIdModel SEARCHABLE_ATTRIBUTES = ['protocols.name', 'protocols.description', 'protocols.authors', 'protocol_keywords.name', PREFIXED_ID_SQL].freeze - include PrefixedIdModel include SearchableModel include RenamingUtil include SearchableByNameModel diff --git a/app/models/report.rb b/app/models/report.rb index 449d12cf8..c822b3dee 100644 --- a/app/models/report.rb +++ b/app/models/report.rb @@ -2,18 +2,15 @@ class Report < ApplicationRecord ID_PREFIX = 'RP' + include PrefixedIdModel SEARCHABLE_ATTRIBUTES = ['reports.name', 'reports.description', PREFIXED_ID_SQL].freeze - include PrefixedIdModel include SettingsModel include Assignable include PermissionCheckableModel include SearchableModel include SearchableByNameModel - ID_PREFIX = 'RP' - include PrefixedIdModel - enum pdf_file_status: { pdf_empty: 0, pdf_processing: 1, pdf_ready: 2, pdf_error: 3 } enum docx_file_status: { docx_empty: 0, docx_processing: 1, docx_ready: 2, docx_error: 3 }