add cp name to options on stages page
This commit is contained in:
parent
a5b62f30a2
commit
4b4990b123
33
main.js
33
main.js
@ -312,10 +312,10 @@
|
||||
})
|
||||
}
|
||||
|
||||
async function getPointsByNumber(numbers) {
|
||||
async function getPointsByField(field, values) {
|
||||
let params = new URLSearchParams()
|
||||
for (const number of numbers) {
|
||||
params.append("number[]", number)
|
||||
for (const value of values) {
|
||||
params.append(`${field}[]`, value)
|
||||
}
|
||||
let response = await fetch(`https://${adminSite}/api/competitions/${getCompetition()}/points?${params.toString()}`, {
|
||||
method: 'GET'
|
||||
@ -1164,7 +1164,7 @@
|
||||
on: {
|
||||
click: async function () {
|
||||
let number = document.querySelector("#go-to-cp").value
|
||||
let json = await getPointsByNumber([number])
|
||||
let json = await getPointsByField("number", [number])
|
||||
let id = json[number].cp_id
|
||||
|
||||
if (id == null) {
|
||||
@ -2153,7 +2153,7 @@
|
||||
}
|
||||
|
||||
async function getPointsFromRows() {
|
||||
return await getPointsByNumber(Object.values(getPointNumbers()))
|
||||
return await getPointsByField("number", Object.values(getPointNumbers()))
|
||||
}
|
||||
|
||||
function countCp(points) {
|
||||
@ -2210,7 +2210,7 @@
|
||||
fullNeedHistoryCount++
|
||||
stageNeedHistoryCount++
|
||||
}
|
||||
|
||||
|
||||
if (point.history_ru) {
|
||||
fullHistoryCount++
|
||||
stageHistoryCount++
|
||||
@ -2469,6 +2469,26 @@
|
||||
addStylesToHead(styles)
|
||||
}
|
||||
|
||||
function addCpNameToOptions() {
|
||||
let options = [...document.querySelectorAll(`option`)]
|
||||
let cpIds = [...new Set(
|
||||
options
|
||||
.map($option => $option.value)
|
||||
.filter($value => $value != null)
|
||||
)
|
||||
]
|
||||
|
||||
;(async () => {
|
||||
let points = await getPointsByField("cp_id", cpIds)
|
||||
|
||||
for (const option of options) {
|
||||
if (option.value != null && points[option.value] != null) {
|
||||
option.innerText = option.innerText + " - " + points[option.value].name_int
|
||||
}
|
||||
}
|
||||
})()
|
||||
}
|
||||
|
||||
function addCommonStyles() {
|
||||
addStylesToHead(`
|
||||
#content h1 {
|
||||
@ -2636,6 +2656,7 @@
|
||||
|
||||
if (isRouteStagesPage()) {
|
||||
hideUselessRowsFromRouteStagesPage()
|
||||
addCpNameToOptions()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user