add links to stages
This commit is contained in:
parent
7ef9d55dc6
commit
815bc96234
77
main.js
77
main.js
@ -15,7 +15,22 @@
|
||||
(function () {
|
||||
'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": {
|
||||
"l": "legend_photo",
|
||||
"h": "history_photo"
|
||||
@ -28,12 +43,12 @@
|
||||
"attachment3": "admin_files"
|
||||
}
|
||||
|
||||
let fileInpitVariants = {
|
||||
const fileInpitVariants = {
|
||||
"l": "для легенды",
|
||||
"h": "для ист. справки"
|
||||
}
|
||||
|
||||
let mapsCenterByCompetition = {
|
||||
const mapsCenterByCompetition = {
|
||||
"msk2025": {
|
||||
lat: 55.839808,
|
||||
ifSouthern: {
|
||||
@ -187,10 +202,14 @@
|
||||
return getPageType() === "route_mgmt"
|
||||
}
|
||||
|
||||
function isListCpPage() {
|
||||
function isCpListPage() {
|
||||
return isCpManagement() && getAction() === null
|
||||
}
|
||||
|
||||
function isRouteListPage() {
|
||||
return isRouteManagement() && getAction() === null
|
||||
}
|
||||
|
||||
function isRouteBuildPage() {
|
||||
return isRouteManagement() && getAction() === "build2"
|
||||
}
|
||||
@ -935,20 +954,6 @@
|
||||
}
|
||||
|
||||
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")
|
||||
menuContainer.classList.add("sticky-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() {
|
||||
return [...document.querySelectorAll('#props > tbody > tr')]
|
||||
}
|
||||
@ -1781,16 +1804,22 @@
|
||||
}
|
||||
|
||||
addClearBoth()
|
||||
initMapbox()
|
||||
addFullscreenButton()
|
||||
if (document.querySelector(".leaflet-container")) {
|
||||
initMapbox()
|
||||
addFullscreenButton()
|
||||
|
||||
if (isRouteBuildPage() || isRouteMapPage()) {
|
||||
centerMap()
|
||||
}
|
||||
}
|
||||
|
||||
addStickyMenu()
|
||||
|
||||
if (isRouteBuildPage() || isRouteMapPage()) {
|
||||
centerMap()
|
||||
}
|
||||
|
||||
if (isEditCpPage()) {
|
||||
prettifyEditCpPage()
|
||||
}
|
||||
|
||||
if (isRouteListPage()) {
|
||||
addStageLink()
|
||||
}
|
||||
})();
|
Loading…
Reference in New Issue
Block a user