Skip to content

Commit 63afc0d

Browse files
authored
add priority color outline to task markers (#2756)
* add priority color outline to task markers * run formatting
1 parent 47f4563 commit 63afc0d

File tree

5 files changed

+52
-4
lines changed

5 files changed

+52
-4
lines changed

src/components/HOCs/WithTaskClusterMarkers/WithTaskClusterMarkers.jsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@ export const WithTaskClusterMarkers = function (WrappedComponent) {
2020
}
2121

2222
componentDidUpdate(prevProps) {
23+
const showPriorityColors = this.props.user?.settings?.showPriorityMarkerColors ?? false;
24+
const prevShowPriorityColors = prevProps.user?.settings?.showPriorityMarkerColors ?? false;
25+
2326
if (
2427
!_isEqual(this.props.taskClusters, prevProps.taskClusters) ||
2528
!_isEqual(this.props.selectedTasks, prevProps.selectedTasks) ||
26-
!_isEqual(this.props.selectedClusters, prevProps.selectedClusters)
29+
!_isEqual(this.props.selectedClusters, prevProps.selectedClusters) ||
30+
showPriorityColors !== prevShowPriorityColors
2731
) {
2832
this.updateMapMarkers();
2933
}
@@ -69,12 +73,15 @@ export const WithTaskClusterMarkers = function (WrappedComponent) {
6973
tasksToDeselect.push({ id: clusterId });
7074
}
7175

76+
const showPriorityColors = this.props.user?.settings?.showPriorityMarkerColors ?? false;
77+
7278
return AsMappableCluster(cluster).mapMarker(
7379
this.props.monochromaticClusters,
7480
this.props.selectedTasks,
7581
this.props.highlightPrimaryTask,
7682
this.props.selectedClusters,
7783
bundleConflict,
84+
showPriorityColors,
7885
);
7986
});
8087

