Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle multiple tags when splitting up in tag editor #6211

Merged
merged 3 commits into from
Apr 23, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions modules/ui/raw_tag_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(function (key) { return key.slice(0, -1); });
var vals = keys.length === 0
? []
: kNew
.split(new RegExp(keys.map(function (key) { return key.replace('_', '\\_'); }).join('|')))
.splice(1)
.map(function (val) { return val.slice(1).trim(); });

if (keys.length > 0) {
kNew = keys[0];
vNew = vals[0];

keys.forEach(function (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;
Expand Down