Changeset refactor

(closes #2633)

* move osmChangeJXON from osm service to osmChangeset
* cleanup putChangeset for code clarity
* adjust params for callbacks (pass changeset around instead of changeset_id)
* add commit.reset() to reset changeset object after successful save
* improve checks for changeset tags (trim whitespace, etc)
This commit is contained in:
Bryan Housel
2017-03-15 11:03:43 -04:00
parent 4d207471ff
commit 1a8cfcc8b1
7 changed files with 277 additions and 276 deletions
+8 -3
View File
@@ -214,7 +214,6 @@ export function uiCommit(context) {
})
.on('click.save', function() {
dispatch.call('save', this, changeset);
changeset = null;
});
saveButton
@@ -383,11 +382,11 @@ export function uiCommit(context) {
var tags = _.clone(changeset.tags);
_.forEach(changed, function(v, k) {
k = k.trim();
k = k.trim().substr(0, 255);
if (readOnlyTags.indexOf(k) !== -1) return;
if (k !== '' && v !== undefined) {
tags[k] = v.trim();
tags[k] = v.trim().substr(0, 255);
} else {
delete tags[k];
}
@@ -402,5 +401,11 @@ export function uiCommit(context) {
}
commit.reset = function() {
changeset = null;
};
return utilRebind(commit, dispatch, 'on');
}