From b74ba194f297f2bf95640c519ea81bae7f1a2d6b Mon Sep 17 00:00:00 2001 From: Aaron Lidman Date: Wed, 16 Oct 2013 12:43:25 -0400 Subject: [PATCH] Added ability to zoom to changeset list items --- css/app.css | 4 ++++ js/id/modes/save.js | 6 ------ js/id/ui/commit.js | 47 ++++++++++++++++----------------------------- 3 files changed, 21 insertions(+), 36 deletions(-) diff --git a/css/app.css b/css/app.css index 609ced9f3..11475c7ac 100644 --- a/css/app.css +++ b/css/app.css @@ -2449,6 +2449,10 @@ img.wiki-image { color:#555; } +.mode-save .commit-section .changeset-list button { + border-left: 1px solid #CCC; +} + .changeset-list li span.count:before { content: '('; } .changeset-list li span.count:after { content: ')'; } diff --git a/js/id/modes/save.js b/js/id/modes/save.js index daaaafed2..80d78db4d 100644 --- a/js/id/modes/save.js +++ b/js/id/modes/save.js @@ -1,18 +1,12 @@ iD.modes.Save = function(context) { var ui = iD.ui.Commit(context) .on('cancel', cancel) - .on('fix', fix) .on('save', save); function cancel() { context.enter(iD.modes.Browse(context)); } - function fix(d) { - context.map().zoomTo(d.entity); - context.enter(iD.modes.Select(context, [d.entity.id])); - } - function save(e) { var loading = iD.ui.Loading(context) .message(t('save.uploading')) diff --git a/js/id/ui/commit.js b/js/id/ui/commit.js index 0968cabda..49b8b649f 100644 --- a/js/id/ui/commit.js +++ b/js/id/ui/commit.js @@ -1,32 +1,17 @@ iD.ui.Commit = function(context) { - var event = d3.dispatch('cancel', 'save', 'fix'), + var event = d3.dispatch('cancel', 'save'), presets = context.presets(); - function zipSame(d) { - var c = {}, n = -1; - for (var i = 0; i < d.length; i++) { - var desc = { - name: d[i].tags.name || presets.match(d[i], context.graph()).name(), - geometry: d[i].geometry(context.graph()), - count: 1, - tagText: iD.util.tagText(d[i]) - }; - - var fingerprint = desc.name + desc.tagText; - if (c[fingerprint]) { - c[fingerprint].count++; - } else { - c[fingerprint] = desc; - } - } - return _.values(c); - } - function commit(selection) { var changes = context.history().changes(); function changesLength(d) { return changes[d].length; } + function zoomToEntity(entity) { + context.map().zoomTo(entity); + context.enter(iD.modes.Select(context, [entity.id])); + } + var header = selection.append('div') .attr('class', 'header fillL'); @@ -121,7 +106,9 @@ iD.ui.Commit = function(context) { warningLi.filter(function(d) { return d.entity; }) .append('button') .attr('class', 'minor') - .on('click', event.fix) + .on('click', function(d) { + zoomToEntity(d.entity); + }) .append('span') .attr('class', 'icon warning'); @@ -144,23 +131,23 @@ iD.ui.Commit = function(context) { var li = section.append('ul') .attr('class', 'changeset-list') .selectAll('li') - .data(function(d) { return zipSame(changes[d]); }) + .data(function(d) { return changes[d]; }) .enter() .append('li'); li.append('strong') - .text(function(d) { - return d.geometry + ' '; + .text(function(entity) { + return entity.geometry(context.graph()) + ' '; }); li.append('span') - .text(function(d) { return d.name; }) - .attr('title', function(d) { return d.tagText; }); + .text(function(entity) { return iD.util.displayName(entity); }); - li.filter(function(d) { return d.count > 1; }) + li.append('button') + .attr('class', 'minor') + .on('click', zoomToEntity) .append('span') - .attr('class', 'count') - .text(function(d) { return d.count; }); + .attr('class', 'icon warning'); } return d3.rebind(commit, event, 'on');