tech: use facet_id to sort fields
This commit is contained in:
parent
743ff8c8a9
commit
b6464c1963
10 changed files with 38 additions and 18 deletions
|
@ -15,6 +15,8 @@ module FacetsConcern
|
|||
end
|
||||
|
||||
def dossier_facets
|
||||
common = [Facet.new(table: 'self', column: 'id', classname: 'number-col'), Facet.new(table: 'notifications', column: 'notifications', label: "notifications", filterable: false)]
|
||||
|
||||
dates = ['created_at', 'updated_at', 'depose_at', 'en_construction_at', 'en_instruction_at', 'processed_at']
|
||||
.map { |column| Facet.new(table: 'self', column:, type: :date) }
|
||||
|
||||
|
@ -23,7 +25,7 @@ module FacetsConcern
|
|||
|
||||
states = [Facet.new(table: 'self', column: 'state', type: :enum, scope: 'instructeurs.dossiers.filterable_state', virtual: true)]
|
||||
|
||||
[dates, sva_svr_facets(for_filters: true), virtual_dates, states].flatten.compact
|
||||
[common, dates, sva_svr_facets(for_filters: true), virtual_dates, states].flatten.compact
|
||||
end
|
||||
|
||||
def sva_svr_facets(for_filters: false)
|
||||
|
|
|
@ -124,11 +124,13 @@ class ProcedurePresentation < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def update_sort(table, column, order)
|
||||
def update_sort(facet_id, order)
|
||||
facet = procedure.find_facet(id: facet_id)
|
||||
|
||||
update!(sort: {
|
||||
TABLE => table,
|
||||
COLUMN => column,
|
||||
ORDER => order.presence || opposite_order_for(table, column)
|
||||
TABLE => facet.table,
|
||||
COLUMN => facet.column,
|
||||
ORDER => order.presence || opposite_order_for(facet.table, facet.column)
|
||||
})
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue