Add download changes link to uiCommitChanges summary

(WIP: still need to check IE11 and fix download on conflict screen)
This commit is contained in:
Bryan Housel
2017-09-14 17:35:06 -04:00
parent b07dad051b
commit 8c9aae1499
5 changed files with 43 additions and 1 deletions
+39 -1
View File
@@ -1,6 +1,11 @@
import * as d3 from 'd3';
import { t } from '../util/locale';
import { JXON } from '../util/jxon';
import { actionDiscardTags } from '../actions';
import { osmChangeset } from '../osm';
import { svgIcon } from '../svg';
import { utilDetect } from '../util/detect';
import {
utilDisplayName,
utilDisplayType,
@@ -9,10 +14,13 @@ import {
export function uiCommitChanges(context) {
var detected = utilDetect();
function commitChanges(selection) {
var summary = context.history().difference().summary();
var history = context.history(),
summary = history.difference().summary();
var container = selection.selectAll('.modal-section.commit-section')
.data([0]);
@@ -85,6 +93,36 @@ export function uiCommitChanges(context) {
.on('click', zoomToEntity);
// Download changeset link
var changeset = new osmChangeset({ id: 'CHANGEME' }),
changes = history.changes(actionDiscardTags(history.difference())),
data = JXON.stringify(changeset.osmChangeJXON(changes)),
uri = 'data:text/xml,' + encodeURIComponent(data);
var downloadLink = container.selectAll('.download-changes')
.data([0]);
var enter = downloadLink.enter()
.append('a')
.attr('class', 'download-changes')
.attr('href', uri) // no IE11 ?
.attr('download', 'changes.osc') // no IE11 ?
// .attr('target', '_blank') // maybe IE11 ?
.call(svgIcon('#icon-load', 'inline'));
enter
.append('span')
.text(t('commit.download_changes'));
downloadLink
.merge(enter)
.on('click.download', function() {
if (!detected.ie) return; // yes IE11 ?
var win = window.open(uri, '_blank');
win.focus();
});
function mouseover(d) {
if (d.entity) {
context.surface().selectAll(