From 0313064e22c9fe9e7d29e2808831568a8f662fc1 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Wed, 22 Apr 2015 09:52:49 -0400 Subject: [PATCH] Use '; ' seperator for opening_hours-like tags (closes #2301) --- js/id/ui/entity_editor.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/js/id/ui/entity_editor.js b/js/id/ui/entity_editor.js index 206e868da..e6d4509c2 100644 --- a/js/id/ui/entity_editor.js +++ b/js/id/ui/entity_editor.js @@ -133,14 +133,24 @@ iD.ui.EntityEditor = function(context) { } function clean(o) { + function isOpeningHours(k) { + return _.any(['opening_hours', 'service_times', 'collection_times', + 'operating_times', 'smoking_hours', 'happy_hours'], function(s) { + return k.indexOf(s) !== -1; + }); + } + function cleanVal(k, v) { + return v.split(';') + .map(function(s) { return s.trim(); }) + .join(isOpeningHours(k) ? '; ' : ';'); + } + var out = {}, k, v; - /*jshint -W083 */ for (k in o) { if (k && (v = o[k]) !== undefined) { - out[k] = v.split(';').map(function(s) { return s.trim(); }).join(';'); + out[k] = cleanVal(k, v); } } - /*jshint +W083 */ return out; }