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
|
2024-08-27 10:29:10 +02:00
|
|
|
@row_id = @champ.add_row(updated_by: current_user.email)
|
|
|
|
@first_champ_id = @champ.focusable_input_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-08-27 10:29:10 +02:00
|
|
|
@champ.remove_row(params[:row_id], updated_by: current_user.email)
|
2024-04-15 15:06:05 +02:00
|
|
|
@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
|