From ff4eb971accd2d04f26a4d2c04072015f23f7ee3 Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Thu, 7 May 2020 13:27:20 -0700 Subject: [PATCH] Fix various issues that made the walkthrough non-completable --- modules/behavior/select.js | 27 ++++++++++++--------------- modules/ui/intro/building.js | 14 +++++++------- modules/ui/intro/intro.js | 1 - modules/ui/intro/line.js | 2 +- modules/ui/intro/navigation.js | 12 ++++++------ modules/ui/intro/point.js | 10 +++++----- 6 files changed, 31 insertions(+), 35 deletions(-) diff --git a/modules/behavior/select.js b/modules/behavior/select.js index 9ee382ddb..667eb7619 100644 --- a/modules/behavior/select.js +++ b/modules/behavior/select.js @@ -14,8 +14,8 @@ import { utilFastMouse } from '../util/util'; export function behaviorSelect(context) { // legacy option to show menu on every click - var isShowAlways = +prefs('edit-menu-show-always') === 1; - var tolerance = 4; + var _alwaysShowMenu = +prefs('edit-menu-show-always') === 1; + var _tolerancePx = 4; var _lastMouse = null; var _showMenu = false; var _p1 = null; @@ -65,7 +65,7 @@ export function behaviorSelect(context) { d3_select(window) .on(_pointerPrefix + 'up.select', pointerup, true); - _showMenu = isShowAlways; + _showMenu = _alwaysShowMenu; } @@ -110,7 +110,7 @@ export function behaviorSelect(context) { var p2 = point(); var dist = geoVecLength(_p1, p2); _p1 = null; - if (dist > tolerance) return; + if (dist > _tolerancePx) return; var datum = d3_event.target.__data__ || (_lastMouse && _lastMouse.target.__data__); var isMultiselect = d3_event.shiftKey || context.surface().select('.lasso').node(); @@ -137,25 +137,22 @@ export function behaviorSelect(context) { context.selectedErrorID(null); if (!isMultiselect) { - if (selectedIDs.length > 1 && (_showMenu && !isShowAlways)) { + if (selectedIDs.length > 1 && (_showMenu && !_alwaysShowMenu)) { // multiple things already selected, just show the menu... mode.reselect().showMenu(); } else { - if (mode.id !== 'select' || !utilArrayIdentical(mode.selectedIDs(), [datum.id])) { - newMode = modeSelect(context, [datum.id]); - // select a single thing if it's not already selected - context.enter(newMode); - if (_showMenu) newMode.showMenu(); - } else { - mode.reselect(); - if (_showMenu) mode.showMenu(); - } + // always enter modeSelect even if the entity is already + // selected since listeners may expect `context.enter` events, + // e.g. in the walkthrough + newMode = modeSelect(context, [datum.id]); + context.enter(newMode); + if (_showMenu) newMode.showMenu(); } } else { if (selectedIDs.indexOf(datum.id) !== -1) { // clicked entity is already in the selectedIDs list.. - if (_showMenu && !isShowAlways) { + if (_showMenu && !_alwaysShowMenu) { // don't deselect clicked entity, just show the menu. mode.reselect().showMenu(); } else { diff --git a/modules/ui/intro/building.js b/modules/ui/intro/building.js index 7ed73d0f1..00f6a3ea8 100644 --- a/modules/ui/intro/building.js +++ b/modules/ui/intro/building.js @@ -343,7 +343,7 @@ export function uiIntroBuilding(context, reveal) { var node = selectMenuItem(context, 'orthogonalize').node(); if (!node) return; continueTo(clickSquare); - }, 300); // after menu visible + }, 50); // after menu visible }); context.map().on('move.intro drawn.intro', function() { @@ -386,7 +386,7 @@ export function uiIntroBuilding(context, reveal) { } }); - context.map().on('move.intro drawn.intro', function() { + context.map().on('move.intro', function() { var node = selectMenuItem(context, 'orthogonalize').node(); if (!wasChanged && !node) { return continueTo(rightClickHouse); } @@ -412,7 +412,7 @@ export function uiIntroBuilding(context, reveal) { function continueTo(nextStep) { context.on('enter.intro', null); - context.map().on('move.intro drawn.intro', null); + context.map().on('move.intro', null); context.history().on('change.intro', null); nextStep(); } @@ -661,7 +661,7 @@ export function uiIntroBuilding(context, reveal) { var node = selectMenuItem(context, 'circularize').node(); if (!node) return; continueTo(clickCircle); - }, 300); // after menu visible + }, 50); // after menu visible }); revealTank(tank, t('intro.buildings.rightclick_tank')); @@ -708,7 +708,7 @@ export function uiIntroBuilding(context, reveal) { } }); - context.map().on('move.intro drawn.intro', function() { + context.map().on('move.intro', function() { var node = selectMenuItem(context, 'circularize').node(); if (!wasChanged && !node) { return continueTo(rightClickTank); } @@ -724,7 +724,7 @@ export function uiIntroBuilding(context, reveal) { // Something changed. Wait for transition to complete and check undo annotation. timeout(function() { - if (context.history().undoAnnotation() === t('operations.circularize.annotation.area')) { + if (context.history().undoAnnotation() === t('operations.circularize.annotation.single')) { continueTo(play); } else { continueTo(retryClickCircle); @@ -734,7 +734,7 @@ export function uiIntroBuilding(context, reveal) { function continueTo(nextStep) { context.on('enter.intro', null); - context.map().on('move.intro drawn.intro', null); + context.map().on('move.intro', null); context.history().on('change.intro', null); nextStep(); } diff --git a/modules/ui/intro/intro.js b/modules/ui/intro/intro.js index 5994ad0e0..8e53a8fde 100644 --- a/modules/ui/intro/intro.js +++ b/modules/ui/intro/intro.js @@ -125,7 +125,6 @@ export function uiIntro(context) { let chapters = chapterFlow.map((chapter, i) => { let s = chapterUi[chapter](context, curtain.reveal) .on('done', () => { - presetManager.init(); // clear away "recent" presets buttons .filter(d => d.title === s.title) diff --git a/modules/ui/intro/line.js b/modules/ui/intro/line.js index 9696c2bcf..a296642f5 100644 --- a/modules/ui/intro/line.js +++ b/modules/ui/intro/line.js @@ -676,7 +676,7 @@ export function uiIntroLine(context, reveal) { var node = selectMenuItem(context, 'split').node(); if (!node) return; continueTo(splitIntersection); - }, 300); // after menu visible + }, 50); // after menu visible }); context.history().on('change.intro', function() { diff --git a/modules/ui/intro/navigation.js b/modules/ui/intro/navigation.js index 235ce9833..d34a3b69d 100644 --- a/modules/ui/intro/navigation.js +++ b/modules/ui/intro/navigation.js @@ -295,6 +295,11 @@ export function uiIntroNavigation(context, reveal) { var onClick = function() { continueTo(fieldsTownHall); }; + reveal('.entity-editor-pane .section-feature-type', + t('intro.navigation.preset_townhall', { preset: preset.name() }), + { buttonText: t('intro.ok'), buttonCallback: onClick } + ); + context.on('exit.intro', function() { continueTo(clickTownHall); }); @@ -305,11 +310,6 @@ export function uiIntroNavigation(context, reveal) { } }); - reveal('.entity-editor .preset-list-item', - t('intro.navigation.preset_townhall', { preset: preset.name() }), - { buttonText: t('intro.ok'), buttonCallback: onClick } - ); - function continueTo(nextStep) { context.on('exit.intro', null); context.history().on('change.intro', null); @@ -329,7 +329,7 @@ export function uiIntroNavigation(context, reveal) { var onClick = function() { continueTo(closeTownHall); }; - reveal('.inspector-body .preset-editor', + reveal('.entity-editor-pane .section-preset-fields', t('intro.navigation.fields_townhall'), { buttonText: t('intro.ok'), buttonCallback: onClick } ); diff --git a/modules/ui/intro/point.js b/modules/ui/intro/point.js index 5cf276787..a5ddcae03 100644 --- a/modules/ui/intro/point.js +++ b/modules/ui/intro/point.js @@ -388,7 +388,7 @@ export function uiIntroPoint(context, reveal) { reveal(box, t('intro.points.rightclick'), { duration: 600 }); timeout(function() { - context.map().on('move.intro drawn.intro', function() { + context.map().on('move.intro', function() { var entity = context.hasEntity(_pointID); if (!entity) return chapter.restart(); var box = pointBox(entity.loc, context); @@ -405,12 +405,12 @@ export function uiIntroPoint(context, reveal) { var node = selectMenuItem(context, 'delete').node(); if (!node) return; continueTo(enterDelete); - }, 300); // after menu visible + }, 50); // after menu visible }); function continueTo(nextStep) { context.on('enter.intro', null); - context.map().on('move.intro drawn.intro', null); + context.map().on('move.intro', null); nextStep(); } } @@ -429,7 +429,7 @@ export function uiIntroPoint(context, reveal) { ); timeout(function() { - context.map().on('move.intro drawn.intro', function() { + context.map().on('move.intro', function() { revealEditMenu(entity.loc, t('intro.points.delete', { button: icon('#iD-operation-delete', 'pre-text') }), { duration: 0} @@ -450,7 +450,7 @@ export function uiIntroPoint(context, reveal) { }); function continueTo(nextStep) { - context.map().on('move.intro drawn.intro', null); + context.map().on('move.intro', null); context.history().on('change.intro', null); context.on('exit.intro', null); nextStep();