From 5acad221a9dee078cc13a9210680d2346ccb1d4b Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Mon, 17 Apr 2017 10:40:24 -0400 Subject: [PATCH] Catch a few more conditions where the user changed tutorial data --- modules/ui/intro/area.js | 37 ++++++++++++++++++++++++++++--------- modules/ui/intro/point.js | 12 ++++++++++++ 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/modules/ui/intro/area.js b/modules/ui/intro/area.js index 2cb2b48f8..89cbe3550 100644 --- a/modules/ui/intro/area.js +++ b/modules/ui/intro/area.js @@ -216,6 +216,13 @@ export function uiIntroArea(context, reveal) { // reset pane, in case user somehow happened to change it.. d3.select('.inspector-wrap .panewrap').style('right', '0%'); + // It's possible for the user to add a description in a previous step.. + // If they did this already, just continue to next step. + var entity = context.entity(areaId); + if (entity.tags.description) { + return continueTo(play); + } + reveal('.more-fields .combobox-input', t('intro.areas.add_field'), { duration: 300 } @@ -248,13 +255,15 @@ export function uiIntroArea(context, reveal) { return searchPresets(); } - reveal('div.combobox', - t('intro.areas.choose_field', { field: descriptionField.label() }), - { duration: 300 } - ); - - d3.select('div.combobox') - .on('click.intro', function() { + // Make sure combobox is ready.. + if (d3.select('div.combobox').empty()) { + return continueTo(clickAddField); + } + // Watch for the combobox to go away.. + var watcher; + watcher = window.setInterval(function() { + if (d3.select('div.combobox').empty()) { + window.clearInterval(watcher); timeout(function() { if (d3.select('.form-field-description').empty()) { continueTo(retryChooseDescription); @@ -262,14 +271,20 @@ export function uiIntroArea(context, reveal) { continueTo(describePlayground); } }, 300); // after description field added. - }); + } + }, 300); + + reveal('div.combobox', + t('intro.areas.choose_field', { field: descriptionField.label() }), + { duration: 300 } + ); context.on('exit.intro', function() { return continueTo(searchPresets); }); function continueTo(nextStep) { - d3.select('div.combobox').on('click.intro', null); + if (watcher) window.clearInterval(watcher); context.on('exit.intro', null); nextStep(); } @@ -288,6 +303,10 @@ export function uiIntroArea(context, reveal) { // reset pane, in case user happened to change it.. d3.select('.inspector-wrap .panewrap').style('right', '0%'); + if (d3.select('.form-field-description').empty()) { + return continueTo(retryChooseDescription); + } + context.on('exit.intro', function() { continueTo(play); }); diff --git a/modules/ui/intro/point.js b/modules/ui/intro/point.js index 7e39d81a5..2df45c364 100644 --- a/modules/ui/intro/point.js +++ b/modules/ui/intro/point.js @@ -1,5 +1,6 @@ import * as d3 from 'd3'; import { t, textDirection } from '../../util/locale'; +import { actionChangePreset } from '../../actions'; import { modeBrowse, modeSelect } from '../../modes'; import { utilRebind } from '../../util/rebind'; import { icon, pointBox, pad, selectMenuItem, transitionTime } from './helper'; @@ -187,6 +188,13 @@ export function uiIntroPoint(context, reveal) { // reset pane, in case user happened to change it.. d3.select('.inspector-wrap .panewrap').style('right', '0%'); + // It's possible for the user to add a name in a previous step.. + // If they did this already, just continue to next step. + var entity = context.entity(pointId); + if (entity.tags.name) { + return continueTo(addCloseEditor); + } + timeout(function() { reveal('.entity-editor-pane', t('intro.points.add_name'), { tooltipClass: 'intro-points-describe' } @@ -237,6 +245,10 @@ export function uiIntroPoint(context, reveal) { var entity = context.hasEntity(pointId); if (!entity) return chapter.restart(); + // make sure it's still a cafe, in case user somehow changed it.. + var oldPreset = context.presets().match(entity, context.graph()); + context.replace(actionChangePreset(pointId, oldPreset, cafePreset)); + context.enter(modeBrowse(context)); var msec = transitionTime(entity.loc, context.map().center());