Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 14588cb6

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

  • ID 14588cb653e6b7358e0e641cc2b8d45dc27b5cf8
  • Rodič fc8a530f

fixed keys and indices

re #9741

Zobrazit rozdíly:

frontend/src/features/TrackingTool/Controls/MapPointDraggableListItem.tsx
8 8
import { Draggable } from 'react-beautiful-dnd'
9 9
import {
10 10
    getMapPointSemanticColor,
11
    isMapPointDisplayable,
11 12
    MapPointType,
12 13
    PathVariant,
13 14
} from '../trackingToolUtils'
14 15
import { CatalogItemDto } from '../../../swagger/data-contracts'
15 16
import { useDispatch } from 'react-redux'
16
import { removeMapMarker, updateMapMarker } from '../trackingToolSlice'
17
import {
18
    removeMapMarker,
19
    updateMapPoint,
20
    updateMapPointAtIndex,
21
} from '../trackingToolSlice'
17 22
import { useMemo } from 'react'
18 23
import DragHandleIcon from '@mui/icons-material/DragHandle'
19 24
import VisibilityIcon from '@mui/icons-material/Visibility'
......
27 32
    idx: number
28 33
}
29 34

  
35
// function Item({ provided, item, isDragging }) {
36
//     return (
37
//       <div style={{ paddingBottom: '8px' }}>
38
//         <div
39
//           {...provided.draggableProps}
40
//           {...provided.dragHandleProps}
41
//           ref={provided.innerRef}
42
//           style={provided.draggableProps.style}
43
//           className={`item ${isDragging ? 'is-dragging' : ''}`}
44
//         >
45
//           {item.text}
46
//         </div>
47
//       </div>
48
//     )
49
//   }
50

  
51
//   const HeightPreservingItem = ({ children, ...props }) => {
52
//     const [size, setSize] = useState(0)
53
//     const knownSize = props['data-known-size']
54
//     useEffect(() => {
55
//       setSize((prevSize) => {
56
//         return knownSize == 0 ? prevSize : knownSize
57
//       })
58
//     }, [knownSize])
59
//     return (
60
//       <div
61
//         {...props}
62
//         className="height-preserving-container"
63
//         // check styling in the style tag below
64
//         style={{ '--child-height': `${size}px`, }}
65
//       >
66
//         {children}
67
//       </div>
68
//     )
69
//   }
70

  
30 71
const getFormattedLocationOrEmpty = (catalogItem: CatalogItemDto) => {
31 72
    if (!catalogItem || !catalogItem.latitude || !catalogItem.longitude) {
32 73
        return 'Location unavailable'
......
52 93
                //     } as MapPoint,
53 94
                //     id: item.id,
54 95
                // })
55
                updateMapMarker({
96
                updateMapPointAtIndex({
56 97
                    ...item,
57 98
                    addToPath: !item?.addToPath,
58 99
                    idx,
......
69 110
                //     } as MapPoint,
70 111
                //     id: item.id,
71 112
                // })
72
                updateMapMarker({
113
                updateMapPoint({
73 114
                    ...item,
74 115
                    hidden: !item?.hidden,
75 116
                    idx,
......
89 130
        return (
90 131
            item && (
91 132
                <Draggable
92
                    key={`${item.id}`}
93
                    draggableId={`${item.id}`}
133
                    key={`${item.reactId}`}
134
                    draggableId={`${item.reactId}`}
94 135
                    index={idx}
95 136
                >
96 137
                    {(provided, snapshot) => (
......
124 165
                                    <DeleteForeverIcon />
125 166
                                </IconButton>
126 167
                            )}
127
                            <IconButton sx={{ mr: 1 }} onClick={toggleHidden}>
128
                                {item.hidden ? (
129
                                    <VisibilityOffIcon />
130
                                ) : (
131
                                    <VisibilityIcon />
132
                                )}
133
                            </IconButton>
168
                            {isMapPointDisplayable(item) ? (
169
                                <IconButton
170
                                    sx={{ mr: 1 }}
171
                                    onClick={toggleHidden}
172
                                >
173
                                    {item.hidden ? (
174
                                        <VisibilityOffIcon />
175
                                    ) : (
176
                                        <VisibilityIcon />
177
                                    )}
178
                                </IconButton>
179
                            ) : null}
134 180
                            <IconButton
135 181
                                sx={{ mr: 1 }}
136 182
                                onClick={toggleAddToPath}

Také k dispozici: Unified diff