feat: Add carriers
translation on 3 languages
This commit is contained in:
@ -3,7 +3,6 @@ import React, {
|
||||
useRef,
|
||||
useState,
|
||||
useCallback,
|
||||
ReactNode,
|
||||
useMemo,
|
||||
} from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
@ -33,7 +32,6 @@ import {
|
||||
ArrowRightLeft,
|
||||
Landmark,
|
||||
Pencil,
|
||||
Lasso,
|
||||
InfoIcon,
|
||||
X,
|
||||
Loader2,
|
||||
@ -86,9 +84,7 @@ class MapStore {
|
||||
for (const id of routesIds) {
|
||||
const route = await languageInstance("ru").get(`/route/${id}`);
|
||||
this.routes.push({
|
||||
id: route.data.id,
|
||||
route_number: route.data.route_number,
|
||||
path: route.data.path,
|
||||
...route.data,
|
||||
});
|
||||
}
|
||||
|
||||
@ -100,21 +96,14 @@ class MapStore {
|
||||
getStations = async () => {
|
||||
const stations = await languageInstance("ru").get("/station");
|
||||
this.stations = stations.data.map((station: any) => ({
|
||||
id: station.id,
|
||||
name: station.name,
|
||||
latitude: station.latitude,
|
||||
longitude: station.longitude,
|
||||
...station,
|
||||
}));
|
||||
};
|
||||
|
||||
getSights = async () => {
|
||||
const sights = await languageInstance("ru").get("/sight");
|
||||
this.sights = sights.data.map((sight: any) => ({
|
||||
id: sight.id,
|
||||
name: sight.name,
|
||||
description: sight.description,
|
||||
latitude: sight.latitude,
|
||||
longitude: sight.longitude,
|
||||
...sight,
|
||||
}));
|
||||
};
|
||||
|
||||
@ -194,9 +183,25 @@ class MapStore {
|
||||
throw new Error(`Unknown feature type for update: ${featureType}`);
|
||||
}
|
||||
|
||||
let oldData;
|
||||
if (featureType === "route") {
|
||||
oldData = this.routes.find((f) => f.id === numericId);
|
||||
} else if (featureType === "station") {
|
||||
oldData = this.stations.find((f) => f.id === numericId);
|
||||
} else if (featureType === "sight") {
|
||||
oldData = this.sights.find((f) => f.id === numericId);
|
||||
}
|
||||
|
||||
console.log(oldData);
|
||||
console.log(data);
|
||||
|
||||
const response = await languageInstance("ru").patch(
|
||||
`/${featureType}/${numericId}`,
|
||||
data
|
||||
{
|
||||
...oldData,
|
||||
latitude: data.latitude,
|
||||
longitude: data.longitude,
|
||||
}
|
||||
);
|
||||
|
||||
if (featureType === "route") {
|
||||
@ -277,6 +282,7 @@ class MapService {
|
||||
private tooltipElement: HTMLElement;
|
||||
private tooltipOverlay: Overlay | null;
|
||||
private mode: string | null;
|
||||
// @ts-ignore
|
||||
private currentDrawingType: "Point" | "LineString" | null;
|
||||
private currentDrawingFeatureType: FeatureType | null;
|
||||
private currentInteraction: Draw | null;
|
||||
@ -620,7 +626,7 @@ class MapService {
|
||||
filter: (_: FeatureLike, l: Layer<Source, any> | null) =>
|
||||
l === this.vectorLayer,
|
||||
});
|
||||
|
||||
// @ts-ignore
|
||||
this.modifyInteraction.on("modifystart", (event) => {
|
||||
const geoJSONFormat = new GeoJSON();
|
||||
if (!this.map) return;
|
||||
@ -959,7 +965,8 @@ class MapService {
|
||||
feature.set("name", `${baseName} ${maxNumber + 1}`);
|
||||
|
||||
await this.saveNewFeature(feature);
|
||||
this.stopDrawing();
|
||||
// Убираем вызов stopDrawing, чтобы режим рисования оставался активным
|
||||
// this.stopDrawing();
|
||||
});
|
||||
|
||||
this.map.addInteraction(this.currentInteraction);
|
||||
@ -988,7 +995,8 @@ class MapService {
|
||||
this.currentInteraction = null;
|
||||
this.currentDrawingType = null;
|
||||
this.currentDrawingFeatureType = null;
|
||||
this.activateEditMode();
|
||||
// Убираем автоматическое переключение в режим редактирования
|
||||
// this.activateEditMode();
|
||||
}
|
||||
|
||||
public finishDrawing(): void {
|
||||
@ -1007,6 +1015,10 @@ class MapService {
|
||||
this.currentInteraction instanceof Draw
|
||||
) {
|
||||
this.finishDrawing();
|
||||
// После завершения рисования маршрута, останавливаем режим рисования
|
||||
if (this.currentDrawingType === "LineString") {
|
||||
this.stopDrawing();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1098,6 +1110,7 @@ class MapService {
|
||||
if (this.mode === "edit") {
|
||||
this.selectInteraction.getFeatures().clear();
|
||||
this.selectInteraction.getFeatures().push(feature);
|
||||
// @ts-ignore
|
||||
const selectEvent = new SelectEvent("select", [feature], []);
|
||||
this.selectInteraction.dispatchEvent(selectEvent);
|
||||
}
|
||||
@ -1332,7 +1345,8 @@ class MapService {
|
||||
feature.set("name", newName);
|
||||
|
||||
this.updateFeaturesInReact();
|
||||
this.selectFeature(newFeatureId);
|
||||
// Убираем автоматический выбор созданного объекта
|
||||
// this.selectFeature(newFeatureId);
|
||||
} catch (error) {
|
||||
console.error("Failed to save new feature:", error);
|
||||
toast.error("Не удалось сохранить объект.");
|
||||
@ -1366,6 +1380,7 @@ interface ControlItem {
|
||||
const MapControls: React.FC<MapControlsProps> = ({
|
||||
mapService,
|
||||
activeMode,
|
||||
// @ts-ignore
|
||||
isLassoActive,
|
||||
isUnselectDisabled,
|
||||
}) => {
|
||||
@ -1473,11 +1488,13 @@ const MapSightbar: React.FC<MapSightbarProps> = ({
|
||||
}, [mapFeatures, searchQuery]);
|
||||
|
||||
const handleFeatureClick = useCallback(
|
||||
// @ts-ignore
|
||||
(id) => mapService?.selectFeature(id),
|
||||
[mapService]
|
||||
);
|
||||
|
||||
const handleDeleteFeature = useCallback(
|
||||
// @ts-ignore
|
||||
(id, recourse) => {
|
||||
if (
|
||||
mapService &&
|
||||
@ -1490,6 +1507,7 @@ const MapSightbar: React.FC<MapSightbarProps> = ({
|
||||
);
|
||||
|
||||
const handleCheckboxChange = useCallback(
|
||||
// @ts-ignore
|
||||
(id) => {
|
||||
if (id === undefined) return;
|
||||
const newSet = new Set(selectedIds);
|
||||
@ -1512,7 +1530,10 @@ const MapSightbar: React.FC<MapSightbarProps> = ({
|
||||
}
|
||||
}, [mapService, selectedIds, setSelectedIds]);
|
||||
|
||||
// @ts-ignore
|
||||
|
||||
const handleEditFeature = useCallback(
|
||||
// @ts-ignore
|
||||
(featureType, fullId) => {
|
||||
if (!featureType || !fullId) return;
|
||||
const numericId = String(fullId).split("-")[1];
|
||||
@ -1522,8 +1543,11 @@ const MapSightbar: React.FC<MapSightbarProps> = ({
|
||||
);
|
||||
|
||||
const sortFeatures = (
|
||||
// @ts-ignore
|
||||
features,
|
||||
// @ts-ignore
|
||||
currentSelectedIds,
|
||||
// @ts-ignore
|
||||
currentSelectedFeature
|
||||
) => {
|
||||
const selectedId = currentSelectedFeature?.getId();
|
||||
|
Reference in New Issue
Block a user