diff --git a/modules/behavior/hash.js b/modules/behavior/hash.js index e04d39ee22..12e6d71edc 100644 --- a/modules/behavior/hash.js +++ b/modules/behavior/hash.js @@ -51,9 +51,9 @@ export function behaviorHash(context) { newParams.map = zoom.toFixed(2) + '/' + center[1].toFixed(precision) + '/' + center[0].toFixed(precision); - + /* - var gsLayer = context.layers().layer('geoservice').originalURL; + var gsLayer = context.layers().layer('geoservice').layerUrl; if (gsLayer) { q.geoservice = gsLayer; } diff --git a/modules/core/history.js b/modules/core/history.js index 7c53e55b0c..85aa8275f0 100644 --- a/modules/core/history.js +++ b/modules/core/history.js @@ -16,7 +16,7 @@ export function coreHistory(context) { lock = utilSessionMutex('lock'), duration = 150, checkpoints = {}, - stack, index, tree; + stack, index, tree, source; // internal _act, accepts list of actions and eased time @@ -40,7 +40,8 @@ export function coreHistory(context) { return { graph: graph, annotation: annotation, - imageryUsed: imageryUsed + imageryUsed: imageryUsed, + source: source }; } @@ -285,6 +286,15 @@ export function coreHistory(context) { } }, + source: function(sourceUrl) { + if (sourceUrl) { + source = sourceUrl; + return history; + } else { + return source; + } + }, + // save the current history state checkpoint: function(key) { @@ -414,6 +424,7 @@ export function coreHistory(context) { if (deleted.length) x.deleted = deleted; if (i.imageryUsed) x.imageryUsed = i.imageryUsed; if (i.annotation) x.annotation = i.annotation; + if (i.source) x.source = i.source; return x; }); @@ -516,7 +527,8 @@ export function coreHistory(context) { return { graph: coreGraph(stack[0].graph).load(entities), annotation: d.annotation, - imageryUsed: d.imageryUsed + imageryUsed: d.imageryUsed, + source: d.source }; }); diff --git a/modules/modes/save.js b/modules/modes/save.js index c1192faa2f..774a63fe96 100644 --- a/modules/modes/save.js +++ b/modules/modes/save.js @@ -34,14 +34,14 @@ export function modeSave(context) { var mode = { id: 'save' }; - + if (d3.select('input[name="approvalProcess"]:checked').property('value') === 'individual') { // when clicking the save button, filter out entities which were not approved manually var deletions = []; _.map(window.importedEntities, function(entity) { try { if ((entity.approvedForEdit !== 'approved' && entity.approvedForEdit !== 'unchanged') && context.entity(entity.id)) { - deletions.push(entity.id); + deletions.push(entity.id); } } catch (e) { // entity was already deleted, can't be removed here diff --git a/modules/renderer/background.js b/modules/renderer/background.js index ac0f170f4f..928753f54e 100644 --- a/modules/renderer/background.js +++ b/modules/renderer/background.js @@ -92,8 +92,9 @@ export function rendererBackground(context) { .forEach(function (d) { imageryUsed.push(d.source().imageryUsed()); }); var gsLayer = context.layers().layer('geoservice'); - if (gsLayer && gsLayer.enabled() && gsLayer.hasData()) { + if (gsLayer && gsLayer.hasData()) { imageryUsed.push('GeoService'); + context.history().source(gsLayer.layerUrl); } var gpx = context.layers().layer('gpx'); @@ -272,7 +273,7 @@ export function rendererBackground(context) { background.toggleOverlayLayer(overlay); } }); - + /* if (q.geoservice) { setTimeout(function() { diff --git a/modules/svg/geoservice.js b/modules/svg/geoservice.js index 5d65e1c0af..f23ccc3fa0 100644 --- a/modules/svg/geoservice.js +++ b/modules/svg/geoservice.js @@ -637,8 +637,8 @@ export function svgGeoService(projection, context, dispatch) { }; drawGeoService.url = function(true_url, downloadMax) { - if (!this.originalURL) { - this.originalURL = true_url; + if (!this.layerUrl) { + drawGeoService.layerUrl = true_url; } var fmt = drawGeoService.format() || 'json'; @@ -700,7 +700,7 @@ export function svgGeoService(projection, context, dispatch) { } var that = this; - console.log('final GeoService URL: ' + url); + // console.log('final GeoService URL: ' + url); d3.text(url, function(err, data) { if (err) { console.log('GeoService URL did not load'); diff --git a/modules/ui/commit.js b/modules/ui/commit.js index 4e1512b8ec..ea06cbdf62 100644 --- a/modules/ui/commit.js +++ b/modules/ui/commit.js @@ -18,7 +18,7 @@ import { var changeset; -var readOnlyTags = ['created_by', 'imagery_used', 'host', 'locale']; +var readOnlyTags = ['created_by', 'imagery_used', 'host', 'locale', 'source']; export function uiCommit(context) { @@ -35,6 +35,13 @@ export function uiCommit(context) { locale: detected.locale.substr(0, 255) }; + // if a GeoService was imported, pass the source url through, + // along with mandatory, user editable field for the import discussion + if (context.history().source() ){ + tags.source = context.history().source(); + tags.import_discussion = ''; + } + changeset = new osmChangeset({ tags: tags }); } @@ -44,6 +51,7 @@ export function uiCommit(context) { rawTagEditor = uiRawTagEditor(context).on('change', changeTags), comment = context.storage('comment') || '', commentDate = +context.storage('commentDate') || 0, + importDiscussion = context.storage('importDiscussion') || '', currDate = Date.now(), cutoff = 2 * 86400 * 1000; // 2 days @@ -87,6 +95,29 @@ export function uiCommit(context) { commentField.node().select(); + if (tags.source) { + var discussionSection = body + .append('div') + .attr('class', 'modal-section form-field commit-form'); + + discussionSection + .append('label') + .attr('class', 'form-label') + .text('Import Discussion'); + + var discussionField = discussionSection + .append('textarea') + .attr('class', 'commit-form-comment') + .attr('placeholder', 'imports@openstreetmap.org discussion thread (required)') + .attr('maxlength', 255) + .property('value', importDiscussion) + .on('input.save', change(true)) + .on('change.save', change()) + .on('blur.save', function() { + context.storage('importDiscussion', this.value); + }); + } + context.connection().userChangesets(function (err, changesets) { if (err) return; @@ -364,6 +395,18 @@ export function uiCommit(context) { checkComment(comment); var changeset = updateChangeset({ comment: comment }); + + if (discussionField) { + var discussion = discussionField.property('value').trim(); + if (!onInput) { + discussionField.property('value', discussion); + } + + checkComment(discussion); + + var changeset = updateChangeset({ import_discussion: discussion }); + } + var expanded = !tagSection.selectAll('a.hide-toggle.expanded').empty(); tagSection diff --git a/modules/ui/map_data.js b/modules/ui/map_data.js index ee796e4269..23bdb2b284 100644 --- a/modules/ui/map_data.js +++ b/modules/ui/map_data.js @@ -502,6 +502,7 @@ export function uiMapData(context) { content.append('h3') .text('Import from a GeoService by URL'); + var body = content.append('div') .attr('class', 'body'); @@ -540,7 +541,7 @@ export function uiMapData(context) { .text('The url provided not recognized as a valid GeoService'); unrecognizedLabel.classed('hide', false); return; - } + } } // if it just ends /0, we need to keep /0 around @@ -831,6 +832,7 @@ export function uiMapData(context) { function editGeoService() { // window allows user to enter a GeoService layer + d3.event.preventDefault(); toggle(); } diff --git a/modules/ui/save.js b/modules/ui/save.js index b4615e40ba..a39ce83c62 100644 --- a/modules/ui/save.js +++ b/modules/ui/save.js @@ -7,7 +7,6 @@ import { uiCmd } from './cmd'; import { uiTooltipHtml } from './tooltipHtml'; import { tooltip } from '../util/tooltip'; - export function uiSave(context) { var history = context.history(), key = uiCmd('⌘S');