src/components/TaskPane/TaskNearbyList/TaskNearbyMap.jsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import _map from "lodash/map";
99
import { AttributionControl, MapContainer, Marker, Tooltip, useMap } from "react-leaflet";
1010
import resolveConfig from "tailwindcss/resolveConfig";
1111
import AsMappableTask from "../../../interactions/Task/AsMappableTask";
12-
import { messagesByPriority } from "../../../services/Task/TaskPriority/TaskPriority";
12+
import {
13+
TaskPriorityColors,
14+
messagesByPriority,
15+
} from "../../../services/Task/TaskPriority/TaskPriority";
1316
import { TaskStatusColors, messagesByStatus } from "../../../services/Task/TaskStatus/TaskStatus";
1417
import { buildLayerSources } from "../../../services/VisibleLayer/LayerSources";
1518
import tailwindConfig from "../../../tailwind.config.js";
@@ -166,14 +169,19 @@ export class TaskNearbyMap extends Component {
166169
const hasTaskMarkers = (this.props.taskMarkers?.length ?? 0) > 0;
167170
let coloredMarkers = null;
168171
if (hasTaskMarkers) {
172+
const showPriorityColors = this.props.user?.settings?.showPriorityMarkerColors ?? false;
173+
169174
coloredMarkers = _map(this.props.taskMarkers, (marker) => {
170175
const isRequestedMarker = marker.options.taskId === this.props.requestedNextTask;
171176
const markerData = _cloneDeep(marker);
172177
markerData.options.title = `Task ${marker.options.taskId}`;
178+
const priorityColor = showPriorityColors
179+
? TaskPriorityColors[marker.options?.priority ?? 0] || colors["grey-leaflet"]
180+
: colors["grey-leaflet"];
173181
const markerStyle = {
174182
fill: TaskStatusColors[marker.options?.status ?? 0],
175-
stroke: isRequestedMarker ? colors.yellow : colors["grey-leaflet"],
176-
strokeWidth: isRequestedMarker ? 2 : 0.5,
183+
stroke: isRequestedMarker ? colors.yellow : priorityColor,
184+
strokeWidth: isRequestedMarker ? 2 : showPriorityColors ? 1.5 : 0.5,
177185
};
178186

179187
return (

src/interactions/TaskCluster/AsMappableCluster.jsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import _isEmpty from "lodash/isEmpty";
77
import _map from "lodash/map";
88
import _merge from "lodash/merge";
99
import resolveConfig from "tailwindcss/resolveConfig";
10+
import { TaskPriorityColors } from "../../services/Task/TaskPriority/TaskPriority";
1011
import { TaskStatusColors } from "../../services/Task/TaskStatus/TaskStatus";
1112
import tailwindConfig from "../../tailwind.config.js";
1213

@@ -62,6 +63,7 @@ export class AsMappableCluster {
6263
highlightPrimaryTask,
6364
selectedClusters = null,
6465
bundleConflict,
66+
showPriorityColors = false,
6567
) {
6668
return {
6769
position: [this.point.lat, this.point.lng],
@@ -79,6 +81,7 @@ export class AsMappableCluster {
7981
highlightPrimaryTask,
8082
selectedClusters,
8183
bundleConflict,
84+
showPriorityColors,
8285
),
8386
zIndexOffset: bundleConflict ? -10 : 0,
8487
};
@@ -94,6 +97,7 @@ export class AsMappableCluster {
9497
highlightPrimaryTask = false,
9598
selectedClusters = null,
9699
bundleConflict = false,
100+
showPriorityColors = false,
97101
) {
98102
const count =
99103
typeof this.rawData.getChildCount === "function"
@@ -150,6 +154,13 @@ export class AsMappableCluster {
150154

151155
let icon = _cloneDeep(statusIcons[markerData.taskStatus] || statusIcons[0]);
152156

157+
// Set stroke color based on priority if enabled
158+
if (showPriorityColors) {
159+
const priorityColor = TaskPriorityColors[markerData.taskPriority] || colors["grey-leaflet"];
160+
icon.options.style.stroke = priorityColor;
161+
icon.options.style.strokeWidth = 1;
162+
}
163+
153164
if (bundleConflict) {
154165
const red = parseInt(icon.options.style.fill.slice(1, 3), 16);
155166
const green = parseInt(icon.options.style.fill.slice(3, 5), 16);

src/pages/Profile/Messages.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,4 +298,15 @@ export default defineMessages({
298298
id: "Profile.form.mandatory.label",
299299
defaultMessage: "Mandatory",
300300
},
301+
302+
showPriorityMarkerColorsLabel: {
303+
id: "Profile.form.showPriorityMarkerColors.label",
304+
defaultMessage: "Show Priority Colors on Map Markers",
305+
},
306+
307+
showPriorityMarkerColorsDescription: {
308+
id: "Profile.form.showPriorityMarkerColors.description",
309+
defaultMessage:
310+
"Display task priority as colored outlines on map markers (high priority = red, medium = orange, low = teal). When disabled, markers use a standard grey outline.",
311+
},
301312
});

src/pages/Profile/UserSettings/UserSettingsSchema.jsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ export const jsSchema = (intl, user, editor) => {
135135
default: false,
136136
enumNames: [intl.formatMessage(messages.yesLabel), intl.formatMessage(messages.noLabel)],
137137
},
138+
showPriorityMarkerColors: {
139+
title: intl.formatMessage(messages.showPriorityMarkerColorsLabel),
140+
type: "boolean",
141+
default: false,
142+
enumNames: [intl.formatMessage(messages.yesLabel), intl.formatMessage(messages.noLabel)],
143+
},
138144
},
139145
};
140146

@@ -229,6 +235,10 @@ export const uiSchema = (intl, user, editor) => {
229235
"ui:widget": "radio",
230236
"ui:help": intl.formatMessage(messages.disableTaskConfirmDescription),
231237
},
238+
showPriorityMarkerColors: {
239+
"ui:widget": "radio",
240+
"ui:help": intl.formatMessage(messages.showPriorityMarkerColorsDescription),
241+
},
232242
"ui:order": [
233243
"locale",
234244
"allowFollowing",
@@ -238,6 +248,7 @@ export const uiSchema = (intl, user, editor) => {
238248
"isReviewer",
239249
"customBasemaps",
240250
"seeTagFixSuggestions",
251+
"showPriorityMarkerColors",
241252
"disableTaskConfirm",
242253
],
243254
};

0 commit comments

Comments
 (0)