diff --git a/css/app.css b/css/app.css index 66f46429c..b977ebeea 100644 --- a/css/app.css +++ b/css/app.css @@ -247,9 +247,15 @@ button small { .commit-pane ul { border-bottom:1px solid #ccc; + background:#fff; } .commit-pane li { border-top:1px solid #ccc; - padding:2px; + padding:2px 10px; +} + +.commit-pane .changeset-comment { + width:630px; + font-size:100%; } diff --git a/js/iD/Connection.js b/js/iD/Connection.js index 9170f39f3..3df75fe6f 100644 --- a/js/iD/Connection.js +++ b/js/iD/Connection.js @@ -97,12 +97,12 @@ iD.Connection = function() { return oauth.authenticated(); } - function createChangeset(changes) { + function putChangeset(changes, comment, callback) { oauth.xhr({ method: 'PUT', path: '/api/0.6/changeset/create', options: { header: { 'Content-Type': 'text/xml' } }, - content: iD.format.XML.changeset() + content: iD.format.XML.changeset(comment) }, function (changeset_id) { oauth.xhr({ @@ -115,7 +115,7 @@ iD.Connection = function() { method: 'PUT', path: '/api/0.6/changeset/' + changeset_id + '/close' }, function () { - alert('saved! ' + apiURL.replace('/api/0.6', '/browse') + '/changeset/' + changeset_id); + callback(changeset_id); }); }); }); @@ -155,7 +155,7 @@ iD.Connection = function() { connection.userDetails = userDetails; connection.authenticate = authenticate; connection.authenticated = authenticated; - connection.createChangeset = createChangeset; + connection.putChangeset = putChangeset; connection.objectData = objectData; connection.apiURL = apiURL; diff --git a/js/iD/id.js b/js/iD/id.js index 8eaf8e0d1..85b807aed 100644 --- a/js/iD/id.js +++ b/js/iD/id.js @@ -69,13 +69,21 @@ var iD = function(container) { .html("Save") .on('click', function() { connection.authenticate(function() { + var commitpane = iD.Commit(); var shaded = d3.select(document.body) .append('div').attr('class', 'shaded'); var modal = shaded.append('div') .attr('class', 'modal commit-pane') .datum(map.history.changes()); - modal.call(iD.Commit()); - // map.commit(); + modal.call(commitpane); + commitpane.on('cancel', function() { + shaded.remove(); + }); + commitpane.on('save', function(e) { + connection.putChangeset(map.history.changes(), e.comment, function() { + shaded.remove(); + }); + }); }); }); diff --git a/js/iD/renderer/Map.js b/js/iD/renderer/Map.js index 84170deef..03a372d72 100644 --- a/js/iD/renderer/Map.js +++ b/js/iD/renderer/Map.js @@ -503,7 +503,7 @@ iD.Map = function(elem, connection) { } function commit() { - connection.createChangeset(history.changes()); + connection.putChangeset(history.changes()); } map.download = download; diff --git a/js/iD/ui/commit.js b/js/iD/ui/commit.js index f95a3854b..b0b83853c 100644 --- a/js/iD/ui/commit.js +++ b/js/iD/ui/commit.js @@ -1,5 +1,5 @@ iD.Commit = function() { - var event = d3.dispatch(); + var event = d3.dispatch('cancel', 'save'); function commit(selection) { var changes = selection.datum(); @@ -9,7 +9,9 @@ iD.Commit = function() { header.append('h2').text('Save Changes to OpenStreetMap'); var section = body.selectAll('div.section') - .data(['modify', 'delete', 'create']) + .data(['modify', 'delete', 'create'].filter(function(d) { + return changes[d].length; + })) .enter() .append('div').attr('class', 'section'); @@ -31,8 +33,20 @@ iD.Commit = function() { return iD.Util.friendlyName(d); }); - body.append('button').text('Save'); - body.append('button').text('Cancel'); + body.append('textarea') + .attr('class', 'changeset-comment') + .attr('placeholder', 'Brief Description'); + + body.append('button').text('Save') + .on('click', function() { + event.save({ + comment: d3.select('textarea.changeset-comment').node().value + }); + }); + body.append('button').text('Cancel') + .on('click', function() { + event.cancel(); + }); } return d3.rebind(commit, event, 'on');