Merge pull request #4683 from G-Chubinidze/gc_SCI_7199

fixed id sorting on reports removed model duplicate code [SCI-7199]
This commit is contained in:
G-Chubinidze 2022-12-05 13:22:52 +04:00 committed by GitHub
commit bc43b3af98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 11 deletions

View file

@ -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)

View file

@ -2,9 +2,9 @@
class MyModule < ApplicationRecord
ID_PREFIX = 'TA'
include PrefixedIdModel
SEARCHABLE_ATTRIBUTES = ['my_modules.name', 'my_modules.description', PREFIXED_ID_SQL].freeze
include PrefixedIdModel
include ArchivableModel
include SearchableModel
include SearchableByNameModel

View file

@ -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

View file

@ -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

View file

@ -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 }