This way the fields are easier to use, and we can get rid of the placeholders. Note we're simplifying the `answer_result_value` in order to make it easier to return `0` instead of `nil` when the field is empty. Also note there's a small change of behavior here; previously, these fields were empty by default, and now their value is `0` by default, so blindly clicking the "Save" button would send `0` instead of an empty value. I don't think it's a big deal, though, but we need to keep that in mind.
16 lines
418 B
Ruby
16 lines
418 B
Ruby
class Officing::Results::FormComponent < ApplicationComponent
|
|
attr_reader :poll, :officer_assignments
|
|
use_helpers :booths_for_officer_select_options
|
|
|
|
def initialize(poll, officer_assignments)
|
|
@poll = poll
|
|
@officer_assignments = officer_assignments
|
|
end
|
|
|
|
private
|
|
|
|
def answer_result_value(question_id, option_index)
|
|
params.dig(:questions, question_id.to_s, option_index.to_s).to_i
|
|
end
|
|
end
|