177 lines
		
	
	
		
			7.6 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			177 lines
		
	
	
		
			7.6 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| - if @badges.size > 0 && false
 | |
|   .row.mb-4
 | |
|     .col
 | |
|       .badges style="margin-top: -18px; position: absolute"
 | |
|         - @badges.each do |badge|
 | |
|           span.badge.text-bg-info.me-2
 | |
|             = badge
 | |
| 
 | |
| javascript:
 | |
|   async function copyExtensionUrlToClipboard() {
 | |
|     await navigator.clipboard.writeText("#{message_url}?token=#{@contest.generate_token_for(:token)}");
 | |
|     alert("#{t("contests.show.url_copied")}");
 | |
|   }
 | |
| 
 | |
| .row.mb-5
 | |
|   .col
 | |
|     - if @contest.public
 | |
|       a.btn.btn-success href="/public/#{@contest.slug}"
 | |
|         = t("contests.show.open_public_scoreboard")
 | |
|     - else
 | |
|       a.btn.btn-success.disabled
 | |
|         = t("contests.show.public_scoreboard_disabled")
 | |
|     - if @contest.offline_form
 | |
|       a.ms-3.btn.btn-success href="/public/#{@contest.slug}/offline"
 | |
|         = t("contests.show.open_offline_form")
 | |
|     - else
 | |
|       a.ms-3.btn.btn-success.disabled
 | |
|         = t("contests.show.offline_form_disabled")
 | |
|     button.btn.btn-success.ms-3 onclick="copyExtensionUrlToClipboard()"
 | |
|       css:
 | |
|         button > svg {
 | |
|           margin-right: 2px;
 | |
|           margin-top: -3px;
 | |
|         }
 | |
|       <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-clipboard" viewBox="0 0 16 16">
 | |
|         <path d="M4 1.5H3a2 2 0 0 0-2 2V14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3.5a2 2 0 0 0-2-2h-1v1h1a1 1 0 0 1 1 1V14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3.5a1 1 0 0 1 1-1h1z"/>
 | |
|         <path d="M9.5 1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5zm-3-1A1.5 1.5 0 0 0 5 1.5v1A1.5 1.5 0 0 0 6.5 4h3A1.5 1.5 0 0 0 11 2.5v-1A1.5 1.5 0 0 0 9.5 0z"/>
 | |
|       </svg>
 | |
|       =< t("contests.show.copy_extension_url")
 | |
|     
 | |
| .row.mb-4 style="height: calc(100vh - 280px)"
 | |
|   .col-6.d-flex.flex-column style="height: 100%"
 | |
|     .row
 | |
|       .col
 | |
|         h4
 | |
|           = t("contestants.plural").capitalize
 | |
|           a.ms-3.btn.btn-sm.btn-primary href=new_contest_contestant_path(@contest) style="margin-top: -3px"
 | |
|             | + #{t("helpers.buttons.add")}
 | |
|           a.ms-2.btn.btn-sm.btn.btn-primary href=contest_import_path(@contest) style="margin-top: -3px"
 | |
|             | #{t("helpers.buttons.import")}
 | |
|           a.ms-2.btn.btn-sm.btn.btn-primary href="/contests/#{@contest.id}/export.csv" style="margin-top: -3px"
 | |
|             | #{t("helpers.buttons.export")}
 | |
|     - if @contest.categories.size > 0
 | |
|       .row
 | |
|         .col
 | |
|           select.mt-2.mb-2 id="categories" style="padding: 5px"
 | |
|             option value=-1
 | |
|               | Tous.tes les participant.e.s
 | |
|             option value=-2
 | |
|               | Participant.e.s sans catégorie
 | |
|             - @contest.categories.each do |category|
 | |
|               option value=category.id
 | |
|                 = category.name
 | |
|           javascript:
 | |
|             categorySelectEl = document.getElementById('categories');
 | |
|             urlParams = new URLSearchParams(window.location.search);
 | |
|             selectedCategory = urlParams.get('category');
 | |
|             Array.from(categorySelectEl.children).forEach((option) => {
 | |
|               if (option.value == selectedCategory) option.selected = true;
 | |
|             });
 | |
|             categorySelectEl.addEventListener('change', (e) => {
 | |
|               window.location.replace(`#{contest_path(@contest)}?category=${e.target.value}`);
 | |
|             })
 | |
|     .d-flex.flex-column style="overflow-y: auto"
 | |
|       table.table.table-striped.table-hover
 | |
|         thead
 | |
|           tr
 | |
|             th
 | |
|               = t("helpers.rank")
 | |
|             th
 | |
|               = t("activerecord.attributes.contestant.name")
 | |
|             th
 | |
|               = t("activerecord.attributes.contestant.completions")
 | |
|             th
 | |
