48 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			48 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| = form_with model: completion, url: url, method: method do |form|
 | |
|   - if @message
 | |
|     = form.hidden_field :message_id, value: @message.id
 | |
|     .row.mb-3
 | |
|       .col
 | |
|         h4 = t("messages.singular").capitalize
 | |
|         .alert.alert-secondary
 | |
|           b
 | |
|             = @message.author
 | |
|           br
 | |
|           = @message.text
 | |
|   .row
 | |
|     .col
 | |
|       h4 = t("completions.singular").capitalize
 | |
|   .row.mb-3
 | |
|     .col
 | |
|       .form-floating
 | |
|         = form.select :contestant_id, @contestants.map { |contestant| [contestant.form_name, contestant.id] }, {}, class: "form-select"
 | |
|         = form.label :contestant_id
 | |
|   - if @closest_contestant
 | |
|     javascript:
 | |
|       el = document.querySelector('select[name="completion[contestant_id]"]');
 | |
|       el.value = "#{@closest_contestant.id}"
 | |
|   - if @puzzles.size > 1
 | |
|     .row.mb-3
 | |
|       .col
 | |
|         .form-floating
 | |
|           = form.select :puzzle_id, @puzzles.map { |puzzle| ["#{puzzle.name} - #{puzzle.brand}", puzzle.id] }, {}, class: "form-select"
 | |
|           = form.label :puzzle_id
 | |
|   - elsif @puzzles.size == 1
 | |
|     = form.hidden_field :puzzle_id, value: @puzzles.first.id
 | |
|   - else
 | |
|     = form.hidden_field :puzzle_id
 | |
|   .row.mb-3
 | |
|     .col
 | |
|       .form-floating
 | |
|         = form.text_field :display_time_from_start, autocomplete: "off", class: "form-control"
 | |
|         = form.label :display_time_from_start, class: "required"
 | |
|   .row.mb-3
 | |
|     .col
 | |
|       .form-floating
 | |
|         = form.text_field :remaining_pieces, autocomplete: "off", class: "form-control"
 | |
|         = form.label :remaining_pieces
 | |
|       .form-text
 | |
|         = t("activerecord.attributes.completion.remaining_pieces_description")
 | |
|   .row
 | |
|     .col
 | |
|       = form.submit submit_text, class: "btn btn-primary" |