From 8671669898f0cda2ee74ae62b297fa303cbc23b8 Mon Sep 17 00:00:00 2001 From: CollinBeczak Date: Tue, 18 Feb 2025 15:09:04 -0600 Subject: [PATCH] format bundling widget --- .../TaskBundleWidget/TaskBundleWidget.jsx | 156 +++++------------- 1 file changed, 43 insertions(+), 113 deletions(-) diff --git a/src/components/Widgets/TaskBundleWidget/TaskBundleWidget.jsx b/src/components/Widgets/TaskBundleWidget/TaskBundleWidget.jsx index 342030c69..276d38c69 100644 --- a/src/components/Widgets/TaskBundleWidget/TaskBundleWidget.jsx +++ b/src/components/Widgets/TaskBundleWidget/TaskBundleWidget.jsx @@ -14,10 +14,7 @@ import AsMappableTask from "../../../interactions/Task/AsMappableTask"; import { toLatLngBounds } from "../../../services/MapBounds/MapBounds"; import { buildSearchURL } from "../../../services/SearchCriteria/SearchCriteria"; import { TaskAction } from "../../../services/Task/TaskAction/TaskAction"; -import { - WidgetDataTarget, - registerWidgetType, -} from "../../../services/Widget/Widget"; +import { WidgetDataTarget, registerWidgetType } from "../../../services/Widget/Widget"; import BusySpinner from "../../BusySpinner/BusySpinner"; import Dropdown from "../../Dropdown/Dropdown"; import MapPane from "../../EnhancedMap/MapPane/MapPane"; @@ -44,11 +41,7 @@ import TaskStatusFilter from "../../TaskFilters/TaskStatusFilter"; import messages from "./Messages"; import TaskMarkerContent from "./TaskMarkerContent"; -const VALID_STATUS_KEYS = [ - TaskAction.available, - TaskAction.skipped, - TaskAction.tooHard, -]; +const VALID_STATUS_KEYS = [TaskAction.available, TaskAction.skipped, TaskAction.tooHard]; const descriptor = { widgetKey: "TaskBundleWidget", @@ -65,7 +58,7 @@ const ClusterMap = WithChallengeTaskClusters( true, false, false, - false + false, ); const shortcutGroup = "taskEditing"; @@ -77,12 +70,8 @@ export default class TaskBundleWidget extends Component { }; handleKeyboardShortcuts = (event) => { - const { - activeKeyboardShortcuts, - textInputActive, - taskReadOnly, - keyboardShortcutGroups, - } = this.props; + const { activeKeyboardShortcuts, textInputActive, taskReadOnly, keyboardShortcutGroups } = + this.props; // Return early if any of the following conditions are met: // - Shortcut group is not active @@ -118,10 +107,7 @@ export default class TaskBundleWidget extends Component { type: "Feature", geometry: { type: "Point", - coordinates: [ - task.location.coordinates[0], - task.location.coordinates[1], - ], + coordinates: [task.location.coordinates[0], task.location.coordinates[1]], }, })), }); @@ -141,10 +127,7 @@ export default class TaskBundleWidget extends Component { initializeWebsocketSubscription(prevProps = {}) { const challengeId = this.props.task?.parent?.id; - if ( - Number.isFinite(challengeId) && - challengeId !== prevProps.task?.parent?.id - ) { + if (Number.isFinite(challengeId) && challengeId !== prevProps.task?.parent?.id) { this.props.subscribeToChallengeTaskMessages(challengeId); } } @@ -159,11 +142,7 @@ export default class TaskBundleWidget extends Component { const selectedArray = Array.from(selectedTasks.selected.values()); const isCooperative = AsCooperativeWork(task).isCooperative(); - if ( - selectedArray.some( - (item) => AsCooperativeWork(item).isCooperative() !== isCooperative - ) - ) { + if (selectedArray.some((item) => AsCooperativeWork(item).isCooperative() !== isCooperative)) { this.setState((prevState) => ({ errors: new Set([...prevState.errors, "bundleTypeMismatchError"]), })); @@ -222,7 +201,7 @@ export default class TaskBundleWidget extends Component { } const nearbyBounds = bbox( - featureCollection(taskList.map((t) => point([t.point.lng, t.point.lat]))) + featureCollection(taskList.map((t) => point([t.point.lng, t.point.lat]))), ); // Preserve existing zoom or default to 18 @@ -260,7 +239,7 @@ export default class TaskBundleWidget extends Component { // Then add any additional bundle tasks if (this.props.taskBundle?.tasks) { const additionalTasks = this.props.taskBundle.tasks.filter( - (t) => t.id !== this.props.task?.id + (t) => t.id !== this.props.task?.id, ); if (additionalTasks.length > 0) { this.props.selectTasks(additionalTasks); @@ -274,8 +253,7 @@ export default class TaskBundleWidget extends Component { async componentDidUpdate(prevProps) { const taskChanged = this.props.task?.id !== prevProps.task?.id; - const bundleChanged = - this.props.taskBundle?.bundleId !== prevProps.taskBundle?.bundleId; + const bundleChanged = this.props.taskBundle?.bundleId !== prevProps.taskBundle?.bundleId; if (taskChanged || bundleChanged) { await this.props.resetSelectedTasks(); @@ -286,7 +264,7 @@ export default class TaskBundleWidget extends Component { // Then add any additional bundle tasks if (this.props.taskBundle?.tasks) { const additionalTasks = this.props.taskBundle.tasks.filter( - (t) => t.id !== this.props.task?.id + (t) => t.id !== this.props.task?.id, ); if (additionalTasks.length > 0) { this.props.selectTasks(additionalTasks); @@ -327,11 +305,8 @@ export default class TaskBundleWidget extends Component { this.setState({ shortcutActive: true }); this.props.activateKeyboardShortcut( shortcutGroup, - _pick( - this.props.keyboardShortcutGroups.taskEditing, - "completeTogether" - ), - this.handleKeyboardShortcuts + _pick(this.props.keyboardShortcutGroups.taskEditing, "completeTogether"), + this.handleKeyboardShortcuts, ); } else if ( this.state.shortcutActive === true && @@ -341,7 +316,7 @@ export default class TaskBundleWidget extends Component { this.props.deactivateKeyboardShortcut( shortcutGroup, "completeTogether", - this.handleKeyboardShortcuts + this.handleKeyboardShortcuts, ); } } @@ -356,7 +331,7 @@ export default class TaskBundleWidget extends Component { this.props.deactivateKeyboardShortcut( shortcutGroup, "completeTogether", - this.handleKeyboardShortcuts + this.handleKeyboardShortcuts, ); } @@ -395,13 +370,11 @@ const calculateTasksInChallenge = (props) => { }; const ActiveBundle = (props) => { - const { task, taskBundle, bundleEditsDisabled, initialBundle, widgetLayout } = - props; + const { task, taskBundle, bundleEditsDisabled, initialBundle, widgetLayout } = props; const disabled = props.bundleEditsDisabled || (props.initialBundle && - props.initialBundle?.taskIds?.sort() === - props.taskBundle?.taskIds?.sort()); + props.initialBundle?.taskIds?.sort() === props.taskBundle?.taskIds?.sort()); const showMarkerPopup = (markerData) => { return ( @@ -431,13 +404,10 @@ const ActiveBundle = (props) => { type: "Feature", geometry: { type: "Point", - coordinates: [ - task.location.coordinates[0], - task.location.coordinates[1], - ], + coordinates: [task.location.coordinates[0], task.location.coordinates[1]], }, })), - }) + }), ); const map = ( @@ -457,14 +427,8 @@ const ActiveBundle = (props) => { {
{errorType === "lockError" && props.failedLocks && ( - - ({props.failedLocks.join(", ")}) - + ({props.failedLocks.join(", ")}) )}
))} @@ -512,11 +474,7 @@ const ActiveBundle = (props) => { onClick={() => props.setBundledOnly(!props.bundledOnly)} > {initialBundle && ( @@ -569,9 +527,7 @@ const ActiveBundle = (props) => {
{} @@ -626,9 +582,7 @@ const BuildBundle = (props) => { const totalTaskCount = taskInfo?.totalCount || taskInfo?.tasks?.length; const showBundleButton = - !taskReadOnly && - props.selectedTaskCount(totalTaskCount) > 1 && - !bundleEditsDisabled; + !taskReadOnly && props.selectedTaskCount(totalTaskCount) > 1 && !bundleEditsDisabled; const isTooManyTasks = selectedTasks.selected.size > 50; const bundleButton = showBundleButton ? ( @@ -639,9 +593,7 @@ const BuildBundle = (props) => { disabled={isTooManyTasks} onClick={props.createBundle} > - + ) : null; @@ -649,16 +601,10 @@ const BuildBundle = (props) => { return (
- +
); @@ -707,9 +653,7 @@ const BuildBundle = (props) => {
{errorType === "lockError" && props.failedLocks && ( - - ({props.failedLocks.join(", ")}) - + ({props.failedLocks.join(", ")}) )}
))} @@ -719,9 +663,7 @@ const BuildBundle = (props) => { {props.initialBundle && (