Skip to content

Commit

Permalink
Show the preset icon in the assistant when a single feature is select…
Browse files Browse the repository at this point in the history
…ed (close #6027)
  • Loading branch information
quincylvania committed Jun 18, 2019
1 parent 3493b95 commit 1a113c0
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 27 deletions.
15 changes: 11 additions & 4 deletions css/80_app.css
Original file line number Diff line number Diff line change
Expand Up @@ -1030,11 +1030,15 @@ a.hide-toggle {
.assistant .icon-col {
flex: 0 0 auto;
padding: 10px;
padding-bottom: 0;
}
.assistant .icon-col .icon {
.assistant .icon-col > .icon {
width: 30px;
height: 30px;
}
.assistant .icon-col > .preset-icon-container {
margin: -5px;
}
.assistant .body-col {
padding: 10px;
}
Expand All @@ -1050,10 +1054,13 @@ a.hide-toggle {
letter-spacing: 0.7px;
font-size: 10px;
font-weight: bold;
line-height: 1em;
margin-bottom: 3px;
}
.assistant .subject-title {
font-size: 13px;
font-size: 14px;
font-weight: bold;
line-height: normal;
}
.assistant .body-text {
font-size: 12px;
Expand Down Expand Up @@ -1561,10 +1568,10 @@ a.hide-toggle {
height: 100%;
transform: scale(0.48);
}
.preset-icon-container.small .preset-icon.point-geom .icon {
.preset-icon-container .preset-icon.framed.point-geom .icon {
transform: translateY(-7%) scale(0.27);
}
.preset-icon-container.small .preset-icon.point-geom.preset-icon-iD .icon {
.preset-icon-container .preset-icon.framed.point-geom.preset-icon-iD .icon {
transform: translateY(-9%) scale(0.5);
}
.preset-icon.framed .icon {
Expand Down
45 changes: 27 additions & 18 deletions modules/ui/assistant.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { services } from '../services';
import { utilDisplayLabel } from '../util';
import { uiIntro } from './intro';
import { uiSuccess } from './success';
import { uiPresetIcon } from './preset_icon';
import { uiFeatureList } from './feature_list';
import { uiSelectionList } from './selection_list';
import { geoRawMercator } from '../geo/raw_mercator';
Expand Down Expand Up @@ -60,7 +61,7 @@ export function uiAssistant(context) {
if (container.empty()) return;

var mode = context.mode();
if (!mode) return;
if (!mode || !mode.id) return;

if (mode.id !== 'browse') {
updateDidEditStatus();
Expand All @@ -71,7 +72,6 @@ export function uiAssistant(context) {
iconCol = iconCol.enter()
.append('div')
.attr('class', 'icon-col')
.call(svgIcon('#'))
.merge(iconCol);

var mainCol = header.selectAll('.body-col')
Expand All @@ -95,32 +95,32 @@ export function uiAssistant(context) {

mainCol = mainColEnter.merge(mainCol);

var iconUse = iconCol.selectAll('svg.icon use'),
modeLabel = mainCol.selectAll('.mode-label'),
var modeLabel = mainCol.selectAll('.mode-label'),
subjectTitle = mainCol.selectAll('.subject-title'),
bodyTextArea = mainCol.selectAll('.body-text'),
mainFooter = mainCol.selectAll('.main-footer');

if (mode.id.indexOf('point') !== -1) {
iconUse.attr('href','#iD-icon-point');
} else if (mode.id.indexOf('line') !== -1) {
iconUse.attr('href','#iD-icon-line');
} else if (mode.id.indexOf('area') !== -1) {
iconUse.attr('href','#iD-icon-area');
}

iconCol.html('');
body.html('');
bodyTextArea.html('');
mainFooter.html('');
subjectTitle.classed('map-center-location', false);
container.classed('prominent', false);
container.attr('class', 'assistant ' + mode.id);

if (mode.id.indexOf('point') !== -1) {
iconCol.call(svgIcon('#iD-icon-point'));
} else if (mode.id.indexOf('line') !== -1) {
iconCol.call(svgIcon('#iD-icon-line'));
} else if (mode.id.indexOf('area') !== -1) {
iconCol.call(svgIcon('#iD-icon-area'));
}

if (mode.id === 'save') {

var summary = context.history().difference().summary();

modeLabel.text(t('assistant.mode.saving'));
iconUse.attr('href','#iD-icon-save');
iconCol.call(svgIcon('#iD-icon-save'));

var titleID = summary.length === 1 ? 'change' : 'changes';
subjectTitle.text(t('commit.' + titleID, { count: summary.length }));
Expand Down Expand Up @@ -155,16 +155,24 @@ export function uiAssistant(context) {

var selectedIDs = mode.selectedIDs();

iconUse.attr('href','#fas-edit');
modeLabel.text(t('assistant.mode.editing'));

if (selectedIDs.length === 1) {

var id = selectedIDs[0];
var entity = context.entity(id);
var geometry = entity.geometry(context.graph());
var preset = context.presets().match(entity, context.graph());
subjectTitle.text(utilDisplayLabel(entity, context));

iconCol.call(uiPresetIcon(context)
.geometry(geometry)
.preset(preset)
.sizeClass('small')
.pointMarker(false));

} else {
iconCol.call(svgIcon('#fas-edit'));
subjectTitle.text(t('assistant.feature_count.multiple', { count: selectedIDs.length.toString() }));

var selectionList = uiSelectionList(context, selectedIDs);
Expand All @@ -178,7 +186,7 @@ export function uiAssistant(context) {
if (savedChangeset) {
drawSaveSuccessScreen();
} else {
iconUse.attr('href','#' + greetingIcon());
iconCol.call(svgIcon('#' + greetingIcon()));
subjectTitle.text(t('assistant.greetings.' + greetingTimeframe()));

if (context.history().hasRestorableChanges()) {
Expand Down Expand Up @@ -206,7 +214,7 @@ export function uiAssistant(context) {
}

} else {
iconUse.attr('href','#fas-map-marked-alt');
iconCol.call(svgIcon('#fas-map-marked-alt'));

modeLabel.text(t('assistant.mode.mapping'));

Expand Down Expand Up @@ -234,7 +242,7 @@ export function uiAssistant(context) {
} else {
savedIcon = 'laugh-beam';
}
iconUse.attr('href','#fas-' + savedIcon);
iconCol.call(svgIcon('#fas-' + savedIcon));

bodyTextArea.html(
'<b>' + t('assistant.commit.success.just_improved', { location: currLocation }) + '</b>' +
Expand Down Expand Up @@ -314,6 +322,7 @@ export function uiAssistant(context) {
mainFooter.append('button')
.attr('class', 'primary')
.on('click', function() {
updateDidEditStatus();
context.history().restore();
redraw();
})
Expand Down
1 change: 1 addition & 0 deletions modules/ui/entity_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export function uiEntityEditor(context) {
.call(uiPresetIcon(context)
.geometry(context.geometry(_entityID))
.preset(_activePreset)
.pointMarker(false)
);

// NOTE: split on en-dash, not a hypen (to avoid conflict with hyphenated names)
Expand Down
14 changes: 11 additions & 3 deletions modules/ui/preset_icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { svgIcon, svgTagClasses } from '../svg';
import { utilFunctor } from '../util';

export function uiPresetIcon(context) {
var preset, geometry, sizeClass = 'medium';
var preset, geometry, sizeClass = 'medium', pointMarker = true;

function isSmall() {
return sizeClass === 'small';
Expand Down Expand Up @@ -209,12 +209,12 @@ export function uiPresetIcon(context) {
var isTnp = picon && /^tnp-/.test(picon);
var isiDIcon = picon && !(isMaki || isTemaki || isFa || isTnp);
var isCategory = !p.setTags;
var drawPoint = picon && geom === 'point' && isSmall() && !isFallback;
var drawPoint = picon && geom === 'point' && pointMarker && !isFallback;
var drawVertex = picon !== null && geom === 'vertex' && (!isSmall() || !isFallback);
var drawLine = picon && geom === 'line' && !isFallback && !isCategory;
var drawArea = picon && geom === 'area' && !isFallback;
var drawRoute = picon && geom === 'route';
var isFramed = (drawVertex || drawArea || drawLine || drawRoute);
var isFramed = (drawPoint || drawVertex || drawArea || drawLine || drawRoute);

var tags = !isCategory ? p.setTags({}, geom) : {};
for (var k in tags) {
Expand Down Expand Up @@ -378,5 +378,13 @@ export function uiPresetIcon(context) {
return presetIcon;
};


presetIcon.pointMarker = function(val) {
if (!arguments.length) return pointMarker;
pointMarker = val;
return presetIcon;
};


return presetIcon;
}
6 changes: 4 additions & 2 deletions modules/ui/preset_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ export function uiPresetList(context) {
.classed('expanded', false)
.call(uiPresetIcon(context)
.geometry(context.geometry(_entityID))
.preset(preset))
.preset(preset)
.pointMarker(false))
.on('click', click)
.on('keydown', function() {
// right arrow, expand the focused item
Expand Down Expand Up @@ -382,7 +383,8 @@ export function uiPresetList(context) {
.attr('class', 'preset-list-button')
.call(uiPresetIcon(context)
.geometry(context.geometry(_entityID))
.preset(preset))
.preset(preset)
.pointMarker(false))
.on('click', item.choose)
.on('keydown', itemKeydown);

Expand Down
1 change: 1 addition & 0 deletions modules/ui/tools/add_favorite.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export function uiToolAddFavorite(context) {
.geometry((d.geometry === 'point' && !d.preset.matchGeometry(d.geometry)) ? 'vertex' : d.geometry)
.preset(d.preset)
.sizeClass('small')
.pointMarker(true)
);
});

Expand Down
1 change: 1 addition & 0 deletions modules/ui/tools/add_recent.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ export function uiToolAddRecent(context) {
.geometry((d.geometry === 'point' && !d.preset.matchGeometry(d.geometry)) ? 'vertex' : d.geometry)
.preset(d.preset)
.sizeClass('small')
.pointMarker(true)
);
});

Expand Down

0 comments on commit 1a113c0

Please sign in to comment.