Projekt

Obecné

Profil

« Předchozí | Další » 

Revize c0b66eaf

Přidáno uživatelem Václav Honzík před více než 2 roky(ů)

map icon colors start

re #9741

Zobrazit rozdíly:

frontend/src/features/TrackingTool/trackingToolSlice.ts
2 2
import { LatLngTuple } from "leaflet"
3 3
import mapConfig from "../../config/mapConfig"
4 4
import { PathDto } from "../../swagger/data-contracts"
5
import buildPathVariants, { isMapPointDisplayable, MapPoint, PathVariant } from "./Map/pathUtils"
5
import buildPathVariants from "./Map/pathUtils"
6
import  { isMapPointDisplayable, MapPoint, PathVariant } from "./trackingToolUtils"
6 7
import { sendTextForProcessing } from "./trackingToolThunks"
7 8
import storage from "redux-persist/lib/storage"
8
import TrackingToolState from './TrackingToolState'
9
import TrackingToolState from './trackingToolState'
9 10

  
10 11

  
11 12
const defaultPathsPerPage = 5
......
103 104
                })
104 105
            }
105 106
        },
107
        // Removes map marker based on its idx property
108
        removeMapMarker: (state: TrackingToolState, action: { payload: { id: string, idx: number } }) => {
109
            const item = action.payload
110
            const idx = state.primaryPathIdx
111
            if (!state.pathVariants || state.pathVariants.length <= idx) {
112
                return state
113
            }
114

  
115
            return {
116
                ...state,
117
                pathVariants: state.pathVariants.map((pathVariant, i) => {
118
                    if (i !== idx) {
119
                        return [...pathVariant]
120
                    }
121

  
122
                    return [
123
                        ...pathVariant.slice(0, item.idx),
124
                        ...pathVariant.slice(item.idx + 1),
125
                    ]
126
                })
127
            }
128
        },
106 129
        moveMarkerToDestination: (state: TrackingToolState, action: { payload: { destination: number, source: number } }) => {
107 130
            const { destination, source } = action.payload
108 131
            if (!state.pathVariants || state.pathVariants.length === 0) {
......
154 177
            // const itemsToReplace: MapPoint[] = []
155 178
            const itemsToAdd: MapPoint[] = []
156 179
            jsonPath.forEach((item) => {
157
                if (!pathMap.has(item.catalogItem.id as string)) {
180
                if (!pathMap.has(item.catalogItem.id ?? '')) {
158 181
                    itemsToAdd.push(item)
159 182
                    return
160 183
                }
......
231 254
    updateMapMarker,
232 255
    mergeWithCurrentPath,
233 256
    moveMarkerToDestination,
234
    updateMapMarkerWithId
257
    updateMapMarkerWithId,
258
    removeMapMarker,
235 259
} = trackingToolSlice.actions
236 260
const trackingToolReducer = trackingToolSlice.reducer
237 261
export default trackingToolReducer

Také k dispozici: Unified diff