add links to stages

This commit is contained in:
Zhora Shalyapin 2025-03-14 14:39:36 +00:00
parent 7ef9d55dc6
commit 815bc96234

77
main.js
View File

@ -15,7 +15,22 @@
(function () { (function () {
'use strict' 'use strict'
let fileInputs = { const links = {
"Волонтеры": "suv_comp",
"Контрольные пункты": "cp_mgmt",
"Добавить новый КП": "cp_mgmt/?action=edit",
"Маршруты": "route_mgmt",
}
const catLinks = {
"Редактор маршрута": (catId) => `route_mgmt?action=edit&cat_id=${catId}`,
"Конструктор маршрута": (catId) => `route_mgmt/?action=build2&cat_id=${catId}`,
"Карта": (catId) => `route_mgmt?action=map&cat_id=${catId}`,
"Этапы": (catId) => `route_mgmt/?action=stages&cat_id=${catId}`,
"Легенда": (catId) => `route_mgmt?action=preview&cat_id=${catId}&locale_id=ru`,
}
const fileInputs = {
"attachment1": { "attachment1": {
"l": "legend_photo", "l": "legend_photo",
"h": "history_photo" "h": "history_photo"
@ -28,12 +43,12 @@
"attachment3": "admin_files" "attachment3": "admin_files"
} }
let fileInpitVariants = { const fileInpitVariants = {
"l": "для легенды", "l": "для легенды",
"h": "для ист. справки" "h": "для ист. справки"
} }
let mapsCenterByCompetition = { const mapsCenterByCompetition = {
"msk2025": { "msk2025": {
lat: 55.839808, lat: 55.839808,
ifSouthern: { ifSouthern: {
@ -187,10 +202,14 @@
return getPageType() === "route_mgmt" return getPageType() === "route_mgmt"
} }
function isListCpPage() { function isCpListPage() {
return isCpManagement() && getAction() === null return isCpManagement() && getAction() === null
} }
function isRouteListPage() {
return isRouteManagement() && getAction() === null
}
function isRouteBuildPage() { function isRouteBuildPage() {
return isRouteManagement() && getAction() === "build2" return isRouteManagement() && getAction() === "build2"
} }
@ -935,20 +954,6 @@
} }
function addStickyMenu() { function addStickyMenu() {
let links = {
"Волонтеры": "suv_comp",
"Контрольные пункты": "cp_mgmt",
"Добавить новый КП": "cp_mgmt/?action=edit",
"Маршруты": "route_mgmt",
}
let catLinks = {
"Редактор маршрута": (catId) => `route_mgmt?action=edit&cat_id=${catId}`,
"Конструктор маршрута": (catId) => `route_mgmt/?action=stages&cat_id=${catId}`,
"Карта": (catId) => `route_mgmt?action=map&cat_id=${catId}`,
"Этапы": (catId) => `route_mgmt/?action=stages&cat_id=${catId}`,
"Легенда": (catId) => `route_mgmt?action=preview&cat_id=${catId}&locale_id=ru`,
}
let menuContainer = document.createElement("nav") let menuContainer = document.createElement("nav")
menuContainer.classList.add("sticky-menu") menuContainer.classList.add("sticky-menu")
let menu = document.createElement("menu") let menu = document.createElement("menu")
@ -996,6 +1001,24 @@
}) })
} }
function addStageLink() {
let linkCells = [...document.querySelectorAll("#content table td:nth-child(2)")]
for (const linkCell of linkCells) {
let href = linkCell.querySelector("a").href
let catId = new URLSearchParams(href).get("cat_id")
let constructorLink = linkCell.querySelector(`a[href="${catLinks["Конструктор маршрута"](catId).replace("route_mgmt/", "")}"]`)
if (constructorLink) {
let stagesLink = document.createElement("a")
stagesLink.innerText = "Этапы"
stagesLink.href = catLinks[stagesLink.innerText](catId)
constructorLink.after(stagesLink)
constructorLink.after(", ")
}
}
}
function getRows() { function getRows() {
return [...document.querySelectorAll('#props > tbody > tr')] return [...document.querySelectorAll('#props > tbody > tr')]
} }
@ -1781,16 +1804,22 @@
} }
addClearBoth() addClearBoth()
initMapbox() if (document.querySelector(".leaflet-container")) {
addFullscreenButton() initMapbox()
addFullscreenButton()
if (isRouteBuildPage() || isRouteMapPage()) {
centerMap()
}
}
addStickyMenu() addStickyMenu()
if (isRouteBuildPage() || isRouteMapPage()) {
centerMap()
}
if (isEditCpPage()) { if (isEditCpPage()) {
prettifyEditCpPage() prettifyEditCpPage()
} }
if (isRouteListPage()) {
addStageLink()
}
})(); })();