From 7ef2e65c4de015c9b91e34e8ee717c46a84f131f Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Thu, 21 Mar 2013 21:33:24 -0400 Subject: [PATCH] add reset button to modified fields this button only appears if a field's value differs from the original osm value. Resetting changes the value and adds a history entry. It does not undo history. --- css/app.css | 12 ++++++++++++ js/id/ui/preset.js | 12 +++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/css/app.css b/css/app.css index ded09f388..1db4c0e90 100644 --- a/css/app.css +++ b/css/app.css @@ -918,6 +918,18 @@ a.selected:hover .toggle.icon { background-position: -40px -180px;} background: #eef0ff; } +.preset-field h4 .modified-icon { + opacity: 0.2; + display: none; + pointer-events: all; +} +.preset-field h4 .modified-icon:hover { + opacity: 0.5; +} +.preset-field.modified h4 .modified-icon { + display: inline-block; +} + .preset-field h4[for*="input-"] { border: 1px solid #cfcfcf; padding: 5px 10px; diff --git a/js/id/ui/preset.js b/js/id/ui/preset.js index 7d3fb412b..f69517842 100644 --- a/js/id/ui/preset.js +++ b/js/id/ui/preset.js @@ -70,7 +70,17 @@ iD.ui.preset = function(context, entity) { sections.append('h4') .attr('for', function(d) { return 'input-' + d.key; }) - .text(function(d) { return d.label(); }); + .text(function(d) { return d.label(); }) + .append('button') + .attr('class', 'fr icon undo modified-icon') + .on('click', function(d) { + var original = context.graph().base().entities[entity.id]; + var t = {}; + (d.keys || [d.key]).forEach(function(key) { + t[key] = original ? original.tags[key] : undefined; + }); + event.change(t); + }); sections.transition() .style('opacity', 1);