diff --git a/modules/modes/SelectMode.js b/modules/modes/SelectMode.js index fb6a0919c..82f600c46 100644 --- a/modules/modes/SelectMode.js +++ b/modules/modes/SelectMode.js @@ -9,6 +9,7 @@ import { uiDetectionInspector } from '../ui/detection_inspector.js'; import { uiKeepRightEditor } from '../ui/keepRight_editor.js'; import { uiNoteEditor } from '../ui/note_editor.js'; import { uiMapRouletteEditor } from '../ui/maproulette_editor.js'; +import { uiMapRouletteMenu } from '../ui/maproulette_menu.js'; const DEBUG = false; @@ -157,6 +158,7 @@ export class SelectMode extends AbstractMode { } else if (datum instanceof QAItem && datum.service === 'maproulette') { sidebarContent = uiMapRouletteEditor(context).error(datum); + uiMapRouletteMenu(context).error(datum); sidebarContent .on('change', () => { gfx.immediateRedraw(); // force a redraw (there is no history change that would otherwise do this) diff --git a/modules/ui/UiSidebar.js b/modules/ui/UiSidebar.js index a169219d4..934d909f5 100644 --- a/modules/ui/UiSidebar.js +++ b/modules/ui/UiSidebar.js @@ -10,6 +10,7 @@ import { UiInspector } from './UiInspector.js'; import { uiDetectionInspector } from './detection_inspector.js'; import { uiKeepRightEditor } from './keepRight_editor.js'; import { uiMapRouletteEditor } from './maproulette_editor.js'; +import { uiMapRouletteMenu } from './maproulette_menu.js'; import { uiOsmoseEditor } from './osmose_editor.js'; import { uiNoteEditor } from './note_editor.js'; import { UiRapidInspector } from './UiRapidInspector.js'; @@ -54,6 +55,7 @@ export class UiSidebar { this.Inspector = new UiInspector(context); this.KeepRightEditor = uiKeepRightEditor(context); this.MapRouletteEditor = uiMapRouletteEditor(context); + this.MapRouletteMenu= uiMapRouletteMenu(context); this.NoteEditor = uiNoteEditor(context); this.OsmoseEditor = uiOsmoseEditor(context); this.RapidInspector = new UiRapidInspector(context); @@ -268,6 +270,7 @@ export class UiSidebar { Component = this.OsmoseEditor; } else if (service.id === 'maproulette') { Component = this.MapRouletteEditor; + this.MapRouletteMenu.error(datum); } } @@ -553,6 +556,7 @@ export class UiSidebar { this.Inspector.entityIDs([]); this.KeepRightEditor.error(null); this.MapRouletteEditor.error(null); + this.MapRouletteMenu.error(null); this.NoteEditor.note(null); this.OsmoseEditor.error(null); this.RapidInspector.datum = null; diff --git a/modules/ui/maproulette_menu.js b/modules/ui/maproulette_menu.js index 204af7fb7..89385ee3f 100644 --- a/modules/ui/maproulette_menu.js +++ b/modules/ui/maproulette_menu.js @@ -85,11 +85,10 @@ export function uiMapRouletteMenu(context) { return; } _mapRouletteApiKey = apiKey; - console.log('MapRoulette API key retrieved:', _mapRouletteApiKey); - d.action(d3_event, d); // Call the action after retrieving the API key + d.action(d3_event, d, _qaItem); }); } else { - d.action(d3_event, d); + d.action(d3_event, d, _qaItem); } mapRouletteMenu.close(); }) @@ -102,7 +101,7 @@ export function uiMapRouletteMenu(context) { utilHighlightEntities(d.relatedEntityIds(), false, context); }); - buttonsEnter.append('div') + buttonsEnter.append('div') .attr('class', 'icon-wrap') .call(uiIcon('', 'operation')); @@ -177,16 +176,19 @@ export function uiMapRouletteMenu(context) { } } - function fixedIt(d3_event, d) { - if (_qaItem) { - _qaItem._status = 1; - _actionTaken = 'FIXED'; - submitTask(d3_event, _qaItem); - } else { + + function fixedIt(d3_event, d, _qaItem) { + if (!_qaItem) { console.error('No task selected'); + return; } + console.log('Current d in fixedIt:', d); // Debugging log + _qaItem._status = 1; // Update the status of the task + _actionTaken = 'FIXED'; // Set the action taken + submitTask(d3_event, _qaItem); // Submit the task with the updated status } + function cantComplete(d3_event, d) { if (_qaItem) { _qaItem._status = 6; @@ -217,38 +219,33 @@ export function uiMapRouletteMenu(context) { } } - function submitTask(d3_event, task) { + + function submitTask(d3_event, d) { + if (!d) { + console.error('No task to submit'); + return; + } const osm = context.services.osm; const userID = osm._userDetails.id; if (maproulette) { - console.log('task', task); - task.taskStatus = task._status; - task.mapRouletteApiKey = _mapRouletteApiKey; - // Check if the element exists and get its value, otherwise use an empty string - const commentInput = d3_select('.new-comment-input'); - task.comment = commentInput.empty() ? '' : commentInput.property('value').trim(); - // Ensure taskId is correctly set - if (!task.id) { - console.error('Task ID is missing'); - return; - } - task.taskId = task.id; - task.userId = userID; - maproulette.postUpdate(task, (err, item) => { + d.taskStatus = d._status; + d.mapRouletteApiKey = _mapRouletteApiKey; + d.comment = d3_select('.new-comment-input').property('value').trim(); + d.taskId = d.id; + d.userId = userID; + maproulette.postUpdate(d, (err, item) => { if (err) { console.error(err); // eslint-disable-line no-console return; } dispatch.call('change', item); - // Fly to a nearby task if the feature is enabled, after the update if (maproulette.nearbyTaskEnabled) { - maproulette.flyToNearbyTask(task); + maproulette.flyToNearbyTask(d); } }); } } - function getMapRouletteApiKey(context, callback) { const osm = context.services.osm; osm.loadMapRouletteKey((err, preferences) => { @@ -285,7 +282,6 @@ export function uiMapRouletteMenu(context) { mapRouletteMenu.error = function(val) { if (!arguments.length) return _qaItem; _qaItem = val; - console.log('Task selected:', _qaItem); _actionTaken = ''; return mapRouletteMenu; };