mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-28 10:51:45 +02:00
Thank the user for their contribution
This commit is contained in:
@@ -28,6 +28,8 @@ import {
|
||||
modeSelect
|
||||
} from './index';
|
||||
|
||||
import { services } from '../services';
|
||||
|
||||
import {
|
||||
uiConflicts,
|
||||
uiConfirm,
|
||||
@@ -66,6 +68,7 @@ export function modeSave(context) {
|
||||
var _conflicts = [];
|
||||
var _errors = [];
|
||||
var _origChanges;
|
||||
var _location;
|
||||
|
||||
|
||||
function cancel(selectedID) {
|
||||
@@ -305,6 +308,7 @@ export function modeSave(context) {
|
||||
var history = context.history();
|
||||
var changes = history.changes(actionDiscardTags(history.difference()));
|
||||
if (changes.modified.length || changes.created.length || changes.deleted.length) {
|
||||
loadLocation(); // so it is ready when we display the save screen
|
||||
osm.putChangeset(changeset, changes, uploadCallback);
|
||||
} else { // changes were insignificant or reverted by user
|
||||
d3_select('.inspector-wrap *').remove();
|
||||
@@ -468,6 +472,7 @@ export function modeSave(context) {
|
||||
|
||||
var ui = uiSuccess(context)
|
||||
.changeset(changeset)
|
||||
.location(_location)
|
||||
.on('cancel', function() { context.ui().sidebar.hide(); });
|
||||
|
||||
context.enter(modeBrowse(context).sidebar(ui));
|
||||
@@ -486,6 +491,27 @@ export function modeSave(context) {
|
||||
}
|
||||
|
||||
|
||||
// Reverse geocode current map location so we can display a message on
|
||||
// the success screen like "Thank you for editing around city, state."
|
||||
function loadLocation() {
|
||||
_location = null;
|
||||
if (!services.geocoder) return;
|
||||
|
||||
services.geocoder.reverse(context.map().center(), function(err, result) {
|
||||
if (err || !result || !result.address) return;
|
||||
|
||||
var parts = [];
|
||||
var addr = result.address;
|
||||
var city = addr && (addr.suburb || addr.city || addr.county);
|
||||
if (city) parts.push(city);
|
||||
var region = addr && (addr.state || addr.country);
|
||||
if (region) parts.push(region);
|
||||
|
||||
_location = parts.join(', ');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
mode.enter = function() {
|
||||
function done() {
|
||||
context.ui().sidebar.show(commit);
|
||||
|
||||
+36
-11
@@ -1,6 +1,7 @@
|
||||
import { dispatch as d3_dispatch } from 'd3-dispatch';
|
||||
import { select as d3_select } from 'd3-selection';
|
||||
|
||||
import whichPolygon from 'which-polygon';
|
||||
import { t } from '../util/locale';
|
||||
import { tooltip } from '../util/tooltip';
|
||||
import { svgIcon } from '../svg';
|
||||
@@ -8,8 +9,9 @@ import { utilRebind } from '../util/rebind';
|
||||
|
||||
|
||||
export function uiSuccess(context) {
|
||||
var dispatch = d3_dispatch('cancel'),
|
||||
changeset;
|
||||
var dispatch = d3_dispatch('cancel');
|
||||
var _changeset;
|
||||
var _location;
|
||||
|
||||
|
||||
function success(selection) {
|
||||
@@ -33,22 +35,26 @@ export function uiSuccess(context) {
|
||||
|
||||
body
|
||||
.append('p')
|
||||
.html(t('success.help_html'));
|
||||
.append('strong')
|
||||
.append('em')
|
||||
.html(t('success.thank_you' + (_location ? '_location' : ''), { where: _location }));
|
||||
|
||||
body
|
||||
var detailLink = body
|
||||
.append('p')
|
||||
.html(t('success.help_html'))
|
||||
.append('a')
|
||||
.attr('class', 'details')
|
||||
.attr('target', '_blank')
|
||||
.attr('tabindex', -1)
|
||||
.call(svgIcon('#icon-out-link', 'inline'))
|
||||
.attr('href', t('success.help_link_url'))
|
||||
.call(svgIcon('#icon-out-link', 'inline'))
|
||||
.append('span')
|
||||
.text(t('success.help_link_text'));
|
||||
|
||||
var osm = context.connection();
|
||||
if (!osm) return;
|
||||
|
||||
var changesetURL = osm.changesetURL(changeset.id);
|
||||
var changesetURL = osm.changesetURL(_changeset.id);
|
||||
|
||||
var viewOnOsm = body
|
||||
.append('a')
|
||||
@@ -66,7 +72,13 @@ export function uiSuccess(context) {
|
||||
.append('div')
|
||||
.text(t('success.view_on_osm'));
|
||||
|
||||
var message = (changeset.tags.comment || t('success.edited_osm')).substring(0, 130) +
|
||||
body
|
||||
.call(showShareLinks, changesetURL);
|
||||
}
|
||||
|
||||
|
||||
function showShareLinks(selection, changesetURL) {
|
||||
var message = (_changeset.tags.comment || t('success.edited_osm')).substring(0, 130) +
|
||||
' ' + changesetURL;
|
||||
|
||||
var sharing = [
|
||||
@@ -75,7 +87,7 @@ export function uiSuccess(context) {
|
||||
{ key: 'google', value: 'https://plus.google.com/share?url=' + encodeURIComponent(changesetURL) }
|
||||
];
|
||||
|
||||
body.selectAll('.button.social')
|
||||
selection.selectAll('.button.social')
|
||||
.data(sharing)
|
||||
.enter()
|
||||
.append('a')
|
||||
@@ -84,14 +96,27 @@ export function uiSuccess(context) {
|
||||
.attr('href', function(d) { return d.value; })
|
||||
.call(tooltip()
|
||||
.title(function(d) { return t('success.' + d.key); })
|
||||
.placement('bottom'))
|
||||
.placement('bottom')
|
||||
)
|
||||
.each(function(d) { d3_select(this).call(svgIcon('#logo-' + d.key, 'social')); });
|
||||
}
|
||||
|
||||
|
||||
function showCommunities(selection) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
success.changeset = function(_) {
|
||||
if (!arguments.length) return changeset;
|
||||
changeset = _;
|
||||
if (!arguments.length) return _changeset;
|
||||
_changeset = _;
|
||||
return success;
|
||||
};
|
||||
|
||||
|
||||
success.location = function(_) {
|
||||
if (!arguments.length) return _location;
|
||||
_location = _;
|
||||
return success;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user