|               = t("activerecord.attributes.contestant.display_time")
 | |
|         tbody
 | |
|           - @contestants.each_with_index do |contestant, index|
 | |
|             tr scope="row"
 | |
|               td
 | |
|                 = index + 1
 | |
|               td
 | |
|                 = contestant.name
 | |
|               td
 | |
|                 = contestant.completions.where(remaining_pieces: nil).length
 | |
|               td
 | |
|                 = contestant.completions.size > 0 && contestant.completions[-1].remaining_pieces ? "#{contestant.completions.map{|completion| completion.puzzle.pieces}.sum - contestant.completions[-1].remaining_pieces}p" : contestant.display_time
 | |
|               td
 | |
|                 a.btn.btn-sm.btn-secondary href=edit_contest_contestant_path(@contest, contestant)
 | |
|                   = t("helpers.buttons.open")
 | |
|   .col-6.d-flex.flex-column style="height: 100%"
 | |
|     .row
 | |
|       .col
 | |
|         h4
 | |
|           = t("puzzles.plural").capitalize
 | |
|           a.ms-3.btn.btn-sm.btn-primary href=new_contest_puzzle_path(@contest) style="margin-top: -3px"
 | |
|             | + #{t("helpers.buttons.add")}
 | |
|     table.table.table-striped.table-hover
 | |
|       thead
 | |
|         tr
 | |
|           th
 | |
|             = t("activerecord.attributes.puzzle.image")
 | |
|           th
 | |
|             = t("activerecord.attributes.puzzle.name")
 | |
|           th
 | |
|             = t("activerecord.attributes.puzzle.brand")
 | |
|           th
 | |
|             = t("activerecord.attributes.puzzle.pieces")
 | |
|       tbody
 | |
|         - @puzzles.each do |puzzle|
 | |
|           tr.align-middle scope="row"
 | |
|             td
 | |
|               = image_tag(puzzle.image, class: "img-fluid", style: "max-height: 48px;") if puzzle.image.attached?
 | |
|             td
 | |
|               = puzzle.name
 | |
|             td
 | |
|               = puzzle.brand
 | |
|             td
 | |
|               = puzzle.pieces
 | |
|             td
 | |
|               a.btn.btn-sm.btn-secondary href=edit_contest_puzzle_path(@contest, puzzle)
 | |
|                 = t("helpers.buttons.edit")
 | |
|     - if @messages
 | |
|       .row.mt-5
 | |
|         .col
 | |
|           h4 = t("messages.plural").capitalize
 | |
|       - if @puzzles.size == 0
 | |
|         .row
 | |
|           .col.alert.alert-danger
 | |
|             = t("messages.warning")
 | |
|       .d-flex.flex-column style="overflow-y: auto"
 | |
|         table.table.table-striped.table-hover
 | |
|           thead
 | |
|             tr
 | |
|               th scope="col" style="white-space: nowrap"
 | |
|                 = t("activerecord.attributes.message.processed")
 | |
|               th scope="col"
 | |
|                 = t("activerecord.attributes.message.time")
 | |
|               th scope="col"
 | |
|                 = t("activerecord.attributes.message.author")
 | |
|               th.w-25 scope="col"
 | |
|                 = t("activerecord.attributes.message.text")
 | |
|               th.w-25 scope="col"
 | |
|           tbody
 | |
|             - @messages.each do |message|
 | |
|               tr.align-middle scope="row"
 | |
|                 td style="text-align: center"
 | |
|                   - if message.completions.size > 0
 | |
|                     <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-check-square" viewBox="0 0 16 16">
 | |
|                       <path d="M14 1a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1zM2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2z"/>
 | |
|                       <path d="M10.97 4.97a.75.75 0 0 1 1.071 1.05l-3.992 4.99a.75.75 0 0 1-1.08.02L4.324 8.384a.75.75 0 1 1 1.06-1.06l2.094 2.093 3.473-4.425z"/>
 | |
|                     </svg>
 | |
|                 td
 | |
|                   = message.display_time
 | |
|                 td
 | |
|                   = message.author
 | |
|                 td
 | |
|                   = message.text
 | |
|                 td
 | |
|                   .d-inline-flex
 | |
|                     - if @puzzles.size > 0
 | |
|                       a.btn.btn-sm.btn-secondary href=contest_message_convert_path(@contest, message) style="white-space: nowrap;"
 | |
|                         = t("helpers.buttons.add_completion")
 | |
|                     - else
 | |
|                       a.btn.btn-sm.btn-secondary.disabled href=contest_message_convert_path(@contest, message) style="white-space: nowrap;"
 | |
|                         = t("helpers.buttons.add_completion")
 | |
|                     = link_to "x", contest_message_path(@contest, message), data: { turbo_method: :delete }, class: "btn btn-sm btn-danger ms-2"
 |