From faa178797da560d449f6c9cc906445e674d133e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20H=C3=A4ssler?= Date: Mon, 22 Apr 2019 16:22:59 +0200 Subject: [PATCH 1/3] Handle multiple tags when splitting up --- modules/ui/raw_tag_editor.js | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/modules/ui/raw_tag_editor.js b/modules/ui/raw_tag_editor.js index 6ca863fe52..8f661c2675 100644 --- a/modules/ui/raw_tag_editor.js +++ b/modules/ui/raw_tag_editor.js @@ -301,19 +301,6 @@ export function uiRawTagEditor(context) { var inputVal = d3_select(row).selectAll('input.value'); var vNew = utilGetSetValue(inputVal); - // if the key looks like "key=value", split them up - #5024 - if (kNew.indexOf('=') !== -1) { - var parts = kNew - .split('=') - .map(function(str) { return str.trim(); }) - .filter(Boolean); - - if (parts.length === 2) { - kNew = parts[0]; - vNew = parts[1]; - } - } - // allow no change if the key should be readonly if (isReadOnly({ key: kNew })) { this.value = kOld; @@ -340,7 +327,26 @@ export function uiRawTagEditor(context) { if (kOld) { _pendingChange[kOld] = undefined; } - _pendingChange[kNew] = vNew; + + // if the key looks like "key=value key2=value2", split them up - #5024 + var keys = (kNew.match(/[\w_]+=/g) || []).map(key => key.slice(0, -1)); + var vals = keys.length === 0 + ? [] + : kNew + .split(new RegExp(keys.map(key => key.replace('_', '\\_')).join('|'))) + .splice(1) + .map(val => val.slice(1).trim()); + + if (keys.length > 0) { + kNew = keys[0]; + vNew = vals[0]; + + keys.forEach((key, i) => { + _pendingChange[key] = vals[i]; + }); + } else { + _pendingChange[kNew] = vNew; + } d.key = kNew; // update datum to avoid exit/enter on tag update d.value = vNew; From 2596b97dbc9078fb793e789f3e89034154571053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20H=C3=A4ssler?= Date: Mon, 22 Apr 2019 16:38:33 +0200 Subject: [PATCH 2/3] Do not use ES6 features --- modules/ui/raw_tag_editor.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/ui/raw_tag_editor.js b/modules/ui/raw_tag_editor.js index 8f661c2675..af46456fd7 100644 --- a/modules/ui/raw_tag_editor.js +++ b/modules/ui/raw_tag_editor.js @@ -329,19 +329,19 @@ export function uiRawTagEditor(context) { } // if the key looks like "key=value key2=value2", split them up - #5024 - var keys = (kNew.match(/[\w_]+=/g) || []).map(key => key.slice(0, -1)); + var keys = (kNew.match(/[\w_]+=/g) || []).map(function (key) { return key.slice(0, -1)}); var vals = keys.length === 0 ? [] : kNew - .split(new RegExp(keys.map(key => key.replace('_', '\\_')).join('|'))) + .split(new RegExp(keys.map(function (key) { return key.replace('_', '\\_') }).join('|'))) .splice(1) - .map(val => val.slice(1).trim()); + .map(function (val) { return val.slice(1).trim() }); if (keys.length > 0) { kNew = keys[0]; vNew = vals[0]; - keys.forEach((key, i) => { + keys.forEach(function (key, i) { _pendingChange[key] = vals[i]; }); } else { From e49fdce2156427e89c406970ed55749bf201ad05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20H=C3=A4ssler?= Date: Mon, 22 Apr 2019 23:43:55 +0200 Subject: [PATCH 3/3] Add missing semicolons --- modules/ui/raw_tag_editor.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/ui/raw_tag_editor.js b/modules/ui/raw_tag_editor.js index af46456fd7..318c84663c 100644 --- a/modules/ui/raw_tag_editor.js +++ b/modules/ui/raw_tag_editor.js @@ -329,13 +329,13 @@ export function uiRawTagEditor(context) { } // if the key looks like "key=value key2=value2", split them up - #5024 - var keys = (kNew.match(/[\w_]+=/g) || []).map(function (key) { return key.slice(0, -1)}); + var keys = (kNew.match(/[\w_]+=/g) || []).map(function (key) { return key.slice(0, -1); }); var vals = keys.length === 0 ? [] : kNew - .split(new RegExp(keys.map(function (key) { return key.replace('_', '\\_') }).join('|'))) + .split(new RegExp(keys.map(function (key) { return key.replace('_', '\\_'); }).join('|'))) .splice(1) - .map(function (val) { return val.slice(1).trim() }); + .map(function (val) { return val.slice(1).trim(); }); if (keys.length > 0) { kNew = keys[0];