diff --git a/src/components/drawing-selector/DrawingSelector.tsx b/src/components/drawing-selector/DrawingSelector.tsx
index 06fe127..d37b26f 100644
--- a/src/components/drawing-selector/DrawingSelector.tsx
+++ b/src/components/drawing-selector/DrawingSelector.tsx
@@ -13,17 +13,21 @@ import { currentGpxId } from '../gpx-dialog';
const id = getUri('drawingSelections', undefined);
-type SelectionType = 'ALL' | 'NONE' | 'CURRENT';
+type CompleteSelectionType = 'ALL' | 'NONE' | 'CURRENT';
+
+type RestrictedSelectionType = 'ALL' | 'NONE';
type DrawingSelections = {
- gpxSelection: SelectionType;
- trkSelection: SelectionType;
- wptSelection: SelectionType;
+ gpxSelection: CompleteSelectionType;
+ trkSelection: RestrictedSelectionType;
+ rteSelection: RestrictedSelectionType;
+ wptSelection: RestrictedSelectionType;
};
const defaultDrawingSelections: DrawingSelections = {
gpxSelection: 'ALL',
trkSelection: 'ALL',
+ rteSelection: 'ALL',
wptSelection: 'ALL',
};
@@ -62,19 +66,27 @@ const AllNoneCurrent: Component<{}> = (props) => {
);
};
+const AllNone: Component<{}> = (props) => {
+ return (
+ <>
+ }
+ label='All'
+ >
+ }
+ label='None'
+ >
+ >
+ );
+};
+
const gpxSelection = () => drawingSelections().gpxSelection;
-export const mustBeDrawn = (feature: Feature) => {
+const gpxMustBeDrawn = (feature: Feature) => {
const id = feature.getId() as String;
- const type = feature.get('type');
- console.log({
- caller: 'DrawingSelector / mustBeDrawn',
- feature,
- type,
- id,
- currentGpxId: currentGpxId(),
- gpxSelection: gpxSelection(),
- });
if (gpxSelection() === 'ALL') {
return true;
}
@@ -84,6 +96,28 @@ export const mustBeDrawn = (feature: Feature) => {
return false;
};
+const typeMustBeDrawn = (feature: Feature) => {
+ const type = feature.get('type') as String;
+ if (type.startsWith('trk')) {
+ return drawingSelections().trkSelection !== 'NONE';
+ }
+ if (type === 'wpt') {
+ return drawingSelections().wptSelection !== 'NONE';
+ }
+ if (type === 'rte') {
+ return drawingSelections().rteSelection !== 'NONE';
+ }
+ return true;
+};
+
+export const mustBeDrawn = (feature: Feature) => {
+ console.log({
+ caller: 'DrawingSelector / mustBeDrawn',
+ feature,
+ });
+ return gpxMustBeDrawn(feature) && typeMustBeDrawn(feature);
+};
+
const handleGpxSelectionChange = (ev: any) => {
const value = ev.target.value;
console.log({
@@ -99,6 +133,51 @@ const handleGpxSelectionChange = (ev: any) => {
});
};
+const handleTrkSelectionChange = (ev: any) => {
+ const value = ev.target.value;
+ console.log({
+ caller: 'DrawingSelector / handleTrkSelectionChange',
+ ev,
+ value,
+ });
+ const newDrawingSelections = drawingSelections();
+ newDrawingSelections.trkSelection = value;
+ dispatch({
+ action: 'putDrawingSelections',
+ params: { id, drawingSelections: newDrawingSelections },
+ });
+};
+
+const handleRteSelectionChange = (ev: any) => {
+ const value = ev.target.value;
+ console.log({
+ caller: 'DrawingSelector / handleRteSelectionChange',
+ ev,
+ value,
+ });
+ const newDrawingSelections = drawingSelections();
+ newDrawingSelections.rteSelection = value;
+ dispatch({
+ action: 'putDrawingSelections',
+ params: { id, drawingSelections: newDrawingSelections },
+ });
+};
+
+const handleWptSelectionChange = (ev: any) => {
+ const value = ev.target.value;
+ console.log({
+ caller: 'DrawingSelector / handleWptSelectionChange',
+ ev,
+ value,
+ });
+ const newDrawingSelections = drawingSelections();
+ newDrawingSelections.wptSelection = value;
+ dispatch({
+ action: 'putDrawingSelections',
+ params: { id, drawingSelections: newDrawingSelections },
+ });
+};
+
const DrawingSelector: Component<{}> = (props) => {
return (
= (props) => {
>
+ Tracks
+
+
+
+ Routes
+
+
+ {' '}
+ Waypoints
+
+
+
>
}
subTree={undefined}