-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add download changes link #4350
Changes from 2 commits
8c9aae1
a43b1e3
8249475
359eab4
2edc37b
2023545
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' }), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generally for downloading you don't want to supply anything for changeset ID. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you check this for me? I'm really not sure what other tools need. It currently ends up generating something kind of like this, but we can remove the <osmChange version="0.6" generator="iD">
<create/>
<modify>
<node id="105439801" lon="-74.53666020842094" lat="40.663296528227306" version="2" changeset="CHANGEME"/>
<node id="105439798" lon="-74.53607265426908" lat="40.66309431604051" version="2" changeset="CHANGEME"/>
</modify>
<delete if-unused="true">
<node id="5106517631" lon="-74.5367492" lat="40.6633484" version="1" changeset="CHANGEME"/>
</delete>
</osmChange> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the changeset="CHANGEME" and it looks okay. I'm not 100% sure what programs support reading osmChange for uploads. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sounds good, thanks! |
||
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 ? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The standard way is with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah this is different in client side javascript, see stack overflow. That's why we are using the I'm going to test today what happens in IE11, but I think we should be able to fallback to the previous behavior, which is opening a new tab with the |
||
// .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( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The standard spelling for OSC files is "osmChange"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'll change it. I was going off of the osm wiki - should we change it there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wiki page titles have to begin with a capital character.