From 1faa6ad83964e25df2ec2fb42104e51b8a7ab5d3 Mon Sep 17 00:00:00 2001 From: Brian Hatchl Date: Wed, 20 Feb 2019 15:23:58 -0500 Subject: [PATCH 01/17] Favorite preset --- css/55_cursors.css | 1 + css/80_app.css | 22 ++++++++++- data/core.yaml | 2 + dist/locales/en.json | 13 ++---- modules/behavior/draw_way.js | 2 +- modules/core/context.js | 33 +++++++++++++++- modules/modes/add_area.js | 11 +++--- modules/modes/add_line.js | 15 ++++--- modules/modes/add_point.js | 9 +++-- modules/modes/draw_area.js | 4 +- modules/modes/draw_line.js | 4 +- modules/operations/continue.js | 2 +- modules/ui/entity_editor.js | 8 ++++ modules/ui/modes.js | 37 ++++++++++++++++- modules/ui/preset_favorite.js | 57 +++++++++++++++++++++++++++ svg/iD-sprite/icons/icon-favorite.svg | 6 +++ 16 files changed, 193 insertions(+), 33 deletions(-) create mode 100644 modules/ui/preset_favorite.js create mode 100644 svg/iD-sprite/icons/icon-favorite.svg diff --git a/css/55_cursors.css b/css/55_cursors.css index 1a4c8cf7f..70edc9c55 100644 --- a/css/55_cursors.css +++ b/css/55_cursors.css @@ -54,6 +54,7 @@ cursor: url(img/cursor-select-remove.png), pointer; /* FF */ } +[class*=" mode-add-preset-"] #map, .mode-draw-line #map, .mode-draw-area #map, .mode-add-line #map, diff --git a/css/80_app.css b/css/80_app.css index 265b21f9d..f80d96425 100644 --- a/css/80_app.css +++ b/css/80_app.css @@ -1150,28 +1150,47 @@ a.hide-toggle { background-color: #ececec; } +.preset-list-item button.preset-favorite-button, .preset-list-item button.tag-reference-button { height: 100%; border: 1px solid #ccc; flex: 32px; background: #f6f6f6; } +[dir='ltr'] .preset-list-item button.preset-favorite-button, [dir='ltr'] .preset-list-item button.tag-reference-button { border-left: none; - border-radius: 0 4px 4px 0; + border-radius: 0; } +[dir='rtl'] .preset-list-item button.preset-favorite-button, [dir='rtl'] .preset-list-item button.tag-reference-button { border-right: none; + border-radius: 0; +} +[dir='ltr'] .preset-list-item button:last-child { + border-radius: 0 4px 4px 0; +} +[dir='rtl'] .preset-list-item button:last-child { border-radius: 4px 0 0 4px; } +.preset-list-item button.preset-favorite-button:hover, .preset-list-item button.tag-reference-button:hover { background: #f1f1f1; } +.preset-list-item button.preset-favorite-button .icon, .preset-list-item button.tag-reference-button .icon { opacity: .5; } +.preset-list-item button.preset-favorite-button .icon { + fill-opacity: 0; + stroke-width: 1.6; +} +.preset-list-item button.preset-favorite-button.active .icon { + fill-opacity: inherit; +} + img.tag-reference-wiki-image { float: right; width: 33.3333%; @@ -2474,6 +2493,7 @@ input.key-trap { /* hide and remove from layout */ .inspector-hidden, +.inspector-hover .preset-list-button-wrap .preset-favorite-button, .inspector-hover .preset-list-button-wrap .tag-reference-button, .inspector-hover label input[type="checkbox"], .inspector-hover label input[type="radio"], diff --git a/data/core.yaml b/data/core.yaml index b2011a69d..55b96dc44 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -7,6 +7,7 @@ en: zoom_to: zoom to copy: copy open_wikidata: open on wikidata.org + favorite: add to favorites modes: add_area: title: Area @@ -40,6 +41,7 @@ en: vertex: Added a node to a way. relation: Added a relation. note: Added a note. + title: Add start: annotation: line: Started a line. diff --git a/dist/locales/en.json b/dist/locales/en.json index 9aca0b295..2f24a2eeb 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -7,7 +7,8 @@ "undo": "undo", "zoom_to": "zoom to", "copy": "copy", - "open_wikidata": "open on wikidata.org" + "open_wikidata": "open on wikidata.org", + "favorite": "add to favorites" }, "modes": { "add_area": { @@ -51,7 +52,8 @@ "vertex": "Added a node to a way.", "relation": "Added a relation.", "note": "Added a note." - } + }, + "title": "Add" }, "start": { "annotation": { @@ -8370,13 +8372,6 @@ "description": "Japan GSI ortho Imagery. Usually better than bing, but a bit older.", "name": "Japan GSI ortho Imagery" }, - "gsi.go.jp_airphoto": { - "attribution": { - "text": "GSI Japan" - }, - "description": "Japan GSI airphoto Imagery. Not fully orthorectified, but a bit newer and/or differently covered than GSI ortho Imagery.", - "name": "Japan GSI airphoto Imagery" - }, "gsi.go.jp_std_map": { "attribution": { "text": "GSI Japan" diff --git a/modules/behavior/draw_way.js b/modules/behavior/draw_way.js index 847803d15..dc099acf6 100644 --- a/modules/behavior/draw_way.js +++ b/modules/behavior/draw_way.js @@ -323,7 +323,7 @@ export function behaviorDrawWay(context, wayID, index, mode, startGraph, baselin window.setTimeout(function() { context.map().dblclickEnable(true); }, 1000); - var isNewFeature = !mode.isContinuing; + var isNewFeature = !mode.isContinuing && mode.button.indexOf('add-preset-') === -1; context.enter(modeSelect(context, [wayID]).newFeature(isNewFeature)); }; diff --git a/modules/core/context.js b/modules/core/context.js index 6bc3ae849..4295f9db5 100644 --- a/modules/core/context.js +++ b/modules/core/context.js @@ -57,7 +57,7 @@ export function coreContext() { addTranslation('en', dataEn); setLocale('en'); - var dispatch = d3_dispatch('enter', 'exit', 'change'); + var dispatch = d3_dispatch('enter', 'exit', 'change', 'favoritePreset'); // https://github.com/openstreetmap/iD/issues/772 // http://mathiasbynens.be/notes/localstorage-pattern#comment-9 @@ -312,7 +312,38 @@ export function coreContext() { /* Presets */ var presets; context.presets = function() { return presets; }; + //get favorites from local storage + context.getFavoritePresets = function() { + return JSON.parse(context.storage('favorite_presets')) || []; + } + context.favoritePreset = function(preset, geom) { + var favs = context.getFavoritePresets(); + //add/remove favorites from local storage + if (context.isFavoritePreset(preset, geom)) { + favs = favs.filter(function(d) { + return !(d.id === preset.id && d.geom === geom); + }); + } else { + //only allow 3 favorites + //replace the last one + if (favs.length === 3) { + favs = favs.slice(0,2); + } + favs.push({id: preset.id, geom: geom}); + } + + context.storage('favorite_presets', JSON.stringify(favs)); + + //and call update on modes + dispatch.call('favoritePreset'); + }; + context.isFavoritePreset = function(preset, geom) { + var favs = context.getFavoritePresets(); + return favs.some(function(d) { + return d.id === preset.id && d.geom === geom; + }); + }; /* Map */ var map; diff --git a/modules/modes/add_area.js b/modules/modes/add_area.js index ec2097a3e..9c8f465f0 100644 --- a/modules/modes/add_area.js +++ b/modules/modes/add_area.js @@ -10,8 +10,8 @@ import { modeDrawArea } from './index'; import { osmNode, osmWay } from '../osm'; -export function modeAddArea(context) { - var mode = { +export function modeAddArea(context, customMode, preset) { + var mode = customMode || { id: 'add-area', button: 'area', title: t('modes.add_area.title'), @@ -26,6 +26,7 @@ export function modeAddArea(context) { .on('startFromNode', startFromNode); var defaultTags = { area: 'yes' }; + if (preset) defaultTags = preset.setTags(defaultTags, 'area'); function actionClose(wayId) { @@ -47,7 +48,7 @@ export function modeAddArea(context) { actionClose(way.id) ); - context.enter(modeDrawArea(context, way.id, startGraph, context.graph())); + context.enter(modeDrawArea(context, way.id, startGraph, context.graph(), mode.button)); } @@ -64,7 +65,7 @@ export function modeAddArea(context) { actionAddMidpoint({ loc: loc, edge: edge }, node) ); - context.enter(modeDrawArea(context, way.id, startGraph, context.graph())); + context.enter(modeDrawArea(context, way.id, startGraph, context.graph(), mode.button)); } @@ -78,7 +79,7 @@ export function modeAddArea(context) { actionClose(way.id) ); - context.enter(modeDrawArea(context, way.id, startGraph, context.graph())); + context.enter(modeDrawArea(context, way.id, startGraph, context.graph(), mode.button)); } diff --git a/modules/modes/add_line.js b/modules/modes/add_line.js index 364adbcce..c524f502c 100644 --- a/modules/modes/add_line.js +++ b/modules/modes/add_line.js @@ -10,8 +10,8 @@ import { modeDrawLine } from './index'; import { osmNode, osmWay } from '../osm'; -export function modeAddLine(context) { - var mode = { +export function modeAddLine(context, customMode, preset) { + var mode = customMode || { id: 'add-line', button: 'line', title: t('modes.add_line.title'), @@ -25,11 +25,14 @@ export function modeAddLine(context) { .on('startFromWay', startFromWay) .on('startFromNode', startFromNode); + var defaultTags = {}; + if (preset) defaultTags = preset.setTags(defaultTags, 'line'); + function start(loc) { var startGraph = context.graph(); var node = osmNode({ loc: loc }); - var way = osmWay(); + var way = osmWay({ tags: defaultTags }); context.perform( actionAddEntity(node), @@ -37,7 +40,7 @@ export function modeAddLine(context) { actionAddVertex(way.id, node.id) ); - context.enter(modeDrawLine(context, way.id, startGraph, context.graph())); + context.enter(modeDrawLine(context, way.id, startGraph, context.graph(), mode.button)); } @@ -53,7 +56,7 @@ export function modeAddLine(context) { actionAddMidpoint({ loc: loc, edge: edge }, node) ); - context.enter(modeDrawLine(context, way.id, startGraph, context.graph())); + context.enter(modeDrawLine(context, way.id, startGraph, context.graph(), mode.button)); } @@ -66,7 +69,7 @@ export function modeAddLine(context) { actionAddVertex(way.id, node.id) ); - context.enter(modeDrawLine(context, way.id, startGraph, context.graph())); + context.enter(modeDrawLine(context, way.id, startGraph, context.graph(), mode.button)); } diff --git a/modules/modes/add_point.js b/modules/modes/add_point.js index 89623a012..d9024d95d 100644 --- a/modules/modes/add_point.js +++ b/modules/modes/add_point.js @@ -6,8 +6,8 @@ import { osmNode } from '../osm'; import { actionAddMidpoint } from '../actions'; -export function modeAddPoint(context) { - var mode = { +export function modeAddPoint(context, customMode, preset) { + var mode = customMode || { id: 'add-point', button: 'point', title: t('modes.add_point.title'), @@ -23,9 +23,12 @@ export function modeAddPoint(context) { .on('cancel', cancel) .on('finish', cancel); + var defaultTags = {}; + if (preset) defaultTags = preset.setTags(defaultTags, 'point'); + function add(loc) { - var node = osmNode({ loc: loc }); + var node = osmNode({ loc: loc, tags: defaultTags }); context.perform( actionAddEntity(node), diff --git a/modules/modes/draw_area.js b/modules/modes/draw_area.js index 00ef60d50..639773fa7 100644 --- a/modules/modes/draw_area.js +++ b/modules/modes/draw_area.js @@ -2,9 +2,9 @@ import { t } from '../util/locale'; import { behaviorDrawWay } from '../behavior'; -export function modeDrawArea(context, wayId, startGraph, baselineGraph) { +export function modeDrawArea(context, wayId, startGraph, baselineGraph, button) { var mode = { - button: 'area', + button: button, id: 'draw-area' }; diff --git a/modules/modes/draw_line.js b/modules/modes/draw_line.js index ba6748e3e..e6094975b 100644 --- a/modules/modes/draw_line.js +++ b/modules/modes/draw_line.js @@ -2,9 +2,9 @@ import { t } from '../util/locale'; import { behaviorDrawWay } from '../behavior'; -export function modeDrawLine(context, wayID, startGraph, baselineGraph, affix, continuing) { +export function modeDrawLine(context, wayID, startGraph, baselineGraph, button, affix, continuing) { var mode = { - button: 'line', + button: button, id: 'draw-line' }; diff --git a/modules/operations/continue.js b/modules/operations/continue.js index 088bd29ab..173965485 100644 --- a/modules/operations/continue.js +++ b/modules/operations/continue.js @@ -27,7 +27,7 @@ export function operationContinue(selectedIDs, context) { var operation = function() { var candidate = candidateWays()[0]; context.enter( - modeDrawLine(context, candidate.id, context.graph(), context.graph(), candidate.affix(vertex.id), true) + modeDrawLine(context, candidate.id, context.graph(), context.graph(), 'line', candidate.affix(vertex.id), true) ); }; diff --git a/modules/ui/entity_editor.js b/modules/ui/entity_editor.js index 845ad37e9..7f567424c 100644 --- a/modules/ui/entity_editor.js +++ b/modules/ui/entity_editor.js @@ -14,6 +14,7 @@ import { tooltip } from '../util/tooltip'; import { actionChangeTags } from '../actions'; import { modeBrowse } from '../modes'; import { svgIcon } from '../svg'; +import { uiPresetFavorite } from './preset_favorite'; import { uiPresetIcon } from './preset_icon'; import { uiQuickLinks } from './quick_links'; import { uiRawMemberEditor } from './raw_member_editor'; @@ -35,6 +36,7 @@ export function uiEntityEditor(context) { var _entityID; var _activePreset; var _tagReference; + var _presetFavorite; var entityIssues = uiEntityIssues(context); var quickLinks = uiQuickLinks(); @@ -137,6 +139,11 @@ export function uiEntityEditor(context) { body = body .merge(bodyEnter); + if (_presetFavorite) { + body.selectAll('.preset-list-button-wrap') + .call(_presetFavorite.button); + } + // update header if (_tagReference) { body.selectAll('.preset-list-button-wrap') @@ -333,6 +340,7 @@ export function uiEntityEditor(context) { _activePreset = val; _tagReference = uiTagReference(_activePreset.reference(context.geometry(_entityID)), context) .showing(false); + _presetFavorite = uiPresetFavorite(_activePreset, context.geometry(_entityID), context); } return entityEditor; }; diff --git a/modules/ui/modes.js b/modules/ui/modes.js index 35dfcc347..5a9a74c4f 100644 --- a/modules/ui/modes.js +++ b/modules/ui/modes.js @@ -11,6 +11,7 @@ import { } from '../modes'; import { svgIcon } from '../svg'; +import { t } from '../util/locale'; import { tooltip } from '../util/tooltip'; import { uiTooltipHtml } from './tooltipHtml'; @@ -82,7 +83,8 @@ export function uiModes(context) { .on('drawn.modes', debouncedUpdate); context - .on('enter.modes', update); + .on('enter.modes', update) + .on('favoritePreset.modes', update); update(); @@ -91,6 +93,37 @@ export function uiModes(context) { var showNotes = notesEnabled(); var data = showNotes ? modes : modes.slice(0, 3); + // add favorite presets to modes + var favoritePresets = context.getFavoritePresets(); + var favoriteModes = favoritePresets.map(function(d) { + var preset = context.presets().item(d.id); + var isMaki = /^maki-/.test(preset.icon); + var icon = '#' + preset.icon + (isMaki ? '-11' : ''); + var markerClass = 'add-preset-' + preset.name() + .replace(/\s+/g, '_') + + '-' + d.geom; //replace spaces with underscores to avoid css interpretation + + var favoriteMode = { + id: markerClass, + button: markerClass, + title: t('presets.presets.' + preset.id + '.name'), + description: [t('operations.add.title'), t('presets.presets.' + preset.id + '.name').toLowerCase(), t('geometry.' + d.geom)].join(' '), + key: '', + icon: icon + } + switch (d.geom) { + case 'point': + case 'vertex': + return modeAddPoint(context, favoriteMode, preset); + case 'line': + return modeAddLine(context, favoriteMode, preset); + case 'area': + return modeAddArea(context, favoriteMode, preset); + } + }); + + data = data.concat(favoriteModes); + var buttons = selection.selectAll('button.add-button') .data(data, function(d) { return d.id; }); @@ -125,7 +158,7 @@ export function uiModes(context) { buttonsEnter .each(function(d) { d3_select(this) - .call(svgIcon('#iD-icon-' + d.button)); + .call(svgIcon(d.icon || '#iD-icon-' + d.button)); }); buttonsEnter diff --git a/modules/ui/preset_favorite.js b/modules/ui/preset_favorite.js new file mode 100644 index 000000000..ee8d41921 --- /dev/null +++ b/modules/ui/preset_favorite.js @@ -0,0 +1,57 @@ +import _find from 'lodash-es/find'; +import _omit from 'lodash-es/omit'; + +import { + event as d3_event, + select as d3_select +} from 'd3-selection'; + +import { t } from '../util/locale'; +import { svgIcon } from '../svg'; +import { uiModes } from './modes'; + +export function uiPresetFavorite(preset, geom, context) { + + var presetFavorite = {}; + + var _button = d3_select(null); + + + presetFavorite.button = function(selection) { + var data = (preset.icon) ? [0] : []; + + _button = selection.selectAll('.preset-favorite-button') + .data(data); + + _button.exit().remove(); + + _button = _button.enter() + .insert('button', '.tag-reference-button') + .attr('class', 'preset-favorite-button') + .attr('title', t('icons.favorite')) + .attr('tabindex', -1) + .call(svgIcon('#iD-icon-favorite')) + .merge(_button); + + _button + .classed('active', function(d) { + return context.isFavoritePreset(preset, geom); + }) + .on('click', function () { + d3_event.stopPropagation(); + d3_event.preventDefault(); + + //update state of favorite icon + d3_select(this) + .classed('active', function() { + return !d3_select(this).classed('active'); + }); + + context.favoritePreset(preset, geom); + + }); + + }; + + return presetFavorite; +} diff --git a/svg/iD-sprite/icons/icon-favorite.svg b/svg/iD-sprite/icons/icon-favorite.svg new file mode 100644 index 000000000..9d49e6404 --- /dev/null +++ b/svg/iD-sprite/icons/icon-favorite.svg @@ -0,0 +1,6 @@ + + + + + From d8531c88bb1053f994385ff8c32aabd7a5fe6c7c Mon Sep 17 00:00:00 2001 From: Brian Hatchl Date: Wed, 20 Feb 2019 15:44:16 -0500 Subject: [PATCH 02/17] fix lint complaints --- modules/core/context.js | 2 +- modules/ui/modes.js | 2 +- modules/ui/preset_favorite.js | 6 +----- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/modules/core/context.js b/modules/core/context.js index 4295f9db5..617446f1f 100644 --- a/modules/core/context.js +++ b/modules/core/context.js @@ -315,7 +315,7 @@ export function coreContext() { //get favorites from local storage context.getFavoritePresets = function() { return JSON.parse(context.storage('favorite_presets')) || []; - } + }; context.favoritePreset = function(preset, geom) { var favs = context.getFavoritePresets(); diff --git a/modules/ui/modes.js b/modules/ui/modes.js index 5a9a74c4f..b1f1a48f4 100644 --- a/modules/ui/modes.js +++ b/modules/ui/modes.js @@ -110,7 +110,7 @@ export function uiModes(context) { description: [t('operations.add.title'), t('presets.presets.' + preset.id + '.name').toLowerCase(), t('geometry.' + d.geom)].join(' '), key: '', icon: icon - } + }; switch (d.geom) { case 'point': case 'vertex': diff --git a/modules/ui/preset_favorite.js b/modules/ui/preset_favorite.js index ee8d41921..ffdb02307 100644 --- a/modules/ui/preset_favorite.js +++ b/modules/ui/preset_favorite.js @@ -1,6 +1,3 @@ -import _find from 'lodash-es/find'; -import _omit from 'lodash-es/omit'; - import { event as d3_event, select as d3_select @@ -8,7 +5,6 @@ import { import { t } from '../util/locale'; import { svgIcon } from '../svg'; -import { uiModes } from './modes'; export function uiPresetFavorite(preset, geom, context) { @@ -34,7 +30,7 @@ export function uiPresetFavorite(preset, geom, context) { .merge(_button); _button - .classed('active', function(d) { + .classed('active', function() { return context.isFavoritePreset(preset, geom); }) .on('click', function () { From dead97e32103506062c42fa952c0fb5301dfc731 Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Tue, 26 Feb 2019 15:17:04 -0500 Subject: [PATCH 03/17] Reduce parameters for add modes Tweak CSS classes --- css/55_cursors.css | 3 +-- modules/modes/add_area.js | 4 ++-- modules/modes/add_line.js | 4 ++-- modules/modes/add_point.js | 4 ++-- modules/ui/modes.js | 13 +++++++------ 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/css/55_cursors.css b/css/55_cursors.css index 70edc9c55..b9039d91d 100644 --- a/css/55_cursors.css +++ b/css/55_cursors.css @@ -54,7 +54,7 @@ cursor: url(img/cursor-select-remove.png), pointer; /* FF */ } -[class*=" mode-add-preset-"] #map, +.mode-add-favorite #map, .mode-draw-line #map, .mode-draw-area #map, .mode-add-line #map, @@ -105,4 +105,3 @@ .turn circle { cursor: pointer; } - diff --git a/modules/modes/add_area.js b/modules/modes/add_area.js index 9c8f465f0..55b344943 100644 --- a/modules/modes/add_area.js +++ b/modules/modes/add_area.js @@ -10,7 +10,7 @@ import { modeDrawArea } from './index'; import { osmNode, osmWay } from '../osm'; -export function modeAddArea(context, customMode, preset) { +export function modeAddArea(context, customMode) { var mode = customMode || { id: 'add-area', button: 'area', @@ -26,7 +26,7 @@ export function modeAddArea(context, customMode, preset) { .on('startFromNode', startFromNode); var defaultTags = { area: 'yes' }; - if (preset) defaultTags = preset.setTags(defaultTags, 'area'); + if (mode.preset) defaultTags = mode.preset.setTags(defaultTags, 'area'); function actionClose(wayId) { diff --git a/modules/modes/add_line.js b/modules/modes/add_line.js index c524f502c..b56549682 100644 --- a/modules/modes/add_line.js +++ b/modules/modes/add_line.js @@ -10,7 +10,7 @@ import { modeDrawLine } from './index'; import { osmNode, osmWay } from '../osm'; -export function modeAddLine(context, customMode, preset) { +export function modeAddLine(context, customMode) { var mode = customMode || { id: 'add-line', button: 'line', @@ -26,7 +26,7 @@ export function modeAddLine(context, customMode, preset) { .on('startFromNode', startFromNode); var defaultTags = {}; - if (preset) defaultTags = preset.setTags(defaultTags, 'line'); + if (mode.preset) defaultTags = mode.preset.setTags(defaultTags, 'line'); function start(loc) { diff --git a/modules/modes/add_point.js b/modules/modes/add_point.js index d9024d95d..e5c77d0cf 100644 --- a/modules/modes/add_point.js +++ b/modules/modes/add_point.js @@ -6,7 +6,7 @@ import { osmNode } from '../osm'; import { actionAddMidpoint } from '../actions'; -export function modeAddPoint(context, customMode, preset) { +export function modeAddPoint(context, customMode) { var mode = customMode || { id: 'add-point', button: 'point', @@ -24,7 +24,7 @@ export function modeAddPoint(context, customMode, preset) { .on('finish', cancel); var defaultTags = {}; - if (preset) defaultTags = preset.setTags(defaultTags, 'point'); + if (mode.preset) defaultTags = mode.preset.setTags(defaultTags, 'point'); function add(loc) { diff --git a/modules/ui/modes.js b/modules/ui/modes.js index b1f1a48f4..c73628054 100644 --- a/modules/ui/modes.js +++ b/modules/ui/modes.js @@ -99,7 +99,7 @@ export function uiModes(context) { var preset = context.presets().item(d.id); var isMaki = /^maki-/.test(preset.icon); var icon = '#' + preset.icon + (isMaki ? '-11' : ''); - var markerClass = 'add-preset-' + preset.name() + var markerClass = 'add-favorite add-preset-' + preset.name() .replace(/\s+/g, '_') + '-' + d.geom; //replace spaces with underscores to avoid css interpretation @@ -107,18 +107,19 @@ export function uiModes(context) { id: markerClass, button: markerClass, title: t('presets.presets.' + preset.id + '.name'), - description: [t('operations.add.title'), t('presets.presets.' + preset.id + '.name').toLowerCase(), t('geometry.' + d.geom)].join(' '), + description: [t('operations.add.title'), t('presets.presets.' + preset.id + '.name'), t('geometry.' + d.geom)].join(' '), key: '', - icon: icon + icon: icon, + preset: preset }; switch (d.geom) { case 'point': case 'vertex': - return modeAddPoint(context, favoriteMode, preset); + return modeAddPoint(context, favoriteMode); case 'line': - return modeAddLine(context, favoriteMode, preset); + return modeAddLine(context, favoriteMode); case 'area': - return modeAddArea(context, favoriteMode, preset); + return modeAddArea(context, favoriteMode); } }); From ff439ac5b31bb355d2b7cabd2a02582fe81374c6 Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Tue, 26 Feb 2019 15:32:55 -0500 Subject: [PATCH 04/17] Rename "add to favorites" tooltip to "favorite" --- data/core.yaml | 2 +- dist/locales/en.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/core.yaml b/data/core.yaml index 5a9c85dc4..f9da2999c 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -7,7 +7,7 @@ en: zoom_to: zoom to copy: copy open_wikidata: open on wikidata.org - favorite: add to favorites + favorite: favorite modes: add_area: title: Area diff --git a/dist/locales/en.json b/dist/locales/en.json index 6ae7f41a4..14a606e12 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -8,7 +8,7 @@ "zoom_to": "zoom to", "copy": "copy", "open_wikidata": "open on wikidata.org", - "favorite": "add to favorites" + "favorite": "favorite" }, "modes": { "add_area": { From 5faa9990712de7c5b687cdc55c9e6e90ad416ab6 Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Tue, 26 Feb 2019 18:00:33 -0500 Subject: [PATCH 05/17] Use preset icon for favorite buttons --- css/80_app.css | 17 ++++++++++++++++- modules/ui/modes.js | 16 +++++++++++++--- modules/ui/preset_favorite.js | 3 +-- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/css/80_app.css b/css/80_app.css index cf2156f4c..5323aff27 100644 --- a/css/80_app.css +++ b/css/80_app.css @@ -472,8 +472,18 @@ button[disabled].action:hover { padding: 0 10px; min-width: 30px; white-space: nowrap; + display: flex; } -.tool-group button .icon { +.tool-group button.add-favorite { + padding-left: 0px; +} +.tool-group button.add-favorite .label { + padding-left: 0; +} +.narrow .tool-group button.add-favorite { + padding-right: 0; +} +.tool-group button > .icon { flex: 0 0 20px; } .tool-group button .label { @@ -970,6 +980,10 @@ a.hide-toggle { height: 60px; text-align: center; } +#bar .preset-icon-container { + width: 40px; + height: 40px; +} .preset-icon-line { margin: auto; @@ -1018,6 +1032,7 @@ a.hide-toggle { .preset-icon-frame { width: 100%; height:100%; + position: absolute; } .preset-icon-frame .icon{ position: absolute; diff --git a/modules/ui/modes.js b/modules/ui/modes.js index c73628054..92151dc77 100644 --- a/modules/ui/modes.js +++ b/modules/ui/modes.js @@ -13,6 +13,7 @@ import { import { svgIcon } from '../svg'; import { t } from '../util/locale'; import { tooltip } from '../util/tooltip'; +import { uiPresetIcon } from './preset_icon'; import { uiTooltipHtml } from './tooltipHtml'; export function uiModes(context) { @@ -110,7 +111,8 @@ export function uiModes(context) { description: [t('operations.add.title'), t('presets.presets.' + preset.id + '.name'), t('geometry.' + d.geom)].join(' '), key: '', icon: icon, - preset: preset + preset: preset, + geometry: d.geom }; switch (d.geom) { case 'point': @@ -158,8 +160,16 @@ export function uiModes(context) { buttonsEnter .each(function(d) { - d3_select(this) - .call(svgIcon(d.icon || '#iD-icon-' + d.button)); + if (d.preset) { + d3_select(this) + .call(uiPresetIcon() + .geometry(d.geometry) + .preset(d.preset) + ) + } else { + d3_select(this) + .call(svgIcon(d.icon || '#iD-icon-' + d.button)); + } }); buttonsEnter diff --git a/modules/ui/preset_favorite.js b/modules/ui/preset_favorite.js index ffdb02307..f78808c20 100644 --- a/modules/ui/preset_favorite.js +++ b/modules/ui/preset_favorite.js @@ -14,10 +14,9 @@ export function uiPresetFavorite(preset, geom, context) { presetFavorite.button = function(selection) { - var data = (preset.icon) ? [0] : []; _button = selection.selectAll('.preset-favorite-button') - .data(data); + .data([0]); _button.exit().remove(); From 0a0e4890ca15a3ef6f2ae5c692ff09b3de4c50ca Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Wed, 27 Feb 2019 11:28:24 -0500 Subject: [PATCH 06/17] Nicer favorite preset icon rendering in the top bar --- modules/ui/modes.js | 1 + modules/ui/preset_icon.js | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/modules/ui/modes.js b/modules/ui/modes.js index 92151dc77..bb8f71f5e 100644 --- a/modules/ui/modes.js +++ b/modules/ui/modes.js @@ -165,6 +165,7 @@ export function uiModes(context) { .call(uiPresetIcon() .geometry(d.geometry) .preset(d.preset) + .sizeClass('small') ) } else { d3_select(this) diff --git a/modules/ui/preset_icon.js b/modules/ui/preset_icon.js index daaa2110b..14c2723ca 100644 --- a/modules/ui/preset_icon.js +++ b/modules/ui/preset_icon.js @@ -4,7 +4,11 @@ import { svgIcon, svgTagClasses } from '../svg'; import { utilFunctor } from '../util'; export function uiPresetIcon() { - var preset, geometry; + var preset, geometry, sizeClass = 'medium'; + + function isSmall() { + return sizeClass === 'small'; + } function presetIcon(selection) { @@ -39,7 +43,8 @@ export function uiPresetIcon() { } function renderSquareFill(fillEnter) { - var w = 60, h = 60, l = 40, c1 = (w-l)/2, c2 = c1 + l; + var d = isSmall() ? 40 : 60; + var w = d, h = d, l = d*2/3, c1 = (w-l)/2, c2 = c1 + l; fillEnter = fillEnter .append('svg') .attr('class', 'preset-icon-fill preset-icon-fill-area') @@ -59,8 +64,9 @@ export function uiPresetIcon() { } function renderLine(lineEnter) { + var d = isSmall() ? 40 : 60; // draw the line parametrically - var w = 60, h = 60, y = 43, l = 36, r = 2.5; + var w = d, h = d, y = Math.round(d*0.72), l = Math.round(d*0.6), r = 2.5; var x1 = (w - l)/2, x2 = x1 + l; lineEnter = lineEnter @@ -166,7 +172,7 @@ export function uiPresetIcon() { var areaFrame = container.selectAll('.preset-icon-frame') - .data((geom === 'area') ? [0] : []); + .data((geom === 'area' && !isSmall()) ? [0] : []); areaFrame.exit() .remove(); @@ -214,5 +220,12 @@ export function uiPresetIcon() { return presetIcon; }; + + presetIcon.sizeClass = function(val) { + if (!arguments.length) return sizeClass; + sizeClass = val; + return presetIcon; + }; + return presetIcon; } From 1c1c3b28239781db52490c5e7638e8b1edbc56e6 Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Wed, 27 Feb 2019 11:34:47 -0500 Subject: [PATCH 07/17] Disallow favoriting vertices and relations --- modules/ui/preset_favorite.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/ui/preset_favorite.js b/modules/ui/preset_favorite.js index f78808c20..847065d36 100644 --- a/modules/ui/preset_favorite.js +++ b/modules/ui/preset_favorite.js @@ -15,8 +15,10 @@ export function uiPresetFavorite(preset, geom, context) { presetFavorite.button = function(selection) { + var canFavorite = geom !== 'vertex' && geom !== 'relation'; + _button = selection.selectAll('.preset-favorite-button') - .data([0]); + .data(canFavorite ? [0] : []); _button.exit().remove(); From af5012107fba5f07bdc4a92ca0b109c3ce3b553e Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Wed, 27 Feb 2019 11:44:47 -0500 Subject: [PATCH 08/17] Fix crash when drawing a favorite highway --- modules/validations/almost_junction.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/validations/almost_junction.js b/modules/validations/almost_junction.js index 298bec323..8da908a11 100644 --- a/modules/validations/almost_junction.js +++ b/modules/validations/almost_junction.js @@ -145,6 +145,7 @@ export function validationAlmostJunction() { var validation = function(endHighway, context) { if (!isHighway(endHighway)) return []; + if (endHighway.isDegenerate()) return []; var graph = context.graph(); var tree = context.history().tree(); From 4fabb4aac8dceeada4a94e13fa98ec7dc5917330 Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Wed, 27 Feb 2019 12:03:10 -0500 Subject: [PATCH 09/17] Nicen favorite preset mode button tooltips --- data/core.yaml | 8 ++++++++ dist/locales/en.json | 12 ++++++++++++ modules/ui/modes.js | 13 ++++++++++--- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/data/core.yaml b/data/core.yaml index f9da2999c..cc680cab8 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -25,6 +25,14 @@ en: title: Note description: "Spotted an issue? Let other mappers know." tail: Click on the map to add a note. + add_preset: + title: "Add {feature}" + point: + title: "Add {feature} as a point" + line: + title: "Add {feature} as a line" + area: + title: "Add {feature} as an area" browse: title: Browse description: Pan and zoom the map. diff --git a/dist/locales/en.json b/dist/locales/en.json index b26829b22..a1dee379d 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -31,6 +31,18 @@ "description": "Spotted an issue? Let other mappers know.", "tail": "Click on the map to add a note." }, + "add_preset": { + "title": "Add {feature}", + "point": { + "title": "Add {feature} as a point" + }, + "line": { + "title": "Add {feature} as a line" + }, + "area": { + "title": "Add {feature} as an area" + } + }, "browse": { "title": "Browse", "description": "Pan and zoom the map." diff --git a/modules/ui/modes.js b/modules/ui/modes.js index bb8f71f5e..87c01ebf0 100644 --- a/modules/ui/modes.js +++ b/modules/ui/modes.js @@ -103,12 +103,19 @@ export function uiModes(context) { var markerClass = 'add-favorite add-preset-' + preset.name() .replace(/\s+/g, '_') + '-' + d.geom; //replace spaces with underscores to avoid css interpretation - + var presetName = t('presets.presets.' + preset.id + '.name'); + var relevantMatchingGeometry = preset.geometry.filter(function(geometry) { + return ['point', 'line', 'area'].indexOf(geometry) !== -1; + }); + var tooltipTitleID = 'modes.add_preset.title'; + if (relevantMatchingGeometry.length !== 1) { + tooltipTitleID = 'modes.add_preset.' + d.geom + '.title' + } var favoriteMode = { id: markerClass, button: markerClass, - title: t('presets.presets.' + preset.id + '.name'), - description: [t('operations.add.title'), t('presets.presets.' + preset.id + '.name'), t('geometry.' + d.geom)].join(' '), + title: presetName, + description: t(tooltipTitleID, { feature: presetName }), key: '', icon: icon, preset: preset, From 2da011c3ca35c8b1d7088ccde632cdb6fdfd5da3 Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Wed, 27 Feb 2019 12:20:23 -0500 Subject: [PATCH 10/17] Remove unused string Don't show preset browser when adding a favorite point Don't automatically open the sidebar when selecting a non-new feature --- data/core.yaml | 1 - dist/locales/en.json | 3 +-- modules/modes/add_point.js | 4 ++-- modules/ui/sidebar.js | 6 ++++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/data/core.yaml b/data/core.yaml index cc680cab8..ca8a5340b 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -49,7 +49,6 @@ en: vertex: Added a node to a way. relation: Added a relation. note: Added a note. - title: Add start: annotation: line: Started a line. diff --git a/dist/locales/en.json b/dist/locales/en.json index a1dee379d..b41a90abf 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -64,8 +64,7 @@ "vertex": "Added a node to a way.", "relation": "Added a relation.", "note": "Added a note." - }, - "title": "Add" + } }, "start": { "annotation": { diff --git a/modules/modes/add_point.js b/modules/modes/add_point.js index e5c77d0cf..c50b287ba 100644 --- a/modules/modes/add_point.js +++ b/modules/modes/add_point.js @@ -36,7 +36,7 @@ export function modeAddPoint(context, customMode) { ); context.enter( - modeSelect(context, [node.id]).newFeature(true) + modeSelect(context, [node.id]).newFeature(!mode.preset) ); } @@ -50,7 +50,7 @@ export function modeAddPoint(context, customMode) { ); context.enter( - modeSelect(context, [node.id]).newFeature(true) + modeSelect(context, [node.id]).newFeature(!mode.preset) ); } diff --git a/modules/ui/sidebar.js b/modules/ui/sidebar.js index 25d8abd62..b33943003 100644 --- a/modules/ui/sidebar.js +++ b/modules/ui/sidebar.js @@ -215,8 +215,10 @@ export function uiSidebar(context) { var entity = context.entity(id); // uncollapse the sidebar if (selection.classed('collapsed')) { - var extent = entity.extent(context.graph()); - sidebar.expand(sidebar.intersects(extent)); + if (newFeature) { + var extent = entity.extent(context.graph()); + sidebar.expand(sidebar.intersects(extent)); + } } featureListWrap From 1058a2cb272e70781b984d0935a8f95f701a4606 Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Wed, 27 Feb 2019 12:27:54 -0500 Subject: [PATCH 11/17] Fix instances where adding favorite preset would not add tags --- modules/modes/add_line.js | 4 ++-- modules/modes/add_point.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/modes/add_line.js b/modules/modes/add_line.js index b56549682..82f4578ae 100644 --- a/modules/modes/add_line.js +++ b/modules/modes/add_line.js @@ -47,7 +47,7 @@ export function modeAddLine(context, customMode) { function startFromWay(loc, edge) { var startGraph = context.graph(); var node = osmNode({ loc: loc }); - var way = osmWay(); + var way = osmWay({ tags: defaultTags }); context.perform( actionAddEntity(node), @@ -62,7 +62,7 @@ export function modeAddLine(context, customMode) { function startFromNode(node) { var startGraph = context.graph(); - var way = osmWay(); + var way = osmWay({ tags: defaultTags }); context.perform( actionAddEntity(way), diff --git a/modules/modes/add_point.js b/modules/modes/add_point.js index c50b287ba..3b79f86b6 100644 --- a/modules/modes/add_point.js +++ b/modules/modes/add_point.js @@ -42,7 +42,7 @@ export function modeAddPoint(context, customMode) { function addWay(loc, edge) { - var node = osmNode(); + var node = osmNode({ tags: defaultTags }); context.perform( actionAddMidpoint({loc: loc, edge: edge}, node), From 0fe4513e2ad9421bd2a1d887b6ae8342f67d6f84 Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Wed, 27 Feb 2019 12:30:38 -0500 Subject: [PATCH 12/17] Tweak CSS class --- css/55_cursors.css | 2 +- css/80_app.css | 6 +++--- modules/ui/modes.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/css/55_cursors.css b/css/55_cursors.css index b9039d91d..0a5adabbe 100644 --- a/css/55_cursors.css +++ b/css/55_cursors.css @@ -54,7 +54,7 @@ cursor: url(img/cursor-select-remove.png), pointer; /* FF */ } -.mode-add-favorite #map, +.mode-add-preset #map, .mode-draw-line #map, .mode-draw-area #map, .mode-add-line #map, diff --git a/css/80_app.css b/css/80_app.css index 2bbd45672..731322073 100644 --- a/css/80_app.css +++ b/css/80_app.css @@ -474,13 +474,13 @@ button[disabled].action:hover { white-space: nowrap; display: flex; } -.tool-group button.add-favorite { +.tool-group button.add-preset { padding-left: 0px; } -.tool-group button.add-favorite .label { +.tool-group button.add-preset .label { padding-left: 0; } -.narrow .tool-group button.add-favorite { +.narrow .tool-group button.add-preset { padding-right: 0; } .tool-group button > .icon { diff --git a/modules/ui/modes.js b/modules/ui/modes.js index 87c01ebf0..7a19d0277 100644 --- a/modules/ui/modes.js +++ b/modules/ui/modes.js @@ -100,7 +100,7 @@ export function uiModes(context) { var preset = context.presets().item(d.id); var isMaki = /^maki-/.test(preset.icon); var icon = '#' + preset.icon + (isMaki ? '-11' : ''); - var markerClass = 'add-favorite add-preset-' + preset.name() + var markerClass = 'add-preset add-preset-' + preset.name() .replace(/\s+/g, '_') + '-' + d.geom; //replace spaces with underscores to avoid css interpretation var presetName = t('presets.presets.' + preset.id + '.name'); From b302d853ac31b41d71dc66bb4563dc6efb559917 Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Wed, 27 Feb 2019 13:13:15 -0500 Subject: [PATCH 13/17] Fix issue where the favorite preset button could be stale Use first in, first out favoriting order --- modules/core/context.js | 9 +++++---- modules/ui/entity_editor.js | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/core/context.js b/modules/core/context.js index 2a4425b05..2efa2c4f1 100644 --- a/modules/core/context.js +++ b/modules/core/context.js @@ -325,12 +325,13 @@ export function coreContext() { return !(d.id === preset.id && d.geom === geom); }); } else { - //only allow 3 favorites - //replace the last one + // only allow 3 favorites if (favs.length === 3) { - favs = favs.slice(0,2); + // remove the last favorite (first in, first out) + favs.pop(); } - favs.push({id: preset.id, geom: geom}); + // prepend array + favs.unshift({id: preset.id, geom: geom}); } context.storage('favorite_presets', JSON.stringify(favs)); diff --git a/modules/ui/entity_editor.js b/modules/ui/entity_editor.js index 7f567424c..eba317e19 100644 --- a/modules/ui/entity_editor.js +++ b/modules/ui/entity_editor.js @@ -340,8 +340,8 @@ export function uiEntityEditor(context) { _activePreset = val; _tagReference = uiTagReference(_activePreset.reference(context.geometry(_entityID)), context) .showing(false); - _presetFavorite = uiPresetFavorite(_activePreset, context.geometry(_entityID), context); } + _presetFavorite = uiPresetFavorite(_activePreset, context.geometry(_entityID), context); return entityEditor; }; From dd74a1820687c3ab19a78698444f0639fafd746a Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Wed, 27 Feb 2019 14:27:03 -0500 Subject: [PATCH 14/17] Tweak favorite mode spacing Don't show area midpoint dots on small preset icons --- css/80_app.css | 23 +++++++++++++++++++---- modules/ui/modes.js | 2 +- modules/ui/preset_icon.js | 19 +++++++++++-------- 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/css/80_app.css b/css/80_app.css index 7a6dff5c2..64246010c 100644 --- a/css/80_app.css +++ b/css/80_app.css @@ -474,14 +474,29 @@ button[disabled].action:hover { white-space: nowrap; display: flex; } -.tool-group button.add-preset { +[dir='ltr'] .tool-group button.add-preset.add-point, +[dir='ltr'] .tool-group button.add-preset.add-point .label { padding-left: 0px; } -.tool-group button.add-preset .label { - padding-left: 0; +[dir='ltr'] .tool-group button.add-preset:not(.add-point) { + padding-left: 5px; +} +[dir='ltr'] .tool-group button.add-preset:not(.add-point) .label { + padding-left: 3px; +} +[dir='rtl'] .tool-group button.add-preset.add-point, +[dir='rtl'] .tool-group button.add-preset.add-point .label { + padding-right: 0px; +} +[dir='rtl'] .tool-group button.add-preset:not(.add-point) { + padding-right: 5px; +} +[dir='rtl'] .tool-group button.add-preset:not(.add-point) .label { + padding-right: 3px; } .narrow .tool-group button.add-preset { - padding-right: 0; + padding-right: 0 !important; + padding-left: 0 !important; } .tool-group button > .icon { flex: 0 0 20px; diff --git a/modules/ui/modes.js b/modules/ui/modes.js index 7a19d0277..159effa1f 100644 --- a/modules/ui/modes.js +++ b/modules/ui/modes.js @@ -100,7 +100,7 @@ export function uiModes(context) { var preset = context.presets().item(d.id); var isMaki = /^maki-/.test(preset.icon); var icon = '#' + preset.icon + (isMaki ? '-11' : ''); - var markerClass = 'add-preset add-preset-' + preset.name() + var markerClass = 'add-preset add-' + d.geom + ' add-preset-' + preset.name() .replace(/\s+/g, '_') + '-' + d.geom; //replace spaces with underscores to avoid css interpretation var presetName = t('presets.presets.' + preset.id + '.name'); diff --git a/modules/ui/preset_icon.js b/modules/ui/preset_icon.js index 9d1ac8d0b..f699272e2 100644 --- a/modules/ui/preset_icon.js +++ b/modules/ui/preset_icon.js @@ -74,15 +74,18 @@ export function uiPresetIcon() { } } - var midCoordinates = [[c1, w/2], [c2, w/2], [h/2, c1], [h/2, c2]]; - for (var index in midCoordinates) { - var loc = midCoordinates[index]; - fillEnter.append('circle') - .attr('class', 'midpoint') - .attr('cx', loc[0]) - .attr('cy', loc[1]) - .attr('r', 1.25); + if (!isSmall()) { + var midCoordinates = [[c1, w/2], [c2, w/2], [h/2, c1], [h/2, c2]]; + for (var index in midCoordinates) { + var loc = midCoordinates[index]; + fillEnter.append('circle') + .attr('class', 'midpoint') + .attr('cx', loc[0]) + .attr('cy', loc[1]) + .attr('r', 1.25); + } } + } function renderLine(lineEnter) { From bfeb37451002a36ffa014bbe4c82ca754c8d92ae Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Wed, 27 Feb 2019 14:31:23 -0500 Subject: [PATCH 15/17] Don't allow favoriting fallback presets --- modules/ui/preset_favorite.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ui/preset_favorite.js b/modules/ui/preset_favorite.js index 847065d36..ef43ee338 100644 --- a/modules/ui/preset_favorite.js +++ b/modules/ui/preset_favorite.js @@ -15,7 +15,7 @@ export function uiPresetFavorite(preset, geom, context) { presetFavorite.button = function(selection) { - var canFavorite = geom !== 'vertex' && geom !== 'relation'; + var canFavorite = geom !== 'vertex' && geom !== 'relation' && !preset.isFallback(); _button = selection.selectAll('.preset-favorite-button') .data(canFavorite ? [0] : []); From 6ead9ff097bbbdd3847083c7f14db35bd86c5382 Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Wed, 27 Feb 2019 14:51:11 -0500 Subject: [PATCH 16/17] Update favorite icon --- svg/iD-sprite/icons/icon-favorite.svg | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/svg/iD-sprite/icons/icon-favorite.svg b/svg/iD-sprite/icons/icon-favorite.svg index 9d49e6404..cc81bef58 100644 --- a/svg/iD-sprite/icons/icon-favorite.svg +++ b/svg/iD-sprite/icons/icon-favorite.svg @@ -1,6 +1,4 @@ - - - + + From 6bdb59c7d3942466e71af1a53bde665a6bdf3683 Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Wed, 27 Feb 2019 14:53:22 -0500 Subject: [PATCH 17/17] Fix lint errors --- modules/ui/modes.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ui/modes.js b/modules/ui/modes.js index 159effa1f..ea15f1199 100644 --- a/modules/ui/modes.js +++ b/modules/ui/modes.js @@ -109,7 +109,7 @@ export function uiModes(context) { }); var tooltipTitleID = 'modes.add_preset.title'; if (relevantMatchingGeometry.length !== 1) { - tooltipTitleID = 'modes.add_preset.' + d.geom + '.title' + tooltipTitleID = 'modes.add_preset.' + d.geom + '.title'; } var favoriteMode = { id: markerClass, @@ -173,7 +173,7 @@ export function uiModes(context) { .geometry(d.geometry) .preset(d.preset) .sizeClass('small') - ) + ); } else { d3_select(this) .call(svgIcon(d.icon || '#iD-icon-' + d.button));