2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2024-04-15 15:06:05 +02:00
|
|
|
class Champs::RepetitionController < Champs::ChampController
|
2022-05-03 16:40:09 +02:00
|
|
|
def add
|
2023-11-28 17:33:29 +01:00
|
|
|
row = @champ.add_row(@champ.dossier.revision)
|
|
|
|
@first_champ_id = row.map(&:focusable_input_id).compact.first
|
|
|
|
@row_id = row.first&.row_id
|
2024-04-15 13:15:18 +02:00
|
|
|
@row_number = @row_id.nil? ? 0 : @champ.row_ids.find_index(@row_id) + 1
|
2019-01-30 16:14:15 +01:00
|
|
|
end
|
2022-05-03 16:40:09 +02:00
|
|
|
|
|
|
|
def remove
|
2024-04-15 15:06:05 +02:00
|
|
|
@champ.remove_row(params[:row_id])
|
|
|
|
@to_remove = "safe-row-selector-#{params[:row_id]}"
|
|
|
|
@to_focus = @champ.focusable_input_id || helpers.dom_id(@champ, :create_repetition)
|
2022-05-03 16:40:09 +02:00
|
|
|
end
|
2024-03-14 15:13:13 +01:00
|
|
|
|
|
|
|
private
|
|
|
|
|
2024-04-15 15:06:05 +02:00
|
|
|
def params_row_id
|
|
|
|
nil
|
2024-03-14 15:13:13 +01:00
|
|
|
end
|
2019-01-30 16:14:15 +01:00
|
|
|
end
|