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,
|
||||
useSetControlPointDestinationMutation,
|
||||
} from "../../api/liberationApi";
|
||||
import { makeLocationMarkerEventHandlers } from "./EventHandlers";
|
||||
import {
|
||||
Icon,
|
||||
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 {
|
||||
controlPoint: ControlPointModel;
|
||||
}
|
||||
@ -147,6 +140,10 @@ function PrimaryMarker(props: ControlPointProps) {
|
||||
);
|
||||
});
|
||||
|
||||
const locationClickHandlers = makeLocationMarkerEventHandlers(
|
||||
props.controlPoint
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Marker
|
||||
@ -167,7 +164,7 @@ function PrimaryMarker(props: ControlPointProps) {
|
||||
eventHandlers={{
|
||||
click: () => {
|
||||
if (!hasDestination) {
|
||||
openInfoDialog(props.controlPoint);
|
||||
locationClickHandlers.click();
|
||||
}
|
||||
},
|
||||
contextmenu: () => {
|
||||
@ -176,7 +173,7 @@ function PrimaryMarker(props: ControlPointProps) {
|
||||
resetDestination();
|
||||
});
|
||||
} else {
|
||||
openNewPackageDialog(props.controlPoint);
|
||||
locationClickHandlers.contextmenu();
|
||||
}
|
||||
},
|
||||
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
|
||||
// is always the clickable thing.
|
||||
zIndexOffset={1000}
|
||||
eventHandlers={{
|
||||
click: () => {
|
||||
openInfoDialog(props.controlPoint);
|
||||
},
|
||||
contextmenu: () => {
|
||||
openNewPackageDialog(props.controlPoint);
|
||||
},
|
||||
}}
|
||||
eventHandlers={makeLocationMarkerEventHandlers(props.controlPoint)}
|
||||
>
|
||||
<Tooltip>
|
||||
<LocationTooltipText {...props} />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user