other option for groupe instructeurs injection
This commit is contained in:
parent
08fb49d176
commit
1424fca469
5 changed files with 37 additions and 29 deletions
|
@ -17,6 +17,11 @@ module Instructeurs
|
|||
def refresh_column_filter
|
||||
# According to the html, the selected filters is the last one
|
||||
column = ColumnType.new.cast(params['filters'].last['id'])
|
||||
|
||||
if column.groupe_instructeur?
|
||||
column.options_for_select = instructeur_groupes(procedure_id: column.h_id[:procedure_id])
|
||||
end
|
||||
|
||||
component = Instructeurs::ColumnFilterValueComponent.new(column:)
|
||||
|
||||
render turbo_stream: turbo_stream.replace('value', component)
|
||||
|
@ -48,5 +53,10 @@ module Instructeurs
|
|||
.includes(:assign_to)
|
||||
.find_by!(id: params[:id], assign_to: { instructeur: current_instructeur })
|
||||
end
|
||||
|
||||
def instructeur_groupes(procedure_id:)
|
||||
current_instructeur.groupe_instructeurs
|
||||
.filter_map { [_1.label, _1.id] if _1.procedure_id == procedure_id }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,7 +8,8 @@ class Column
|
|||
|
||||
TYPE_DE_CHAMP_TABLE = 'type_de_champ'
|
||||
|
||||
attr_reader :table, :column, :label, :type, :filterable, :displayable, :options_for_select
|
||||
attr_reader :table, :column, :label, :type, :filterable, :displayable
|
||||
attr_accessor :options_for_select
|
||||
|
||||
def initialize(procedure_id:, table:, column:, label: nil, type: :text, filterable: true, displayable: true, options_for_select: [])
|
||||
@procedure_id = procedure_id
|
||||
|
|
|
@ -83,12 +83,7 @@ module ColumnsConcern
|
|||
|
||||
private
|
||||
|
||||
def groupe_instructeurs_id_column
|
||||
groupes = Current.user&.instructeur&.groupe_instructeurs || []
|
||||
options_for_select = groupes.filter_map { [_1.label, _1.id] if _1.procedure_id == id }
|
||||
|
||||
dossier_col(table: 'groupe_instructeur', column: 'id', type: :enum, options_for_select:)
|
||||
end
|
||||
def groupe_instructeurs_id_column = dossier_col(table: 'groupe_instructeur', column: 'id', type: :enum)
|
||||
|
||||
def followers_instructeurs_email_column = dossier_col(table: 'followers_instructeurs', column: 'email')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue