blixify-ui-web 1.3.9 → 1.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/data/dataTemplate/index.d.ts.map +1 -1
- package/lib/components/data/dataTemplate/index.js +156 -35
- package/lib/components/data/dataTemplate/index.js.map +1 -1
- package/lib/components/data/dataTemplate/settingsModal.d.ts +16 -0
- package/lib/components/data/dataTemplate/settingsModal.d.ts.map +1 -1
- package/lib/components/data/dataTemplate/settingsModal.js +129 -23
- package/lib/components/data/dataTemplate/settingsModal.js.map +1 -1
- package/lib/components/data/dataTemplate/spaceModel.d.ts +7 -0
- package/lib/components/data/dataTemplate/spaceModel.d.ts.map +1 -1
- package/lib/components/display/mapView/index.d.ts +26 -1
- package/lib/components/display/mapView/index.d.ts.map +1 -1
- package/lib/components/display/mapView/index.js +352 -21
- package/lib/components/display/mapView/index.js.map +1 -1
- package/lib/components/display/mapView/routes.d.ts +72 -0
- package/lib/components/display/mapView/routes.d.ts.map +1 -0
- package/lib/components/display/mapView/routes.js +310 -0
- package/lib/components/display/mapView/routes.js.map +1 -0
- package/lib/components/display/newKanban/index.d.ts +47 -0
- package/lib/components/display/newKanban/index.d.ts.map +1 -1
- package/lib/components/display/newKanban/index.js +371 -16
- package/lib/components/display/newKanban/index.js.map +1 -1
- package/lib/tail.css +1 -1
- package/package.json +1 -1
|
@@ -14,6 +14,17 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
17
28
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
29
|
if (k2 === undefined) k2 = k;
|
|
19
30
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -86,7 +97,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
86
97
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
87
98
|
};
|
|
88
99
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
89
|
-
exports.MapView = void 0;
|
|
100
|
+
exports.MapView = exports.handleResolveRouteColor = exports.handleBuildRoutesFromRows = exports.handleBuildRouteStops = exports.handleBuildRoutePaths = exports.handleBuildRouteEnds = exports.handleBuildRouteChanges = void 0;
|
|
90
101
|
var markerclusterer_1 = require("@googlemaps/markerclusterer");
|
|
91
102
|
var outline_1 = require("@heroicons/react/24/outline");
|
|
92
103
|
var axios_1 = __importDefault(require("axios"));
|
|
@@ -96,6 +107,14 @@ var ts_overlapping_marker_spiderfier_1 = require("ts-overlapping-marker-spiderfi
|
|
|
96
107
|
var button_1 = require("../../action/button");
|
|
97
108
|
var iconButton_1 = require("../../action/iconButton");
|
|
98
109
|
var googleMaps_1 = require("../../googleMaps");
|
|
110
|
+
var routes_1 = require("./routes");
|
|
111
|
+
var routes_2 = require("./routes");
|
|
112
|
+
Object.defineProperty(exports, "handleBuildRouteChanges", { enumerable: true, get: function () { return routes_2.handleBuildRouteChanges; } });
|
|
113
|
+
Object.defineProperty(exports, "handleBuildRouteEnds", { enumerable: true, get: function () { return routes_2.handleBuildRouteEnds; } });
|
|
114
|
+
Object.defineProperty(exports, "handleBuildRoutePaths", { enumerable: true, get: function () { return routes_2.handleBuildRoutePaths; } });
|
|
115
|
+
Object.defineProperty(exports, "handleBuildRouteStops", { enumerable: true, get: function () { return routes_2.handleBuildRouteStops; } });
|
|
116
|
+
Object.defineProperty(exports, "handleBuildRoutesFromRows", { enumerable: true, get: function () { return routes_2.handleBuildRoutesFromRows; } });
|
|
117
|
+
Object.defineProperty(exports, "handleResolveRouteColor", { enumerable: true, get: function () { return routes_2.handleResolveRouteColor; } });
|
|
99
118
|
var POLYGON_COLOR_HEX = {
|
|
100
119
|
red: "#f87171",
|
|
101
120
|
blue: "#60a5fa",
|
|
@@ -134,8 +153,18 @@ var MapView = /** @class */ (function (_super) {
|
|
|
134
153
|
polygonList: [],
|
|
135
154
|
polygonCoords: [],
|
|
136
155
|
hiddenGroups: [],
|
|
156
|
+
hiddenRoutes: [],
|
|
157
|
+
selectedRoute: "",
|
|
158
|
+
dragStopId: "",
|
|
159
|
+
dropBeforeStopId: null,
|
|
137
160
|
polygonAreas: new Map(),
|
|
138
161
|
};
|
|
162
|
+
_this.routeLines = [];
|
|
163
|
+
_this.routeEndMarkers = [];
|
|
164
|
+
// INFO: the pins on the map now, kept here as well as in state — state
|
|
165
|
+
// updates later, so two redraws in a row cleared nothing and drew every
|
|
166
|
+
// pin twice, and a doubled pin spreads apart on click instead of opening
|
|
167
|
+
_this.drawnMarkers = [];
|
|
139
168
|
_this.handleFetchPolygonFile = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
140
169
|
var response, data, err_1;
|
|
141
170
|
return __generator(this, function (_a) {
|
|
@@ -301,9 +330,9 @@ var MapView = /** @class */ (function (_super) {
|
|
|
301
330
|
}
|
|
302
331
|
}
|
|
303
332
|
this.setState({ googleMap: googleMap }, function () {
|
|
304
|
-
var _a, _b
|
|
305
|
-
|
|
306
|
-
(
|
|
333
|
+
var _a, _b;
|
|
334
|
+
_this.handleRenderMarkers();
|
|
335
|
+
(_a = _this.handleAddPolygons) === null || _a === void 0 ? void 0 : _a.call(_this, (_b = _this.props.polygonList) !== null && _b !== void 0 ? _b : []);
|
|
307
336
|
if (_this.pendingPolygonFileCoords) {
|
|
308
337
|
_this.renderPolygon(_this.pendingPolygonFileCoords);
|
|
309
338
|
_this.pendingPolygonFileCoords = null;
|
|
@@ -319,16 +348,21 @@ var MapView = /** @class */ (function (_super) {
|
|
|
319
348
|
});
|
|
320
349
|
}); };
|
|
321
350
|
_this.handleAddMarkers = function (markerList) {
|
|
351
|
+
var _a, _b;
|
|
322
352
|
var googleMap = _this.state.googleMap;
|
|
323
|
-
var
|
|
353
|
+
var _c = _this, oms = _c.oms, markerClusterer = _c.markerClusterer;
|
|
324
354
|
if (!googleMap || !oms || !markerClusterer)
|
|
325
355
|
return;
|
|
356
|
+
var numbers = (0, routes_1.handleBuildRouteStops)((_a = _this.props.routeList) !== null && _a !== void 0 ? _a : [], (_b = _this.props.markerList) !== null && _b !== void 0 ? _b : [], _this.state.hiddenRoutes).numbers;
|
|
326
357
|
var newMarkers = markerList.map(function (eachMarker) {
|
|
327
|
-
var _a, _b, _c, _d, _e, _f;
|
|
358
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
359
|
+
var stopNumber = numbers[eachMarker.id];
|
|
328
360
|
var infoWindowComponent = (_b = (_a = _this.props).infoWindowComponent) === null || _b === void 0 ? void 0 : _b.call(_a, eachMarker.id, (_c = eachMarker.data) !== null && _c !== void 0 ? _c : {});
|
|
329
361
|
var markerNode = document.createElement("div");
|
|
330
362
|
var markerRoot = (0, client_1.createRoot)(markerNode);
|
|
331
|
-
markerRoot.render(
|
|
363
|
+
markerRoot.render(react_1.default.createElement(react_1.default.Fragment, null,
|
|
364
|
+
infoWindowComponent,
|
|
365
|
+
_this.renderAddToRoute(eachMarker.id)));
|
|
332
366
|
var infoWindowHeaderComponent = (_e = (_d = _this.props).infoWindowHeaderComponent) === null || _e === void 0 ? void 0 : _e.call(_d, eachMarker.id, (_f = eachMarker.data) !== null && _f !== void 0 ? _f : {});
|
|
333
367
|
var headerNode = document.createElement("div");
|
|
334
368
|
var headerRoot = (0, client_1.createRoot)(headerNode);
|
|
@@ -344,14 +378,20 @@ var MapView = /** @class */ (function (_super) {
|
|
|
344
378
|
if (eachMarker.color && eachMarker.color !== "none") {
|
|
345
379
|
markerUrl = "https://github.com/Concept211/Google-Maps-Markers/blob/master/source/marker_".concat(eachMarker.color, ".png?raw=true");
|
|
346
380
|
}
|
|
347
|
-
var marker = new window.google.maps.Marker({
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
381
|
+
var marker = new window.google.maps.Marker(__assign(__assign(__assign({ position: new window.google.maps.LatLng(eachMarker.coord.lat, eachMarker.coord.lng), map: googleMap }, (((_g = eachMarker.data) === null || _g === void 0 ? void 0 : _g.title) && typeof eachMarker.data.title === "string"
|
|
382
|
+
? { title: eachMarker.data.title }
|
|
383
|
+
: {})), { icon: __assign({ url: eachMarker.icon ? eachMarker.icon : markerUrl, scaledSize: new google.maps.Size(22, 40) }, (stopNumber ? { labelOrigin: new google.maps.Point(11, 12) } : {})) }), (stopNumber
|
|
384
|
+
? {
|
|
385
|
+
label: {
|
|
386
|
+
text: String(stopNumber),
|
|
387
|
+
// INFO: white reads on every pin colour; dark text sat on the
|
|
388
|
+
// pin's own dark dot
|
|
389
|
+
color: "#ffffff",
|
|
390
|
+
fontSize: "11px",
|
|
391
|
+
fontWeight: "700",
|
|
392
|
+
},
|
|
393
|
+
}
|
|
394
|
+
: {})));
|
|
355
395
|
marker.set("id", eachMarker.id);
|
|
356
396
|
marker.set("data", eachMarker.data);
|
|
357
397
|
oms.addMarker(marker, function () {
|
|
@@ -362,6 +402,7 @@ var MapView = /** @class */ (function (_super) {
|
|
|
362
402
|
});
|
|
363
403
|
return marker;
|
|
364
404
|
});
|
|
405
|
+
_this.drawnMarkers = newMarkers;
|
|
365
406
|
if (_this.props.enableCluster && markerClusterer) {
|
|
366
407
|
markerClusterer.addMarkers(newMarkers);
|
|
367
408
|
}
|
|
@@ -406,14 +447,204 @@ var MapView = /** @class */ (function (_super) {
|
|
|
406
447
|
}
|
|
407
448
|
};
|
|
408
449
|
_this.handleRenderMarkers = function () {
|
|
409
|
-
var _a, _b;
|
|
450
|
+
var _a, _b, _c, _d;
|
|
410
451
|
_this.handleClearMarkers();
|
|
411
|
-
var
|
|
452
|
+
var hiddenIds = (0, routes_1.handleBuildRouteStops)((_a = _this.props.routeList) !== null && _a !== void 0 ? _a : [], (_b = _this.props.markerList) !== null && _b !== void 0 ? _b : [], _this.state.hiddenRoutes).hiddenIds;
|
|
453
|
+
var visibleMarkers = (_d = (_c = _this.props.markerList) === null || _c === void 0 ? void 0 : _c.filter(function (marker) {
|
|
412
454
|
var _a;
|
|
413
455
|
var group = ((_a = marker.data) === null || _a === void 0 ? void 0 : _a.group) || "Untitled";
|
|
414
|
-
return !_this.state.hiddenGroups.includes(group);
|
|
415
|
-
})) !== null &&
|
|
456
|
+
return (!_this.state.hiddenGroups.includes(group) && !hiddenIds.has(marker.id));
|
|
457
|
+
})) !== null && _d !== void 0 ? _d : [];
|
|
416
458
|
_this.handleAddMarkers(visibleMarkers);
|
|
459
|
+
_this.handleRenderRoutes();
|
|
460
|
+
};
|
|
461
|
+
// INFO: one straight line per shown route, with arrows along it in the
|
|
462
|
+
// direction of travel; road-following lines would need the paid Directions
|
|
463
|
+
// service
|
|
464
|
+
_this.handleRenderRoutes = function () {
|
|
465
|
+
var _a, _b, _c, _d, _e;
|
|
466
|
+
_this.routeLines.forEach(function (eachLine) { return eachLine.setMap(null); });
|
|
467
|
+
_this.routeLines = [];
|
|
468
|
+
_this.routeEndMarkers.forEach(function (eachMarker) { return eachMarker.setMap(null); });
|
|
469
|
+
_this.routeEndMarkers = [];
|
|
470
|
+
var googleMap = _this.state.googleMap;
|
|
471
|
+
if (!googleMap || !((_b = (_a = window.google) === null || _a === void 0 ? void 0 : _a.maps) === null || _b === void 0 ? void 0 : _b.Polyline))
|
|
472
|
+
return;
|
|
473
|
+
// INFO: a line only passes stops whose pins are shown, so hiding a colour
|
|
474
|
+
// group in the Color Legend takes its stops off the lines as well
|
|
475
|
+
var shownMarkers = ((_c = _this.props.markerList) !== null && _c !== void 0 ? _c : []).filter(function (marker) { var _a; return !_this.state.hiddenGroups.includes(((_a = marker.data) === null || _a === void 0 ? void 0 : _a.group) || "Untitled"); });
|
|
476
|
+
_this.routeLines = (0, routes_1.handleBuildRoutePaths)((_d = _this.props.routeList) !== null && _d !== void 0 ? _d : [], shownMarkers, _this.state.hiddenRoutes).map(function (eachRoute) {
|
|
477
|
+
return new window.google.maps.Polyline({
|
|
478
|
+
path: eachRoute.path,
|
|
479
|
+
map: googleMap,
|
|
480
|
+
strokeColor: getPolygonColorHex(eachRoute.color),
|
|
481
|
+
// INFO: a route picked for planning stands out over the others
|
|
482
|
+
strokeOpacity: !_this.state.selectedRoute ||
|
|
483
|
+
_this.state.selectedRoute === eachRoute.id
|
|
484
|
+
? 0.9
|
|
485
|
+
: 0.25,
|
|
486
|
+
strokeWeight: _this.state.selectedRoute === eachRoute.id ? 6 : 4,
|
|
487
|
+
icons: [
|
|
488
|
+
{
|
|
489
|
+
icon: {
|
|
490
|
+
path: window.google.maps.SymbolPath.FORWARD_CLOSED_ARROW,
|
|
491
|
+
scale: 2.5,
|
|
492
|
+
strokeColor: getPolygonColorHex(eachRoute.color),
|
|
493
|
+
fillColor: getPolygonColorHex(eachRoute.color),
|
|
494
|
+
fillOpacity: 1,
|
|
495
|
+
},
|
|
496
|
+
offset: "50%",
|
|
497
|
+
repeat: "160px",
|
|
498
|
+
},
|
|
499
|
+
],
|
|
500
|
+
});
|
|
501
|
+
});
|
|
502
|
+
// INFO: a route's start and end (a depot) as a house-shaped pin in the
|
|
503
|
+
// route's colour, lettered S, E, or SE where the trip returns to its start
|
|
504
|
+
if (!window.google.maps.Marker)
|
|
505
|
+
return;
|
|
506
|
+
_this.routeEndMarkers = (0, routes_1.handleBuildRouteEnds)((_e = _this.props.routeList) !== null && _e !== void 0 ? _e : [], shownMarkers, _this.state.hiddenRoutes).map(function (eachEnd) {
|
|
507
|
+
var _a, _b;
|
|
508
|
+
var name = eachEnd.point.label ||
|
|
509
|
+
((_b = ((_a = _this.props.routeList) !== null && _a !== void 0 ? _a : []).find(function (each) { return each.id === eachEnd.routeId; })) === null || _b === void 0 ? void 0 : _b.label) ||
|
|
510
|
+
eachEnd.routeId;
|
|
511
|
+
var kindLabel = eachEnd.kind === "both"
|
|
512
|
+
? "Start and end"
|
|
513
|
+
: eachEnd.kind === "start"
|
|
514
|
+
? "Start"
|
|
515
|
+
: "End";
|
|
516
|
+
return new window.google.maps.Marker({
|
|
517
|
+
position: { lat: eachEnd.point.lat, lng: eachEnd.point.lng },
|
|
518
|
+
map: googleMap,
|
|
519
|
+
title: "".concat(kindLabel, ": ").concat(name),
|
|
520
|
+
zIndex: 1000,
|
|
521
|
+
icon: {
|
|
522
|
+
path: "M -12 -2 L 0 -14 L 12 -2 L 12 12 L -12 12 Z",
|
|
523
|
+
fillColor: getPolygonColorHex(eachEnd.color),
|
|
524
|
+
fillOpacity: 1,
|
|
525
|
+
strokeColor: "#ffffff",
|
|
526
|
+
strokeWeight: 2,
|
|
527
|
+
scale: 1.1,
|
|
528
|
+
labelOrigin: new window.google.maps.Point(0, 3),
|
|
529
|
+
},
|
|
530
|
+
label: {
|
|
531
|
+
text: eachEnd.kind === "both"
|
|
532
|
+
? "SE"
|
|
533
|
+
: eachEnd.kind === "start"
|
|
534
|
+
? "S"
|
|
535
|
+
: "E",
|
|
536
|
+
color: "#ffffff",
|
|
537
|
+
fontSize: "11px",
|
|
538
|
+
fontWeight: "700",
|
|
539
|
+
},
|
|
540
|
+
});
|
|
541
|
+
});
|
|
542
|
+
};
|
|
543
|
+
_this.handleSelectRoute = function (routeId) {
|
|
544
|
+
_this.setState({
|
|
545
|
+
selectedRoute: _this.state.selectedRoute === routeId ? "" : routeId,
|
|
546
|
+
}, function () { return _this.handleRenderMarkers(); });
|
|
547
|
+
};
|
|
548
|
+
_this.handleGetSelectedRoute = function () {
|
|
549
|
+
var _a;
|
|
550
|
+
return ((_a = _this.props.routeList) !== null && _a !== void 0 ? _a : []).find(function (each) { return each.id === _this.state.selectedRoute; });
|
|
551
|
+
};
|
|
552
|
+
_this.handleAddToRoute = function (markerId) {
|
|
553
|
+
var route = _this.handleGetSelectedRoute();
|
|
554
|
+
if (!route || !_this.props.onChangeRoute)
|
|
555
|
+
return;
|
|
556
|
+
_this.props.onChangeRoute({
|
|
557
|
+
routeId: route.id,
|
|
558
|
+
stopIds: __spreadArray(__spreadArray([], route.stopIds.filter(function (each) { return each !== markerId; }), true), [markerId], false),
|
|
559
|
+
});
|
|
560
|
+
};
|
|
561
|
+
_this.handleRemoveFromRoute = function (markerId) {
|
|
562
|
+
var route = _this.handleGetSelectedRoute();
|
|
563
|
+
if (!route || !_this.props.onChangeRoute)
|
|
564
|
+
return;
|
|
565
|
+
_this.props.onChangeRoute({
|
|
566
|
+
routeId: route.id,
|
|
567
|
+
stopIds: route.stopIds.filter(function (each) { return each !== markerId; }),
|
|
568
|
+
removedIds: [markerId],
|
|
569
|
+
});
|
|
570
|
+
};
|
|
571
|
+
// INFO: over a stop below the one dragged, the drop goes after it; over
|
|
572
|
+
// one above, before it — reaching a row is enough to pass it, as in most
|
|
573
|
+
// sortable lists. Over the dragged stop itself it stays where it is. null
|
|
574
|
+
// is the end of the list
|
|
575
|
+
_this.handleGetStopDropBefore = function (stopIds, stopId, y, rect) {
|
|
576
|
+
var _a, _b;
|
|
577
|
+
var from = stopIds.indexOf(_this.state.dragStopId);
|
|
578
|
+
var over = stopIds.indexOf(stopId);
|
|
579
|
+
var isAfter = from > -1 && over !== from ? over > from : y > rect.top + rect.height / 2;
|
|
580
|
+
if (over === from)
|
|
581
|
+
return (_a = stopIds[from + 1]) !== null && _a !== void 0 ? _a : null;
|
|
582
|
+
return isAfter ? ((_b = stopIds[over + 1]) !== null && _b !== void 0 ? _b : null) : stopId;
|
|
583
|
+
};
|
|
584
|
+
// INFO: over a stop's row, see handleGetStopDropBefore
|
|
585
|
+
_this.handleDragOverStop = function (e, stopIds, stopId) {
|
|
586
|
+
if (!_this.state.dragStopId)
|
|
587
|
+
return;
|
|
588
|
+
e.preventDefault();
|
|
589
|
+
var beforeId = _this.handleGetStopDropBefore(stopIds, stopId, e.clientY, e.currentTarget.getBoundingClientRect());
|
|
590
|
+
if (beforeId !== _this.state.dropBeforeStopId)
|
|
591
|
+
_this.setState({ dropBeforeStopId: beforeId });
|
|
592
|
+
};
|
|
593
|
+
// INFO: touch fires no HTML5 drag events, so a stop is dragged by its grip
|
|
594
|
+
// with pointer events and placed by the row under the pointer
|
|
595
|
+
_this.handleStopGripDown = function (e, stopId) {
|
|
596
|
+
var _a, _b;
|
|
597
|
+
// INFO: every pointer, the mouse included — a native drag does not start
|
|
598
|
+
// from the grip, so it is the grip's own drag or none
|
|
599
|
+
if (!_this.props.onChangeRoute)
|
|
600
|
+
return;
|
|
601
|
+
e.preventDefault();
|
|
602
|
+
e.stopPropagation();
|
|
603
|
+
(_b = (_a = e.currentTarget).setPointerCapture) === null || _b === void 0 ? void 0 : _b.call(_a, e.pointerId);
|
|
604
|
+
_this.setState({ dragStopId: stopId, dropBeforeStopId: null });
|
|
605
|
+
};
|
|
606
|
+
_this.handleStopGripMove = function (e, stopIds) {
|
|
607
|
+
var _a;
|
|
608
|
+
if (!_this.state.dragStopId)
|
|
609
|
+
return;
|
|
610
|
+
var listEl = e.currentTarget.closest('[data-testid^="map-route-stops-"]');
|
|
611
|
+
var rows = Array.from((_a = listEl === null || listEl === void 0 ? void 0 : listEl.querySelectorAll('[data-testid^="map-route-stop-"]')) !== null && _a !== void 0 ? _a : []);
|
|
612
|
+
var handleRowId = function (el) { var _a; return ((_a = el === null || el === void 0 ? void 0 : el.dataset.testid) !== null && _a !== void 0 ? _a : "").replace("map-route-stop-", ""); };
|
|
613
|
+
var overRow = rows.find(function (each) {
|
|
614
|
+
var rect = each.getBoundingClientRect();
|
|
615
|
+
return e.clientY >= rect.top && e.clientY <= rect.bottom;
|
|
616
|
+
});
|
|
617
|
+
var beforeId;
|
|
618
|
+
if (overRow)
|
|
619
|
+
beforeId = _this.handleGetStopDropBefore(stopIds, handleRowId(overRow), e.clientY, overRow.getBoundingClientRect());
|
|
620
|
+
else {
|
|
621
|
+
var below = rows.find(function (each) { return each.getBoundingClientRect().top > e.clientY; });
|
|
622
|
+
beforeId = below ? handleRowId(below) : null;
|
|
623
|
+
}
|
|
624
|
+
if (beforeId !== _this.state.dropBeforeStopId &&
|
|
625
|
+
(beforeId === null || stopIds.includes(beforeId)))
|
|
626
|
+
_this.setState({ dropBeforeStopId: beforeId });
|
|
627
|
+
};
|
|
628
|
+
_this.handleDropStop = function () {
|
|
629
|
+
var route = _this.handleGetSelectedRoute();
|
|
630
|
+
var _a = _this.state, dragStopId = _a.dragStopId, dropBeforeStopId = _a.dropBeforeStopId;
|
|
631
|
+
_this.setState({ dragStopId: "", dropBeforeStopId: null });
|
|
632
|
+
if (!route || !dragStopId || !_this.props.onChangeRoute)
|
|
633
|
+
return;
|
|
634
|
+
var rest = route.stopIds.filter(function (each) { return each !== dragStopId; });
|
|
635
|
+
var index = dropBeforeStopId === null ? rest.length : rest.indexOf(dropBeforeStopId);
|
|
636
|
+
rest.splice(index < 0 ? rest.length : index, 0, dragStopId);
|
|
637
|
+
if (rest.join("|") === route.stopIds.join("|"))
|
|
638
|
+
return;
|
|
639
|
+
_this.props.onChangeRoute({ routeId: route.id, stopIds: rest });
|
|
640
|
+
};
|
|
641
|
+
_this.handleToggleRouteVisibility = function (routeId) {
|
|
642
|
+
var hiddenRoutes = _this.state.hiddenRoutes;
|
|
643
|
+
_this.setState({
|
|
644
|
+
hiddenRoutes: hiddenRoutes.includes(routeId)
|
|
645
|
+
? hiddenRoutes.filter(function (each) { return each !== routeId; })
|
|
646
|
+
: __spreadArray(__spreadArray([], hiddenRoutes, true), [routeId], false),
|
|
647
|
+
}, function () { return _this.handleRenderMarkers(); });
|
|
417
648
|
};
|
|
418
649
|
_this.handleToggleGroupVisibility = function (group) {
|
|
419
650
|
var hiddenGroups = _this.state.hiddenGroups;
|
|
@@ -433,7 +664,8 @@ var MapView = /** @class */ (function (_super) {
|
|
|
433
664
|
return infoWindowDiv;
|
|
434
665
|
};
|
|
435
666
|
_this.handleClearMarkers = function () {
|
|
436
|
-
var markers = _this.state.markers;
|
|
667
|
+
var markers = Array.from(new Set(__spreadArray(__spreadArray([], _this.drawnMarkers, true), _this.state.markers, true)));
|
|
668
|
+
_this.drawnMarkers = [];
|
|
437
669
|
var _a = _this, oms = _a.oms, markerClusterer = _a.markerClusterer;
|
|
438
670
|
if (oms) {
|
|
439
671
|
markers.forEach(function (marker) { return oms.removeMarker(marker); });
|
|
@@ -684,11 +916,104 @@ var MapView = /** @class */ (function (_super) {
|
|
|
684
916
|
return (_b = (_a = _this.props).handleDeleteOnClick) === null || _b === void 0 ? void 0 : _b.call(_a, _this.state.selectedMarkerIds);
|
|
685
917
|
}, disabled: _this.state.selectedMarkerIds.length <= 0 })))),
|
|
686
918
|
react_1.default.createElement(button_1.Button, { type: "normal", size: "small", text: "Clear Polygons", disable: _this.state.polygonList.length <= 0, onClick: _this.handleClearPolygons }))),
|
|
919
|
+
_this.renderRouteLegend(),
|
|
687
920
|
_this.renderColorLegend()));
|
|
688
921
|
}
|
|
689
922
|
else
|
|
690
923
|
return react_1.default.createElement(react_1.default.Fragment, null);
|
|
691
924
|
};
|
|
925
|
+
_this.renderRouteLegend = function () {
|
|
926
|
+
var _a, _b;
|
|
927
|
+
var routes = (_a = _this.props.routeList) !== null && _a !== void 0 ? _a : [];
|
|
928
|
+
if (routes.length === 0)
|
|
929
|
+
return null;
|
|
930
|
+
var shown = new Set(((_b = _this.props.markerList) !== null && _b !== void 0 ? _b : []).map(function (each) { return each.id; }));
|
|
931
|
+
return (react_1.default.createElement("div", { className: "flex flex-col space-y-2 bg-white w-full h-fit max-h-[28rem] overflow-y-auto rounded-md p-4 shadow-lg", style: { zIndex: 1 }, "data-testid": "map-route-legend" },
|
|
932
|
+
react_1.default.createElement("p", { className: "font-semibold" }, "Routes"),
|
|
933
|
+
routes.map(function (eachRoute, index) {
|
|
934
|
+
var isHidden = _this.state.hiddenRoutes.includes(eachRoute.id);
|
|
935
|
+
var stops = eachRoute.stopIds.filter(function (each) { return shown.has(each); });
|
|
936
|
+
return (react_1.default.createElement("div", { key: eachRoute.id },
|
|
937
|
+
react_1.default.createElement("div", { className: "flex justify-between items-center" },
|
|
938
|
+
react_1.default.createElement("button", { type: "button", "data-testid": "map-route-select-".concat(eachRoute.id), className: "flex space-x-2 items-center min-w-0 rounded px-1 -mx-1 text-left ".concat(_this.state.selectedRoute === eachRoute.id
|
|
939
|
+
? "bg-primary-50 font-semibold"
|
|
940
|
+
: "hover:bg-gray-50"), onClick: function () { return _this.handleSelectRoute(eachRoute.id); } },
|
|
941
|
+
react_1.default.createElement("div", { className: "w-4 h-1 flex-shrink-0 rounded-full", style: {
|
|
942
|
+
backgroundColor: getPolygonColorHex((0, routes_1.handleResolveRouteColor)(eachRoute, index)),
|
|
943
|
+
} }),
|
|
944
|
+
react_1.default.createElement("p", { className: "break-words" },
|
|
945
|
+
eachRoute.label || eachRoute.id,
|
|
946
|
+
" (",
|
|
947
|
+
stops.length,
|
|
948
|
+
")")),
|
|
949
|
+
react_1.default.createElement(iconButton_1.IconButton, { icon: isHidden ? (react_1.default.createElement(outline_1.EyeSlashIcon, { className: "w-5 h-5 text-primary-500" })) : (react_1.default.createElement(outline_1.EyeIcon, { className: "w-5 h-5 text-primary-500" })), onClick: function () { return _this.handleToggleRouteVisibility(eachRoute.id); } })),
|
|
950
|
+
_this.state.selectedRoute === eachRoute.id &&
|
|
951
|
+
_this.renderRouteStops(eachRoute, stops)));
|
|
952
|
+
})));
|
|
953
|
+
};
|
|
954
|
+
// INFO: a picked route's stops in order between its start and end, each
|
|
955
|
+
// draggable into a new place and with a cross to take it off the route
|
|
956
|
+
_this.renderRouteStops = function (route, stopIds) {
|
|
957
|
+
var _a;
|
|
958
|
+
var canPlan = !!_this.props.onChangeRoute;
|
|
959
|
+
var titles = new Map(((_a = _this.props.markerList) !== null && _a !== void 0 ? _a : []).map(function (each) {
|
|
960
|
+
var _a;
|
|
961
|
+
return [
|
|
962
|
+
each.id,
|
|
963
|
+
((_a = each.data) === null || _a === void 0 ? void 0 : _a.title) || each.id,
|
|
964
|
+
];
|
|
965
|
+
}));
|
|
966
|
+
var renderDropLine = function () { return (react_1.default.createElement("div", { "data-testid": "map-route-drop-line", className: "h-0.5 rounded-full bg-primary-500" })); };
|
|
967
|
+
var renderEnd = function (label, name) { return (react_1.default.createElement("div", { className: "flex items-center gap-2 px-1 py-1 text-xs text-gray-500" },
|
|
968
|
+
react_1.default.createElement("span", { className: "w-5 flex-shrink-0 text-center font-semibold" }, label),
|
|
969
|
+
react_1.default.createElement("span", { className: "truncate" }, name || "—"))); };
|
|
970
|
+
return (react_1.default.createElement("div", { "data-testid": "map-route-stops-".concat(route.id), className: "mt-2 mb-1 ml-1 border-l-2 border-gray-200 pl-2", onDragOver: function (e) { return canPlan && e.preventDefault(); }, onDrop: function (e) {
|
|
971
|
+
e.preventDefault();
|
|
972
|
+
_this.handleDropStop();
|
|
973
|
+
} },
|
|
974
|
+
route.start && renderEnd("S", route.start.label),
|
|
975
|
+
stopIds.map(function (eachId, index) { return (react_1.default.createElement(react_1.default.Fragment, { key: eachId },
|
|
976
|
+
_this.state.dragStopId &&
|
|
977
|
+
_this.state.dropBeforeStopId === eachId &&
|
|
978
|
+
renderDropLine(),
|
|
979
|
+
react_1.default.createElement("div", { "data-testid": "map-route-stop-".concat(eachId), draggable: canPlan, onDragStart: function (e) {
|
|
980
|
+
e.dataTransfer.setData("text/plain", eachId);
|
|
981
|
+
e.dataTransfer.effectAllowed = "move";
|
|
982
|
+
_this.setState({ dragStopId: eachId });
|
|
983
|
+
}, onDragOver: function (e) { return _this.handleDragOverStop(e, stopIds, eachId); }, onDragEnd: function () {
|
|
984
|
+
return _this.setState({ dragStopId: "", dropBeforeStopId: null });
|
|
985
|
+
}, className: "flex items-center gap-2 rounded px-1 py-1 text-sm ".concat(canPlan ? "cursor-grab hover:bg-gray-50" : "", " ").concat(_this.state.dragStopId === eachId ? "opacity-40" : "") },
|
|
986
|
+
canPlan && (react_1.default.createElement("span", { role: "button", "aria-label": "Drag to reorder", "data-testid": "map-route-grip-".concat(eachId), className: "flex h-6 w-5 flex-shrink-0 items-center justify-center text-gray-400", style: { touchAction: "none" }, onPointerDown: function (e) { return _this.handleStopGripDown(e, eachId); }, onPointerMove: function (e) { return _this.handleStopGripMove(e, stopIds); }, onPointerUp: function () {
|
|
987
|
+
return _this.state.dragStopId && _this.handleDropStop();
|
|
988
|
+
}, onPointerCancel: function () {
|
|
989
|
+
return _this.setState({ dragStopId: "", dropBeforeStopId: null });
|
|
990
|
+
} },
|
|
991
|
+
react_1.default.createElement("svg", { viewBox: "0 0 20 20", fill: "currentColor", className: "h-4 w-4", "aria-hidden": true },
|
|
992
|
+
react_1.default.createElement("circle", { cx: "7", cy: "5", r: "1.5" }),
|
|
993
|
+
react_1.default.createElement("circle", { cx: "13", cy: "5", r: "1.5" }),
|
|
994
|
+
react_1.default.createElement("circle", { cx: "7", cy: "10", r: "1.5" }),
|
|
995
|
+
react_1.default.createElement("circle", { cx: "13", cy: "10", r: "1.5" }),
|
|
996
|
+
react_1.default.createElement("circle", { cx: "7", cy: "15", r: "1.5" }),
|
|
997
|
+
react_1.default.createElement("circle", { cx: "13", cy: "15", r: "1.5" })))),
|
|
998
|
+
react_1.default.createElement("span", { className: "w-5 flex-shrink-0 rounded-full bg-gray-700 text-center text-xs font-semibold text-white" }, index + 1),
|
|
999
|
+
react_1.default.createElement("span", { className: "min-w-0 flex-1 truncate" }, titles.get(eachId)),
|
|
1000
|
+
canPlan && (react_1.default.createElement("button", { type: "button", "aria-label": "Take off the route", "data-testid": "map-route-remove-".concat(eachId), className: "flex-shrink-0 text-gray-400 hover:text-red-500", onClick: function () { return _this.handleRemoveFromRoute(eachId); } },
|
|
1001
|
+
react_1.default.createElement(outline_1.XMarkIcon, { className: "h-4 w-4" })))))); }),
|
|
1002
|
+
_this.state.dragStopId &&
|
|
1003
|
+
_this.state.dropBeforeStopId === null &&
|
|
1004
|
+
renderDropLine(),
|
|
1005
|
+
route.end && renderEnd("E", route.end.label)));
|
|
1006
|
+
};
|
|
1007
|
+
// INFO: in a pin's popup while a route is picked, adds the pin to it as the
|
|
1008
|
+
// last stop
|
|
1009
|
+
_this.renderAddToRoute = function (markerId) {
|
|
1010
|
+
var route = _this.handleGetSelectedRoute();
|
|
1011
|
+
if (!route || !_this.props.onChangeRoute || route.stopIds.includes(markerId))
|
|
1012
|
+
return null;
|
|
1013
|
+
return (react_1.default.createElement("button", { type: "button", "data-testid": "map-route-add", className: "mt-3 w-full rounded-md border border-primary-500 px-3 py-1.5 text-sm font-medium text-primary-600 hover:bg-primary-50", onClick: function () { return _this.handleAddToRoute(markerId); } },
|
|
1014
|
+
"Add to ",
|
|
1015
|
+
route.label || route.id));
|
|
1016
|
+
};
|
|
692
1017
|
_this.renderColorLegend = function () {
|
|
693
1018
|
var markerColorMap = {};
|
|
694
1019
|
if (_this.props.markerList && _this.props.markerList.length > 0) {
|
|
@@ -775,7 +1100,9 @@ var MapView = /** @class */ (function (_super) {
|
|
|
775
1100
|
MapView.prototype.componentDidUpdate = function (prevProps) {
|
|
776
1101
|
var _a;
|
|
777
1102
|
if (JSON.stringify(prevProps.markerList) !==
|
|
778
|
-
JSON.stringify(this.props.markerList)
|
|
1103
|
+
JSON.stringify(this.props.markerList) ||
|
|
1104
|
+
JSON.stringify(prevProps.routeList) !==
|
|
1105
|
+
JSON.stringify(this.props.routeList)) {
|
|
779
1106
|
this.handleRenderMarkers();
|
|
780
1107
|
}
|
|
781
1108
|
if (JSON.stringify(prevProps.polygonList) !==
|
|
@@ -788,6 +1115,10 @@ var MapView = /** @class */ (function (_super) {
|
|
|
788
1115
|
}
|
|
789
1116
|
};
|
|
790
1117
|
MapView.prototype.componentWillUnmount = function () {
|
|
1118
|
+
this.routeLines.forEach(function (eachLine) { return eachLine.setMap(null); });
|
|
1119
|
+
this.routeLines = [];
|
|
1120
|
+
this.routeEndMarkers.forEach(function (eachMarker) { return eachMarker.setMap(null); });
|
|
1121
|
+
this.routeEndMarkers = [];
|
|
791
1122
|
if (this.mapInitRetryHandle) {
|
|
792
1123
|
clearTimeout(this.mapInitRetryHandle);
|
|
793
1124
|
this.mapInitRetryHandle = null;
|