mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Factor out control point location event behavior.
This commit is contained in:
parent
f0a30b5cb7
commit
6c388bd557
@ -4,6 +4,7 @@ import {
|
|||||||
useClearControlPointDestinationMutation,
|
useClearControlPointDestinationMutation,
|
||||||
useSetControlPointDestinationMutation,
|
useSetControlPointDestinationMutation,
|
||||||
} from "../../api/liberationApi";
|
} from "../../api/liberationApi";
|
||||||
|
import { makeLocationMarkerEventHandlers } from "./EventHandlers";
|
||||||
import {
|
import {
|
||||||
Icon,
|
Icon,
|
||||||
LatLng,
|
LatLng,
|
||||||
@ -35,14 +36,6 @@ function iconForControlPoint(cp: ControlPointModel) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function openInfoDialog(controlPoint: ControlPointModel) {
|
|
||||||
backend.post(`/qt/info/control-point/${controlPoint.id}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
function openNewPackageDialog(controlPoint: ControlPointModel) {
|
|
||||||
backend.post(`/qt/create-package/control-point/${controlPoint.id}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ControlPointProps {
|
interface ControlPointProps {
|
||||||
controlPoint: ControlPointModel;
|
controlPoint: ControlPointModel;
|
||||||
}
|
}
|
||||||
@ -147,6 +140,10 @@ function PrimaryMarker(props: ControlPointProps) {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const locationClickHandlers = makeLocationMarkerEventHandlers(
|
||||||
|
props.controlPoint
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Marker
|
<Marker
|
||||||
@ -167,7 +164,7 @@ function PrimaryMarker(props: ControlPointProps) {
|
|||||||
eventHandlers={{
|
eventHandlers={{
|
||||||
click: () => {
|
click: () => {
|
||||||
if (!hasDestination) {
|
if (!hasDestination) {
|
||||||
openInfoDialog(props.controlPoint);
|
locationClickHandlers.click();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
contextmenu: () => {
|
contextmenu: () => {
|
||||||
@ -176,7 +173,7 @@ function PrimaryMarker(props: ControlPointProps) {
|
|||||||
resetDestination();
|
resetDestination();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
openNewPackageDialog(props.controlPoint);
|
locationClickHandlers.contextmenu();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
drag: (event) => {
|
drag: (event) => {
|
||||||
@ -261,14 +258,7 @@ function SecondaryMarker(props: SecondaryMarkerProps) {
|
|||||||
// other markers are helpful so we want to keep them, but make sure the CP
|
// other markers are helpful so we want to keep them, but make sure the CP
|
||||||
// is always the clickable thing.
|
// is always the clickable thing.
|
||||||
zIndexOffset={1000}
|
zIndexOffset={1000}
|
||||||
eventHandlers={{
|
eventHandlers={makeLocationMarkerEventHandlers(props.controlPoint)}
|
||||||
click: () => {
|
|
||||||
openInfoDialog(props.controlPoint);
|
|
||||||
},
|
|
||||||
contextmenu: () => {
|
|
||||||
openNewPackageDialog(props.controlPoint);
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
<LocationTooltipText {...props} />
|
<LocationTooltipText {...props} />
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user