Detect, pass, and display errors. Fixes #124

This commit is contained in:
Tom MacWright
2013-01-07 17:51:50 -05:00
parent f5e2eeff9e
commit ed032be98f
3 changed files with 25 additions and 15 deletions

View File

@@ -122,17 +122,25 @@ window.iD = function(container) {
l.remove();
history.reset();
map.flush().redraw();
var modal = iD.modal();
modal.select('.content')
.classed('success-modal', true)
.datum({
id: changeset_id,
comment: e.comment
})
.call(iD.success()
.on('cancel', function() {
modal.remove();
}));
if (err) {
var desc = iD.confirm()
.select('.description');
desc.append('h2')
.text('An error occurred while trying to save');
desc.append('p').text(err.responseText);
} else {
var modal = iD.modal();
modal.select('.content')
.classed('success-modal', true)
.datum({
id: changeset_id,
comment: e.comment
})
.call(iD.success()
.on('cancel', function() {
modal.remove();
}));
}
});
}
var changes = history.changes();

View File

@@ -49,8 +49,9 @@ iD.OAuth = function() {
o.oauth_signature = ohauth.signature(oauth_secret, oauth_token_secret,
ohauth.baseString(options.method, url, o));
ohauth.xhr(options.method, url, o, options.content, options.options, function(err, xhr) {
if (xhr.responseXML) callback(err, xhr.responseXML);
else callback(err, xhr.response);
if (err) return callback(err);
if (xhr.responseXML) return callback(err, xhr.responseXML);
else return callback(err, xhr.response);
});
};

View File

@@ -1,9 +1,10 @@
iD.confirm = function(message) {
iD.confirm = function() {
var modal = iD.modal();
modal.select('.modal').classed('modal-alert', true);
modal.select('.content')
.classed('modal-section', true)
.append('div').attr('class', 'description');
.append('div')
.attr('class', 'description');
var nochanges = modal.select('.content')
.append('button')
.attr('class','wide action centered')