fix: Fix name on map
and fix city name in sight list
This commit is contained in:
@ -146,7 +146,7 @@ class MapStore {
|
||||
|
||||
if (featureType === "station") {
|
||||
data = {
|
||||
name: properties.name || "Новая остановка",
|
||||
name: properties.name || "Остановка 1",
|
||||
latitude: geometry.coordinates[1],
|
||||
longitude: geometry.coordinates[0],
|
||||
};
|
||||
@ -159,7 +159,7 @@ class MapStore {
|
||||
};
|
||||
} else if (featureType === "sight") {
|
||||
data = {
|
||||
name: properties.name || "Новая достопримечательность",
|
||||
name: properties.name || "Достопримечательность 1",
|
||||
description: properties.description || "",
|
||||
latitude: geometry.coordinates[1],
|
||||
longitude: geometry.coordinates[0],
|
||||
@ -1263,14 +1263,42 @@ class MapService {
|
||||
|
||||
feature.set("featureType", fType);
|
||||
|
||||
// --- ИЗМЕНЕНИЕ: Именование с порядковым номером для маршрутов ---
|
||||
// --- ИЗМЕНЕНИЕ: Именование с порядковым номером для всех типов объектов ---
|
||||
let resourceName: string;
|
||||
switch (fType) {
|
||||
case "station":
|
||||
resourceName = "Новая остановка";
|
||||
// Находим следующий доступный номер остановки
|
||||
const existingStations = this.vectorSource
|
||||
.getFeatures()
|
||||
.filter((f) => f.get("featureType") === "station");
|
||||
const stationNumbers = existingStations
|
||||
.map((f) => {
|
||||
const name = f.get("name") as string;
|
||||
const match = name.match(/^Остановка (\d+)$/);
|
||||
return match ? parseInt(match[1], 10) : 0;
|
||||
})
|
||||
.filter((num) => num > 0);
|
||||
|
||||
const nextStationNumber =
|
||||
stationNumbers.length > 0 ? Math.max(...stationNumbers) + 1 : 1;
|
||||
resourceName = `Остановка ${nextStationNumber}`;
|
||||
break;
|
||||
case "sight":
|
||||
resourceName = "Новая достопримечательность";
|
||||
// Находим следующий доступный номер достопримечательности
|
||||
const existingSights = this.vectorSource
|
||||
.getFeatures()
|
||||
.filter((f) => f.get("featureType") === "sight");
|
||||
const sightNumbers = existingSights
|
||||
.map((f) => {
|
||||
const name = f.get("name") as string;
|
||||
const match = name.match(/^Достопримечательность (\d+)$/);
|
||||
return match ? parseInt(match[1], 10) : 0;
|
||||
})
|
||||
.filter((num) => num > 0);
|
||||
|
||||
const nextSightNumber =
|
||||
sightNumbers.length > 0 ? Math.max(...sightNumbers) + 1 : 1;
|
||||
resourceName = `Достопримечательность ${nextSightNumber}`;
|
||||
break;
|
||||
case "route":
|
||||
// Находим следующий доступный номер маршрута
|
||||
@ -1285,9 +1313,9 @@ class MapService {
|
||||
})
|
||||
.filter((num) => num > 0);
|
||||
|
||||
const nextNumber =
|
||||
const nextRouteNumber =
|
||||
routeNumbers.length > 0 ? Math.max(...routeNumbers) + 1 : 1;
|
||||
resourceName = `Маршрут ${nextNumber}`;
|
||||
resourceName = `Маршрут ${nextRouteNumber}`;
|
||||
break;
|
||||
default:
|
||||
resourceName = "Объект";
|
||||
@ -1920,7 +1948,7 @@ const MapSightbar: React.FC<MapSightbarProps> = ({
|
||||
if (aIsChecked && !bIsChecked) return -1;
|
||||
if (!aIsChecked && bIsChecked) return 1;
|
||||
|
||||
// 3. Сортировка по ID (новые объекты с большими ID в начале)
|
||||
// 3. Сортировка по ID (объекты остаются в порядке создания)
|
||||
const aNumericId = aId ? parseInt(String(aId).split("-")[1], 10) : 0;
|
||||
const bNumericId = bId ? parseInt(String(bId).split("-")[1], 10) : 0;
|
||||
if (
|
||||
@ -1928,7 +1956,7 @@ const MapSightbar: React.FC<MapSightbarProps> = ({
|
||||
!isNaN(bNumericId) &&
|
||||
aNumericId !== bNumericId
|
||||
) {
|
||||
return bNumericId - aNumericId; // По убыванию - новые сверху
|
||||
return aNumericId - bNumericId; // По возрастанию - старые сверху, новые снизу
|
||||
}
|
||||
|
||||
// 4. Запасная сортировка по имени
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { DataGrid, GridColDef, GridRenderCellParams } from "@mui/x-data-grid";
|
||||
import { ruRU } from "@mui/x-data-grid/locales";
|
||||
import { languageStore, sightsStore } from "@shared";
|
||||
import { cityStore, languageStore, sightsStore } from "@shared";
|
||||
import { useEffect, useState } from "react";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { Pencil, Trash2, Minus } from "lucide-react";
|
||||
@ -10,6 +10,7 @@ import { Box, CircularProgress } from "@mui/material";
|
||||
|
||||
export const SightListPage = observer(() => {
|
||||
const { sights, getSights, deleteListSight } = sightsStore;
|
||||
const { cities, getCities } = cityStore;
|
||||
const navigate = useNavigate();
|
||||
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
||||
const [isBulkDeleteModalOpen, setIsBulkDeleteModalOpen] = useState(false);
|
||||
@ -21,7 +22,9 @@ export const SightListPage = observer(() => {
|
||||
useEffect(() => {
|
||||
const fetchSights = async () => {
|
||||
setIsLoading(true);
|
||||
await getCities(language);
|
||||
await getSights();
|
||||
|
||||
setIsLoading(false);
|
||||
};
|
||||
fetchSights();
|
||||
@ -45,14 +48,14 @@ export const SightListPage = observer(() => {
|
||||
},
|
||||
},
|
||||
{
|
||||
field: "city",
|
||||
field: "city_id",
|
||||
headerName: "Город",
|
||||
flex: 1,
|
||||
renderCell: (params: GridRenderCellParams) => {
|
||||
return (
|
||||
<div className="w-full h-full flex items-center">
|
||||
{params.value ? (
|
||||
params.value
|
||||
cities[language].data.find((el) => el.id == params.value)?.name
|
||||
) : (
|
||||
<Minus size={20} className="text-red-500" />
|
||||
)}
|
||||
@ -92,7 +95,7 @@ export const SightListPage = observer(() => {
|
||||
const rows = sights.map((sight) => ({
|
||||
id: sight.id,
|
||||
name: sight.name,
|
||||
city: sight.city,
|
||||
city_id: sight.city_id,
|
||||
}));
|
||||
|
||||
return (
|
||||
|
Reference in New Issue
Block a user